Compose a licence key the Input does not carry with a stand-in named foreseen; keep empty only where Keys is given and lacks the holder (review round 1, finding 3). The test failed first

This commit is contained in:
2026-10-20 07:01:50 +00:00
parent 66da19827c
commit 0864ae5e47
3 changed files with 43 additions and 2 deletions
+33
View File
@@ -325,3 +325,36 @@ func TestSettingsAreReturnedForEveryResolvedModuleIncludingOneThatWasPulledIn(t
t.Error("the settings returned share the Input's layers")
}
}
// Round 1, finding 3: a licence key the Input does not carry (Keys not given) is composed with a stand-in and named foreseen, so the
// node still composes; Keys given that lack the holder is the mesh holding none, and the need stays empty.
func TestALicenceKeyTheInputDoesNotCarryIsAStandInAndNamedForeseen(t *testing.T) {
in := aMesh(t)
in.Catalogue["assistant"] = catalogue.Manifest{Module: "assistant", Version: "1", Requires: []string{LicenceProvision}}
laptop := nodeOf(t, &in, "laptop")
laptop.Assigned = append(laptop.Assigned, "assistant")
in.Licences = []Licence{{Name: "personal", Serves: map[string]any{"model": "x"}, Holders: []Holder{{Node: "laptop", Module: "assistant"}}}}
got, err := Resolve(in, "laptop")
if err != nil {
t.Fatal(err)
}
if n := need(t, got.Plan, "assistant", LicenceProvision); n.Sealed != catalogue.ForeseenSealed {
t.Errorf("a key not given is composed as %q", n.Sealed)
}
if len(got.Foreseen) != 1 || !strings.Contains(got.Foreseen[0], "assistant on laptop needs model-access") {
t.Errorf("foreseen %v", got.Foreseen)
}
// And a whole node composes with it.
if _, problems, err := Compose(in, "laptop"); err != nil || len(problems) != 0 {
t.Errorf("a node using a licence whose key is not carried: %v %v", err, problems)
}
// Keys given, and none for this holder: the mesh holds none.
in.Licences[0].Keys = map[Holder]string{}
got, err = Resolve(in, "laptop")
if err != nil {
t.Fatal(err)
}
if n := need(t, got.Plan, "assistant", LicenceProvision); n.Sealed != "" || len(got.Foreseen) != 0 {
t.Errorf("a key the mesh holds none of: %q %v", n.Sealed, got.Foreseen)
}
}