Files
archie/internal/app/controlplane/instance_only_test.go
T
2026-10-13 16:17:38 +11:00

28 lines
819 B
Go

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", PersonasKind, 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)
}
})
}
}