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: