package controlplane import ( "errors" "testing" "github.com/samcharles93/archie-core/internal/domain/storecontract" ) func TestInstanceOnlyKindsRefuseOtherOrgs(t *testing.T) { tests := []struct { name, org, kind string refused bool }{ {"another org writes an instance setting", "acme", ToolSettingsKind, true}, {"the system org writes an instance setting", storecontract.DefaultOrgID, ToolSettingsKind, false}, {"another org writes an org-scoped kind", "acme", SoulKind, false}, {"another org writes a forge connection", "acme", ForgeConnectionsKind, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { err := (&Server{}).checkOrgWrite(t.Context(), tt.org, tt.kind, []byte(`{}`)) if refused := errors.Is(err, ErrValidation); refused != tt.refused { t.Fatalf("refused = %v, want %v (err %v)", refused, tt.refused, err) } }) } }