Files
mesh-delivery/modules/mesh-grants/internal/grants/everyright_test.go
T

27 lines
1.1 KiB
Go

package grants
import (
"slices"
"testing"
"mesh-grants/internal/buscompose"
)
// Design 47 G A-383, A-384: a runner's account kept from the list in force gains the rights of hearing new events and the streams'
// names, and loses nothing; a ledger's account gains neither.
func TestAKeptRunnerGainsWhatEveryRunnerCarries(t *testing.T) {
own := map[string][]string{"novox.node-tools": buscompose.NewEventGrants([]string{"EVENTS"})}
kept := map[string]User{"novox.node-tools": {User: "novox.node-tools", Publish: []string{"a"}}, "ledger.novox.m": {User: "ledger.novox.m", Publish: []string{"b"}}}
users, kept := withEveryAccountsRights([]User{{User: "novox.node-tools", Publish: []string{"a"}}}, kept, own)
for _, u := range []User{users[0], kept["novox.node-tools"]} {
for _, want := range []string{"a", buscompose.StreamNamesSubject, "$JS.API.CONSUMER.CREATE.EVENTS.*", "$JS.FC.EVENTS.>"} {
if !slices.Contains(u.Publish, want) {
t.Errorf("the runner lacks %s: %v", want, u.Publish)
}
}
}
if got := kept["ledger.novox.m"].Publish; !slices.Equal(got, []string{"b"}) {
t.Errorf("a ledger's account = %v", got)
}
}