diff --git a/modules/mesh-grants/cmd/mesh-grants/composed_integration_test.go b/modules/mesh-grants/cmd/mesh-grants/composed_integration_test.go index fb847a1f..d0e3ce52 100644 --- a/modules/mesh-grants/cmd/mesh-grants/composed_integration_test.go +++ b/modules/mesh-grants/cmd/mesh-grants/composed_integration_test.go @@ -647,19 +647,32 @@ func aRuntimeDeniedTheMarksHearsNoMarkedCall(t *testing.T) { t.Fatal(err) } asker, askerRefused := bus.dial("a.asker") - // The caller-named subject is process.Call's first: mesh.mod..call... - for _, subject := range []string{"mesh.mod.shell.tool.execute", "mesh.mod.shell.call.execute.asker~a", "mesh.mod.shell.tool.read"} { + // The caller-named subject is process.Call's first: mesh.mod..call.., the token the + // composer grants (buscompose.CallerToken: `a~asker` for the user a.asker). + for _, subject := range []string{"mesh.mod.shell.tool.execute", "mesh.mod.shell.call.execute." + buscompose.CallerToken("a.asker"), "mesh.mod.shell.tool.read"} { if err := asker.Publish(subject, []byte(`{}`)); err != nil { t.Fatal(err) } } + // The server says a refused publish asynchronously, in the order of the publishes: a probe the asker may not publish + // (another caller's token) is refused after every refusal of the calls above, so waiting for it waits on what is asserted. + const probe = "mesh.mod.shell.call.execute.a~someone" + if err := asker.Publish(probe, []byte(`{}`)); err != nil { + t.Fatal(err) + } if err := asker.Flush(); err != nil { t.Fatal(err) } - select { - case e := <-askerRefused: - t.Fatalf("the asker may not call: %s", e) - default: + for probed := false; !probed; { + select { + case e := <-askerRefused: + if !strings.Contains(e, `"`+probe+`"`) { + t.Fatalf("the asker may not call: %s", e) + } + probed = true + case <-time.After(5 * time.Second): + t.Fatal("the probe's refusal never came, so the calls' refusals are not known") + } } select { case m := <-heard: diff --git a/modules/mesh-grants/cmd/mesh-grants/integration_test.go b/modules/mesh-grants/cmd/mesh-grants/integration_test.go index a7d41915..b64f7cdf 100644 --- a/modules/mesh-grants/cmd/mesh-grants/integration_test.go +++ b/modules/mesh-grants/cmd/mesh-grants/integration_test.go @@ -147,7 +147,10 @@ func TestTheGrantsPartWhole(t *testing.T) { consumers := []any{} names := st.ConsumerNames(ctx) for name := range names.Name() { - c, _ := st.Consumer(ctx, name) + c, err := st.Consumer(ctx, name) + if err != nil { + continue // deleted between the listing and its read: the bus module's tool lists what it can read + } cfg := c.CachedInfo().Config consumers = append(consumers, map[string]any{"name": name, "filters": cfg.FilterSubjects, "max_deliver": cfg.MaxDeliver}) }