mesh/delivery-group group feat/r4g rejected: a member's own check failed
mesh/delivery superseded: a newer head of the same pull request
mesh/check failed: g14: novox/mesh-catalog#464: checks/health/go.mod names mesh-sdk a9560890ee26, which is neither on mesh-sdk's trunk nor the group's…
89 lines
3.3 KiB
Go
89 lines
3.3 KiB
Go
package broker
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func hasSubject(list []string, s string) bool {
|
|
for _, x := range list {
|
|
if x == s {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func composedFor(t *testing.T, module string) (pub, sub []string) {
|
|
t.Helper()
|
|
perms, err := PermissionsFor(Principal{Kind: KindModule, Node: "one", Module: module})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return perms.Publish, perms.Subscribe
|
|
}
|
|
|
|
func TestTheWatchmanIsGrantedNothingOnTheBuildSeats(t *testing.T) { // 1908: a waiting ask has no pulse
|
|
pub, sub := composedFor(t, WatchmanModule)
|
|
for _, s := range append(append([]string{}, pub...), sub...) {
|
|
if strings.Contains(s, "node-build") || strings.Contains(s, "NODE_BUILD") {
|
|
t.Errorf("the watchman is granted %s on a build seat", s)
|
|
}
|
|
}
|
|
}
|
|
|
|
func containsAny(list []string, sub string) bool {
|
|
for _, x := range list {
|
|
if strings.Contains(x, sub) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func TestTheViewReadsTheBuildSeatsWorkersByNameAndPublishesNoAsk(t *testing.T) { // 1887/A8a
|
|
pub, sub := composedFor(t, ViewModule)
|
|
for _, s := range []string{
|
|
"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_GO", "$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_GO",
|
|
"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_CHECK_worker", "$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_NODE.SEAT_NODE_BUILD_NODE_RECHECK_worker",
|
|
"$JS.API.CONSUMER.INFO.SEAT_NODE_BUILD_IMAGE.SEAT_NODE_BUILD_IMAGE_DELIVERY_worker", "$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_IMAGE",
|
|
} {
|
|
if !hasSubject(pub, s) {
|
|
t.Errorf("the view cannot request %s", s)
|
|
}
|
|
}
|
|
for _, s := range append(append([]string{}, pub...), sub...) {
|
|
if strings.Contains(s, "mesh.seat.node-build") || (strings.Contains(s, "NODE_BUILD") && (strings.Contains(s, "MSG.NEXT") || strings.Contains(s, "$JS.ACK") || strings.Contains(s, "CONSUMER.CREATE"))) {
|
|
t.Errorf("the view may publish an ask or pull and acknowledge: %s", s)
|
|
}
|
|
}
|
|
perms, _ := PermissionsFor(Principal{Kind: KindModule, Node: "one", Module: ViewModule})
|
|
for _, s := range []string{"mesh.seat.node-build-go.accept.check", "$JS.API.CONSUMER.MSG.NEXT.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_CHECK_worker"} {
|
|
if MayPublish(perms, s) {
|
|
t.Errorf("the view may publish %s", s)
|
|
}
|
|
}
|
|
if other, _ := composedFor(t, "shop"); containsAny(other, "SEAT_NODE_BUILD") {
|
|
t.Errorf("another module reads the build seats: %v", other)
|
|
}
|
|
}
|
|
|
|
// 1910: the builder may read each build seat's stream's information and its messages by sequence, by name, and may not
|
|
// pull, acknowledge or make a consumer there, nor list every stream.
|
|
func TestTheBuilderReadsTheBuildSeatsStreamsByName(t *testing.T) {
|
|
pub, _ := composedFor(t, BuilderModule)
|
|
for _, s := range []string{"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_GO", "$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_GO",
|
|
"$JS.API.STREAM.INFO.SEAT_NODE_BUILD_NODE", "$JS.API.STREAM.MSG.GET.SEAT_NODE_BUILD_IMAGE"} {
|
|
if !hasSubject(pub, s) {
|
|
t.Errorf("the builder cannot request %s", s)
|
|
}
|
|
}
|
|
perms, _ := PermissionsFor(Principal{Kind: KindModule, Node: "one", Module: BuilderModule})
|
|
for _, s := range []string{"$JS.API.STREAM.NAMES", "$JS.API.STREAM.INFO.SEAT_OPERATOR_CHANNEL",
|
|
"$JS.API.CONSUMER.MSG.NEXT.SEAT_NODE_BUILD_GO.SEAT_NODE_BUILD_GO_CHECK_worker", "$JS.API.CONSUMER.CREATE.SEAT_NODE_BUILD_GO"} {
|
|
if MayPublish(perms, s) {
|
|
t.Errorf("the builder may publish %s", s)
|
|
}
|
|
}
|
|
}
|