Merge pull request 'mesh-grants: the marks subtest calls on the caller's granted token and waits for its refusals; the test's nats_streams stand-in skips a consumer gone' (#270) from fix/47-H1-grants-marks-test into main
This commit was merged in pull request #270.
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:
|
||||
|
||||
@@ -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})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user