Let brother's scan-folder take an absolute path: mesh-config matches a pattern against the whole value (issue 1472)
mesh/merge-gate head 35aac9f358cd merged into trunk 1357023bed09 — pass: builds brother → shanks; no bus step; every machine composes with the change as it…
mesh/repo-check head 35aac9f358cd merged into trunk 1357023bed09 — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-…
mesh/delivery delivered

This commit is contained in:
2026-10-20 21:49:47 +02:00
parent 1357023bed
commit 35aac9f358
2 changed files with 39 additions and 1 deletions
@@ -357,3 +357,41 @@ func TestTheBucketIsRequiredAndItsKeyIsOnlyTheDeviceAccounts(t *testing.T) {
}
}
}
// Issue 1472: mesh-config matches a config value against its pattern whole, as mesh-sdk's catalogue compiles it
// (`^(?:<pattern>)$`, go/catalogue/config.go). Each value the operator gives on a real node passes, and a value
// of the wrong form does not.
func TestEachConfigPatternAdmitsARealValueWhole(t *testing.T) {
raw, err := os.ReadFile(filepath.Join("..", "..", "module.json"))
if err != nil {
t.Fatal(err)
}
var m struct {
Config map[string]struct {
Pattern string `json:"pattern"`
} `json:"config"`
}
if err := json.Unmarshal(raw, &m); err != nil {
t.Fatal(err)
}
cases := map[string]struct{ good, bad string }{
"scanner": {"http://192.0.2.10/eSCL", "192.0.2.10"},
"scan-folder": {"/home/operator/Documents/Scans", "Documents/Scans"},
"printer": {"192.0.2.10", "http://192.0.2.10"},
"printer-certificate": {"EA:B4:B7:0F:96:CD:A6:2B:61:53:2E:F0:A8:D6:9F:42:EA:9F:66:0A:82:5B:C2:43:0B:97:C5:9A:7A:B4:18:5B", "EAB4"},
}
for key, c := range cases {
p := m.Config[key].Pattern
if p == "" {
t.Errorf("%s declares no pattern", key)
continue
}
re := regexp.MustCompile(`^(?:` + p + `)$`)
if !re.MatchString(c.good) {
t.Errorf("%s's pattern %q refuses the real value %q", key, p, c.good)
}
if re.MatchString(c.bad) {
t.Errorf("%s's pattern %q admits %q", key, p, c.bad)
}
}
}