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) } } }