mesh-grants: the marks subtest calls on the caller's granted token and waits for its refusals
The subtest "a runtime denied the marks is delivered no call on a marked subject" published the caller-named call on mesh.mod.shell.call.execute.asker~a, a token the composer never grants (buscompose.CallerToken gives a~asker for the user a.asker), so the server refused it every time; the test passed only because it read the refusals with a non-blocking select right after Flush, before the client's error callback had run. Under load the callback won the race and the pipeline's integration step failed (main.12, 15:50). The call now uses CallerToken, and a probe on another caller's token is published last: the server refuses in order, so waiting for the probe's refusal waits on every refusal asserted. Builds: design 47 H §746 (the pipeline's integration step), G A-203 (AM-D4)
This commit is contained in:
@@ -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.<module>.call.<tool>.<caller's token>.
|
||||
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.<module>.call.<tool>.<caller's token>, 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:
|
||||
|
||||
Reference in New Issue
Block a user