package controlplanestore import ( "errors" "testing" "github.com/samcharles93/archie-core/internal/domain/storecontract" ) func TestTaskPolicyNamesNoInstanceSecretForAnotherOrg(t *testing.T) { const signed = `{"notify_webhook":"https://example.com/hook","notify_secret":{"engine":"env","key":"INSTANCE_KEY"}}` const unsigned = `{"notify_webhook":"https://example.com/hook"}` tests := []struct { name, org, value string refused bool }{ {"system org signs with a secret", storecontract.DefaultOrgID, signed, false}, {"another org names an instance secret", "acme", signed, true}, {"another org sets only its webhook", "acme", unsigned, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { err := (&Server{}).checkOrgWrite(t.Context(), tt.org, TaskPolicyKind, []byte(tt.value)) if refused := errors.Is(err, ErrValidation); refused != tt.refused { t.Fatalf("refused = %v, want %v (err %v)", refused, tt.refused, err) } }) } }