Files
archie/internal/app/controlplane/instance_only_test.go
T
sam cb48a27d16 feat(controlplane): organisation forge connections
A connection is an organisation's own resource: the forge host, the
credential reference and the external account it belongs to. It records a
reference, never a token value, and names per execution identity the
operations that identity may perform through it.

The file's [forge] sections seed it: the root's becomes the root connection
and each identity's own forge becomes a connection only that identity may
use, so the migration keeps exactly the grants the file expressed.
2026-10-17 03:05:01 +11:00

29 lines
897 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", 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)
}
})
}
}