Files
mesh-host/internal/declaration/trusted_test.go
T
jochen 7c046a8a1d
mesh/merge-gate pass: builds mesh-host → ace, g14, novox, shanks; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: its merge-check.sh passed
mesh/delivery delivered
Accept and ignore a file's trusted, and give each runtime its own time to answer
The fourth review (hq issue 339): `trusted` is the catalogue's word and the
controller takes it out, but a controller that passes it on, an older one or
one rolled back to, must not cost a node its whole declaration. A file now
accepts it and nothing reads it; any other resource still refuses it. And a
podman that hangs no longer eats docker's ten seconds.
2026-10-09 01:42:09 +02:00

24 lines
1002 B
Go

package declaration
import "testing"
// `trusted` is the catalogue's word on a file (novox/hq issue 339): a controller takes it out before it sends a
// declaration, and one that does not — an older one, or one rolled back to — must not cost the node its whole
// declaration. So a file accepts it and the engine does nothing with it; any other resource still refuses it.
func TestAFileAcceptsAndIgnoresTrusted(t *testing.T) {
for _, v := range []string{"true", "false"} {
d, err := Parse([]byte(`{"declaration":1,"resources":[{"id":"m.f","type":"file","path":"/etc/m.conf",` +
`"content":"x","trusted":` + v + `}]}`))
if err != nil {
t.Fatalf("trusted %s: %v", v, err)
}
if f, ok := d.Resources[0].(*File); !ok || f.Content != "x" {
t.Fatalf("trusted %s: %+v", v, d.Resources[0])
}
}
if _, err := Parse([]byte(`{"declaration":1,"resources":[{"id":"m.d","type":"directory","path":"/srv/m",` +
`"trusted":true}]}`)); err == nil {
t.Fatal("a directory took trusted")
}
}