Give the served board its credential in a file, so a rotation shows in its composition (issue 1945)

This commit is contained in:
2026-10-24 19:36:28 +02:00
parent f18bac4533
commit 98e948e30e
@@ -171,6 +171,10 @@ func aServedMesh(t *testing.T) *servedMesh {
for _, m := range storeManifests() {
shelf[m.Module] = m
}
// The board is given its credential in a file, as a consumer of a database is.
board := shelf["board"]
board.Secrets = map[string]string{"postgres-database": "/var/lib/board/database-password"}
shelf["board"] = board
for i, module := range []string{"store", "board"} {
raw, k, trunk := keyOfManifest(t, shelf[module], fpOf(byte('a'+i)), "c0ffee0123456789")
keys := trunkKeys{keyBuckets: keyBuckets{keys: map[string]builderkeys.Key{module: aBuilderKey(module, trunk.FP2, k)},
@@ -363,6 +367,7 @@ func TestServedADoneKeyIsComposedAndGranted(t *testing.T) {
shelf[mf.Module] = mf
}
next := shelf["board"]
next.Secrets = map[string]string{"postgres-database": "/var/lib/board/database-password"}
next.Version = "2"
fp := fpOf('c')
raw, k, trunk := keyOfManifest(t, next, fp, "d00d0123456789ab")
@@ -418,8 +423,8 @@ func TestServedARotationRewritesOnlyTheCompositionsThatUseIt(t *testing.T) {
}
boardKey, _ := sdkdelivery.ComposedKey("laptop", "board", fpOf('b'))
storeKey, _ := sdkdelivery.ComposedKey("anchor", "store", fpOf('a'))
// The store's grants carry the consumer's credential: its composition moves with the rotation.
m.waitFor(t, nil, "anchor", storeKey, before["anchor"][storeKey])
// The board's sealed credential file is new: its composition moves with the rotation.
m.waitFor(t, nil, "laptop", boardKey, before["laptop"][boardKey])
moved := map[string]bool{}
for node, was := range before {
for k, rev := range m.revisions(t, node) {
@@ -433,8 +438,8 @@ func TestServedARotationRewritesOnlyTheCompositionsThatUseIt(t *testing.T) {
t.Errorf("%s moved: only the compositions carrying the credential do", k)
}
}
if !moved[storeKey] {
t.Errorf("the store's composition did not move: %v", moved)
if !moved[boardKey] {
t.Errorf("the board's composition did not move: %v", moved)
}
if n := m.declarationsSent(t); n != 0 {
t.Errorf("%d declarations were sent", n)