Files
mesh-delivery/modules/mesh-grants/internal/buscompose/recovery_engine_test.go
T
jschoubben 8fc1997b1b fix9-8: the grants part composes the node-engine's grants for the seat mesh-recovery and for a module's catch-up tool
The node-engine of a node hears the kept events ended and restored through an ordered consumer, and calls the catch-up tool of a module placed on its node (its manifest's kept data name it); the verbs snapshot-kept, restore-kept and kept-points were granted already as the engine's invokes. No nodegrant mirror lives in mesh-delivery (it is mesh-host's).

Builds: design 47 G §406, §554, §631, A-108
2026-11-12 01:13:03 +01:00

50 lines
2.2 KiB
Go

package buscompose
import (
"testing"
)
// Design 47 G §406, §554, A-108: the node-engine of a node is granted to hear the seat mesh-recovery's kept events ended and
// restored through an ordered consumer, to ask the verbs snapshot-kept, restore-kept and kept-points of the seat, and to call
// the catch-up tool of a module placed on its node, on its own node's tool subject and no other module's tool.
func TestTheNodeEngineIsGrantedWhatItNeedsOfTheRecoverySeat(t *testing.T) {
kept := []KeptEvent{
{Seat: "mesh-recovery", Event: "ended", Stream: "SEAT_mesh-recovery_ended", Filter: "mesh.seat.mesh-recovery.event.ended.*.*"},
{Seat: "mesh-recovery", Event: "restored", Stream: "SEAT_mesh-recovery_restored", Filter: "mesh.seat.mesh-recovery.event.restored.*.*"},
}
records := Records{Nodes: []string{"one"}, Kept: kept,
Engine: &Declared{Module: EngineModule, Consumes: []string{"mesh-recovery.ended", "mesh-recovery.restored"},
Invokes: []string{"seat:mesh-recovery.snapshot-kept", "seat:mesh-recovery.restore-kept", "seat:mesh-recovery.kept-points"}},
Assigned: map[string][]Declared{"one": {{Module: "keeper", CatchUps: []string{"catch_up"}}, {Module: "plain"}}}}
users, err := Users(records)
if err != nil {
t.Fatal(err)
}
var node Principal
for _, u := range users {
if u.Kind == KindNode {
node = u
}
}
perms, err := PermissionsFor(node)
if err != nil {
t.Fatal(err)
}
for _, want := range []string{
"$JS.API.CONSUMER.CREATE.SEAT_mesh-recovery_ended", "$JS.API.CONSUMER.CREATE.SEAT_mesh-recovery_ended.>",
"$JS.API.CONSUMER.MSG.NEXT.SEAT_mesh-recovery_ended.*", "$JS.API.CONSUMER.DELETE.SEAT_mesh-recovery_restored.*",
"$JS.API.STREAM.INFO.SEAT_mesh-recovery_restored",
"mesh.seat.mesh-recovery.tool.snapshot-kept", "mesh.seat.mesh-recovery.tool.restore-kept", "mesh.seat.mesh-recovery.tool.kept-points",
"mesh.mod.keeper.tool.catch_up.one",
} {
if !MayPublish(perms, want) {
t.Errorf("the node-engine of one may not publish %s", want)
}
}
for _, bad := range []string{"mesh.mod.plain.tool.catch_up.one", "mesh.mod.keeper.tool.other.one", "$JS.API.CONSUMER.CREATE.SEAT_mesh-recovery_set-aside"} {
if MayPublish(perms, bad) {
t.Errorf("the node-engine of one may publish %s", bad)
}
}
}