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.
29 lines
897 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|