Warn instead of holding the machine for an unissued process account, and drive the delivery path in the test (issue 1226, review round 1)

This commit is contained in:
2026-10-21 19:25:44 +02:00
parent 6bcfbeb5b2
commit faf8beee84
4 changed files with 109 additions and 67 deletions
+15 -21
View File
@@ -1,33 +1,27 @@
package main
import (
"strings"
"testing"
)
import "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) {
// 1226/AC1: given a module whose process declares bus and has no issued account, when a machine is composed, the
// push's warning names issue, and the machine's other modules are composed (AC4: nothing is refused).
func TestAProcessAccountNobodyIssuedIsWarnedOfNamingIssue(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")
got := processAccountWarning(m, "laptop", "broker-send", nil)
want := "laptop/mesh-mail process send: its bus account is not issued — mesh-controller.issue laptop mesh-mail"
if got != want {
t.Fatalf("1226/AC1: the warning is %q, want %q", got, want)
}
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.
if processAccountWarning(m, "laptop", "broker", nil) != "" || processAccountWarning(m, "laptop", "broker-other", nil) != "" ||
processAccountWarning(m, "laptop", "token", nil) != "" {
t.Fatal("1226/AC1: a name that is no declared process's account was warned of")
}
// 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)
if got := processAccountWarning(m, "laptop", "broker-send", []string{"laptop.mesh-mail.send"}); got != "" {
t.Fatalf("1226/AC3: an issued account was warned of: %q", got)
}
}
// 1226/AC3: an account already issued is not replaced by a later compose, nor issued again by a delivery.
// 1226/AC3: an account already issued is not issued again by a later delivery or assignment.
func TestAnIssuedProcessAccountIsNotIssuedAgain(t *testing.T) {
m := mailSenderWithProcess()
if got := processAccountsMissing(m, "laptop", nil); len(got) != 1 || got[0].Process != "send" {