ADR 0593 §7: the composer with its refusals leaves mesh-sdk, so mesh-sdk carries no composition rule. The catalogue functions only the node-engine's composition reaches (Resolve, Resolution's Compose, Declaration, DataItems, LeftOut, Rules and the rest, the settings, placeholder and template refusals, the rendering helpers) are copied with their tests into internal/compose/resolution; a method of a mesh-sdk shape becomes a function taking it first. The composition calls its own copies, and the captured catalogue its tests read lives here now, shared by mesh-compose's tests. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
package resolution
|
|
|
|
import (
|
|
"testing"
|
|
|
|
mcat "git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
func familyManifest(t *testing.T, ownSecrets string) (mcat.Manifest, error) {
|
|
t.Helper()
|
|
return decodeForTest([]byte(`{"module":"mounts","version":"1","own-secrets":{` + ownSecrets + `}}`))
|
|
}
|
|
|
|
// A member given is one file at its path; one not given is nothing, and the machine still composes — the mesh never
|
|
// makes a member.
|
|
func TestAMemberGivenIsPlacedAndOneNotGivenIsNothing(t *testing.T) {
|
|
m, err := familyManifest(t, `"smb-password-*":{"path":"/var/lib/mounts/smb-password-*.secret","issued-by":"outside"}`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
r := mcat.Resolution{Node: "workstation", Modules: []mcat.Manifest{m}}
|
|
out, err := Declaration(r, mcat.Rendering{Needed: map[string]map[string]string{"mounts": {"smb-password-games": "sealed"}}})
|
|
if err != nil {
|
|
t.Fatalf("a module with one member given did not compose: %v", err)
|
|
}
|
|
var paths []string
|
|
for _, res := range out {
|
|
if res["sealed"] != nil {
|
|
paths = append(paths, res["path"].(string))
|
|
}
|
|
}
|
|
if len(paths) != 1 || paths[0] != "/var/lib/mounts/smb-password-games.secret" {
|
|
t.Fatalf("placed: %v", paths)
|
|
}
|
|
out, err = Declaration(r, mcat.Rendering{})
|
|
if err != nil {
|
|
t.Fatalf("a module with no member given did not compose: %v", err)
|
|
}
|
|
for _, res := range out {
|
|
if res["sealed"] != nil {
|
|
t.Fatalf("a member nobody gave was placed: %v", res)
|
|
}
|
|
}
|
|
}
|