The vault's seat, and a report that carries the machine's profile (hq ADR 0161)
mesh-vault joins the mesh's own set — mesh-scoped, delivering secret — because the controller seals every minted credential with it, which is the test for a seat of the mesh's own; a second provider is a second claimant, refused by name (issue 106). A report may carry the machine's profile, detected again by the apply that reports, and the latest replaces the enrolled one: a machine that switched its network manager is a machine whose uplink holder lacks a capability at its next push (issue 138).
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package link_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/novox/mesh-controller/internal/link"
|
||||
)
|
||||
|
||||
// A report may carry the machine's profile, detected again by the apply that reports, and the latest
|
||||
// replaces what enrolment recorded (novox/hq ADR 0161): a machine that switched its network manager
|
||||
// is a machine whose uplink holder lacks a capability at its next push, not at its next enrolment.
|
||||
func TestAReportsProfileReplacesTheEnrolledOne(t *testing.T) {
|
||||
e, _, _ := anEnrolledHub(t)
|
||||
ctx := t.Context()
|
||||
first := map[string]any{"capabilities": []any{map[string]any{"name": "uplink-networkmanager", "present": true}}}
|
||||
if _, err := e.Heard(ctx, link.Report{Node: "anchor", Profile: first}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err := e.Inventory.Profile(ctx, "anchor")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(got) != 1 || got[0].Name != "uplink-networkmanager" || !got[0].Present {
|
||||
t.Fatalf("the report's profile was not kept: %+v", got)
|
||||
}
|
||||
// The machine switched managers; the next report says so and the old fact is gone.
|
||||
second := map[string]any{"capabilities": []any{map[string]any{"name": "uplink-systemd-networkd", "present": true}}}
|
||||
if _, err := e.Heard(ctx, link.Report{Node: "anchor", Profile: second}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err = e.Inventory.Profile(ctx, "anchor")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(got) != 1 || got[0].Name != "uplink-systemd-networkd" {
|
||||
t.Fatalf("the latest profile did not replace the earlier one: %+v", got)
|
||||
}
|
||||
// A report with no profile leaves the last one standing.
|
||||
if _, err := e.Heard(ctx, link.Report{Node: "anchor", Host: "1"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, _ = e.Inventory.Profile(ctx, "anchor"); len(got) != 1 {
|
||||
t.Fatalf("a report without a profile erased it: %+v", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user