package store import "testing" func TestLocalityPublicationCeilingIntersection(t *testing.T) { for _, domain := range []string{"public", "authenticated_acl"} { for _, q := range []string{"inherit", "public", "authenticated_acl"} { for _, st := range []string{"inherit", "public", "authenticated_acl"} { for _, spot := range []string{"inherit", "public", "authenticated_acl"} { chain := []LocalityPolicy{{Kind: "domain", Policy: domain}, {Kind: "quartier", Policy: q}, {Kind: "street", Policy: st}, {Kind: "spot", Policy: spot}} allows, published := EvaluateLocalityPublication(chain) wantCap := domain == "public" && q != "authenticated_acl" && st != "authenticated_acl" && spot != "authenticated_acl" wantPublic := wantCap && (q == "public" || st == "public" || spot == "public") if allows != wantCap || published != wantPublic { t.Fatalf("chain=%+v result=%v,%v", chain, allows, published) } } } } } for _, policy := range []string{"inherit", "invalid", ""} { if allows, published := EvaluateLocalityPublication([]LocalityPolicy{{Kind: "domain", Policy: policy}, {Kind: "spot", Policy: "public"}}); allows || published { t.Fatal("invalid Domain policy failed open") } } }