Refuse a process account's stand-in, naming issue (issue 1226)

This commit is contained in:
2026-10-21 19:21:11 +02:00
parent 5ba2ffe8e6
commit deac3e232c
3 changed files with 172 additions and 0 deletions
@@ -0,0 +1,42 @@
package main
import (
"strings"
"testing"
)
// 1226/AC1: given a module whose process declares bus and has no issued account, when a machine's declaration
// is composed, the push refuses that module, naming issue. (The composition's wiring is proven against the store
// in TestAGainedProcessIsIssuedWhenTheDeliveryRecordsIt.)
func TestAProcessAccountNobodyIssuedIsRefusedNamingIssue(t *testing.T) {
m := mailSenderWithProcess()
err := processAccountRefusal(m, "laptop", "broker-send", nil)
if err == nil {
t.Fatal("1226/AC1: a process account nobody issued was not refused, so a random value would be made")
}
if !strings.Contains(err.Error(), "mesh-controller.issue laptop mesh-mail") {
t.Fatalf("1226/AC1: the refusal does not name issue: %v", err)
}
// Other names are not this rule's: the module's own broker and a secret of no process.
if processAccountRefusal(m, "laptop", "broker", nil) != nil || processAccountRefusal(m, "laptop", "broker-other", nil) != nil {
t.Fatal("1226/AC1: a name that is no declared process's account was refused")
}
// Issued, it is not refused.
if err := processAccountRefusal(m, "laptop", "broker-send", []string{"laptop.mesh-mail.send"}); err != nil {
t.Fatalf("1226/AC1: an issued account was refused: %v", err)
}
}
// 1226/AC3: an account already issued is not replaced by a later compose, nor issued again by a delivery.
func TestAnIssuedProcessAccountIsNotIssuedAgain(t *testing.T) {
m := mailSenderWithProcess()
if got := processAccountsMissing(m, "laptop", nil); len(got) != 1 || got[0].Process != "send" {
t.Fatalf("1226/AC3: an account not issued is not missing: %v", got)
}
if got := processAccountsMissing(m, "laptop", []string{"laptop.mesh-mail.send"}); len(got) != 0 {
t.Fatalf("1226/AC3: an issued account would be issued again: %v", got)
}
if got := processAccountsMissing(m, "ace", []string{"laptop.mesh-mail.send"}); len(got) != 1 {
t.Fatalf("1226/AC3: another machine's account stands in for this one's: %v", got)
}
}