Add the replays of issues 279 and 412 (hq issues 279, 412) #285

Merged
mesh-admin merged 1 commits from fix/279-412-replays into main 2026-10-13 00:45:26 +00:00
2 changed files with 72 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
package catalogue
import "testing"
// Replay of novox/hq issue 279 (2026-10-06): the media managers' recycle-bin folders were declared owned by
// a literal user and group, and on a machine whose puid and pgid settings named another account the apps
// refused them as not writable. A directory's owner could not follow the account its module runs as. Written
// only with what the catalogue had before its fix (mesh-controller #260): Compose, LeftOut, a setting layer,
// and the adoption tests' anchor, so it is laid over the commit before.
func TestReplay279(t *testing.T) {
r := anAdoptedAnchor()
r.Modules = append(r.Modules, Manifest{Module: "sonarr",
Resources: []map[string]any{
{"id": "recycle-bin", "type": "directory", "path": "/srv/sonarr/recycle", "mode": "0755",
"owner": "${setting:puid}:${setting:pgid}"},
{"id": "identity", "type": "file", "path": "/srv/sonarr/identity.env", "mode": "0644",
"content": "PUID=${setting:puid}\nPGID=${setting:pgid}\n"},
},
})
with := anchorRendering(false)
with.Settings["sonarr"] = []Layer{{From: "node anchor", Values: map[string]any{"puid": "1001", "pgid": "2000"}}}
composed, err := r.Compose(with)
if err != nil {
t.Fatalf("the machine did not compose: %v", err)
}
if why, left := composed.LeftOut["sonarr"]; left {
t.Fatalf("the module was left out: %s", why)
}
got, ok := byID(composed.Resources)["sonarr.recycle-bin"]
if !ok {
t.Fatal("the recycle bin was not declared")
}
if got["owner"] != "1001:2000" {
t.Fatalf("the recycle bin reaches the node-engine owned by %v, not the account the module runs as (1001:2000)", got["owner"])
}
}
+36
View File
@@ -0,0 +1,36 @@
package catalogue
import (
"strings"
"testing"
)
// Replay of novox/hq issue 412 (2026-10-10): which module owns /etc/hosts was enforced only after the fact,
// when two modules on one machine declared it; a module that did not claim node-hostname could declare
// /etc/hosts, and a module could claim node-hostname declaring none of its paths, and nothing refused either.
// Written only with what the catalogue had before its fix (mesh-controller #267): CatalogueProblems, Shelf,
// SeatNamed and CanHold, so it is laid over the commit before.
func TestReplay412(t *testing.T) {
stranger := Manifest{Module: "stranger", Version: "1", Resources: []map[string]any{
{"id": "hosts", "type": "file", "path": "/etc/hosts", "into": "block", "content": "10.0.0.1 x\n"}}}
got := strings.Join(CatalogueProblems(Shelf{"stranger": stranger}), "; ")
if !strings.Contains(got, "node-hostname") {
t.Errorf("a module declaring /etc/hosts without claiming node-hostname was not refused: %q", got)
}
seat, ok := SeatNamed("node-hostname")
if !ok {
t.Fatal("no node-hostname seat")
}
holder := Manifest{Module: "names", Version: "1", Claims: []Claim{{Name: "node-hostname", Scope: ScopeNode,
Serves: []string{"entries", "add", "remove"}}}}
err := CanHold(holder, seat)
if err == nil {
t.Fatal("a holder of node-hostname declaring neither /etc/hosts nor /etc/hostname was accepted")
}
for _, want := range []string{"/etc/hosts", "/etc/hostname"} {
if !strings.Contains(err.Error(), want) {
t.Errorf("the refusal does not name %s: %v", want, err)
}
}
}