Make the credentials in four integration tests by a send, not a question, and name the refusal each now meets

This commit is contained in:
2026-10-20 11:30:55 +00:00
parent 37d61441f8
commit 33b285ce09
3 changed files with 19 additions and 6 deletions
@@ -82,8 +82,8 @@ func TestAPairCredentialNoRowHoldsIsAWouldMakeAndNoRowIsInserted(t *testing.T) {
if _, err := inv.Assign(ctx, "laptop", "reports"); err != nil { if _, err := inv.Assign(ctx, "laptop", "reports"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
// The controller's own planning makes the credentials of files and reports. // A send makes the credentials of files and reports; a question makes none.
if _, _, err := resolveNode(ctx, open, "laptop"); err != nil { if _, err := composeSend(ctx, open, "laptop"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
register(t, open, aConsumerOfTheBucket("metrics")) register(t, open, aConsumerOfTheBucket("metrics"))
@@ -39,6 +39,10 @@ func TestAConsumerPinnedBackIsNoLongerGrantedByTheProviderItLeft(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Only a send makes a credential; a question makes nothing.
if _, err := composeSend(ctx, open, "laptop"); err != nil {
t.Fatal(err)
}
if n := need(t, plan, "board", "postgres-database"); n.From != "anchor" { if n := need(t, plan, "board", "postgres-database"); n.From != "anchor" {
t.Fatalf("pinned to the anchor and bound to %s", n.From) t.Fatalf("pinned to the anchor and bound to %s", n.From)
} }
@@ -61,6 +65,9 @@ func TestAConsumerPinnedBackIsNoLongerGrantedByTheProviderItLeft(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if _, err := composeSend(ctx, open, "laptop"); err != nil {
t.Fatal(err)
}
if n := need(t, plan, "board", "postgres-database"); n.From != "laptop" { if n := need(t, plan, "board", "postgres-database"); n.From != "laptop" {
t.Fatalf("pinned back to the laptop and bound to %s", n.From) t.Fatalf("pinned back to the laptop and bound to %s", n.From)
} }
@@ -131,7 +138,7 @@ func TestAConsumerWhoseResolutionCannotBeReadIsNotWithdrawn(t *testing.T) {
t.Fatalf("assign %s %s: %v", a[0], a[1], err) t.Fatalf("assign %s %s: %v", a[0], a[1], err)
} }
} }
if _, _, err := resolveNode(ctx, open, "laptop"); err != nil { if _, err := composeSend(ctx, open, "laptop"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -151,7 +158,8 @@ func TestAConsumerWhoseResolutionCannotBeReadIsNotWithdrawn(t *testing.T) {
if err == nil { if err == nil {
t.Fatalf("an unreadable consumer was answered: grants %+v, unbound %+v", grants, unbound) t.Fatalf("an unreadable consumer was answered: grants %+v, unbound %+v", grants, unbound)
} }
if !strings.Contains(err.Error(), "what laptop asked of postgres-database cannot be read") { // mesh-sdk names the provider's node where the controller's own words named the provision.
if !strings.Contains(err.Error(), "what laptop asked of") || !strings.Contains(err.Error(), "cannot be read") {
t.Fatalf("the error does not say whose resolution could not be read: %v", err) t.Fatalf("the error does not say whose resolution could not be read: %v", err)
} }
} }
@@ -22,8 +22,13 @@ func TestTheProvisionerClientsAccountIsIssuedForItsServiceAndNeverInvented(t *te
if _, err := assign(ctx, open, "laptop", m.Module); err != nil { if _, err := assign(ctx, open, "laptop", m.Module); err != nil {
t.Fatal(err) t.Fatal(err)
} }
// The module's own account exists, so the only account missing is the client's.
if _, err := inv.MintBusPassword(ctx, inventory.BusUser{
Username: "laptop.mesh-provisioner", Kind: inventory.BusModule, Node: "laptop", Module: "mesh-provisioner"}); err != nil {
t.Fatal(err)
}
// The composition refuses it in the send's words (mesh-sdk's go/compose: TestTheSendsRefusalsAreRefusedInTheSendsWords). // The composition refuses it in the send's words (mesh-sdk's go/compose: TestTheSendsRefusalsAreRefusedInTheSendsWords).
if _, _, err := composeQuestion(ctx, open, "laptop", compose.Foreseeing, false); err == nil || !strings.Contains(err.Error(), "has no bus credential") { if _, _, err := composeQuestion(ctx, open, "laptop", compose.Foreseeing, false); err == nil || !strings.Contains(err.Error(), "provisioner.laptop") {
t.Fatalf("a push would seal a placeholder for the client's account before it was issued: %v", err) t.Fatalf("a push would seal a placeholder for the client's account before it was issued: %v", err)
} }
@@ -40,7 +45,7 @@ func TestTheProvisionerClientsAccountIsIssuedForItsServiceAndNeverInvented(t *te
if !slices.ContainsFunc(states, func(s inventory.SecretState) bool { return s.Name == broker.ProvisionerSecret }) { if !slices.ContainsFunc(states, func(s inventory.SecretState) bool { return s.Name == broker.ProvisionerSecret }) {
t.Fatalf("the client's account is not sealed to the machine for its service: %+v", states) t.Fatalf("the client's account is not sealed to the machine for its service: %+v", states)
} }
if _, _, err := composeQuestion(ctx, open, "laptop", compose.Foreseeing, false); err != nil && strings.Contains(err.Error(), "has no bus credential") { if _, _, err := composeQuestion(ctx, open, "laptop", compose.Foreseeing, false); err != nil && strings.Contains(err.Error(), "provisioner.laptop") {
t.Fatalf("an issued client account is refused: %v", err) t.Fatalf("an issued client account is refused: %v", err)
} }
if !runsTheProvisionerClient(m) { if !runsTheProvisionerClient(m) {