Builds: design 47 G A-115, A-127 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
26 lines
1.1 KiB
Go
26 lines
1.1 KiB
Go
package grants
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// Design 47 G A-115, A-127: a process's `serves`, beside its bus, is its account's (a process with a bus) or the module's own
|
|
// (a process with none); a `serves` inside the bus is no grant.
|
|
func TestAProcessesServesAreReadBesideItsBus(t *testing.T) {
|
|
m := catalogue.Manifest{Module: "nats", Resources: []map[string]any{
|
|
{"id": "keeper", "type": "process", "serves": []any{"seat:mesh-broker.list"}, "bus": map[string]any{"keeps": true}},
|
|
{"id": "plain", "type": "process", "serves": []any{"seat:mesh-broker.snapshot-get"}},
|
|
{"id": "inside", "type": "process", "bus": map[string]any{"serves": []any{"seat:mesh-broker.remove"}}},
|
|
}}
|
|
procs := processesOf(m)
|
|
if len(procs) != 1 || procs[0].Process != "keeper" || !slices.Equal(procs[0].Serves, []string{"seat:mesh-broker.list"}) {
|
|
t.Errorf("the process principals = %+v; want the keeper serving seat:mesh-broker.list", procs)
|
|
}
|
|
if got := ownServesOf(m); !slices.Equal(got, []string{"seat:mesh-broker.snapshot-get"}) {
|
|
t.Errorf("the module's own serves = %v; want the bus-less process's alone", got)
|
|
}
|
|
}
|