status: box identity test uses a real projection
Builds a root seeds-floor projection with the root-runner fixtures: one naming this box is accepted, one naming another box is quarantined.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+90
−0
internal/host/seedsfloorprobe_root_linux_test.go+90 −0
CI failed — run details
diff --git a/internal/host/seedsfloorprobe_root_linux_test.go b/internal/host/seedsfloorprobe_root_linux_test.go| new file mode 100644 |
| index 000000000..c5d2c02bf |
| --- /dev/null |
| +++ b/internal/host/seedsfloorprobe_root_linux_test.go |
| @@ -0,0 +1,90 @@ |
| +//go:build linux && rootrunner |
| + |
| +package host |
| + |
| +import ( |
| + "context" |
| + "crypto/ed25519" |
| + "encoding/base64" |
| + "github.com/carlosframework/platform/internal/moves" |
| + "github.com/carlosframework/platform/internal/release" |
| + "github.com/carlosframework/platform/internal/rootstate" |
| + "github.com/carlosframework/platform/internal/seeds" |
| + "os" |
| + "path/filepath" |
| + "testing" |
| +) |
| + |
| +// TestSeedsFloorFieldsBoxIdentityRootRunner is plan R3-2 against a real root |
| +// projection (the fixtures of TestPlan14RootSeedsFloorRootRunner): one that |
| +// names this box is accepted, one that names another box is quarantined. |
| +func TestSeedsFloorFieldsBoxIdentityRootRunner(t *testing.T) { |
| + opt := generationRootRunnerDir(t) |
| + dd := filepath.Join(opt, "data") |
| + if err := os.Mkdir(dd, 0755); err != nil { |
| + t.Fatal(err) |
| + } |
| + id := rootFloorIdentity{"deploy", "box", "en"} |
| + pub, key, _ := ed25519.GenerateKey(nil) |
| + t.Setenv("CARLOS_RELEASE_PUBKEY", base64.StdEncoding.EncodeToString(pub)) |
| + t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "deploy") |
| + rootFloorSignRunnerBytes(t, opt, systemBinaryPath(opt), "v2.0.0", []byte("#!/bin/sh\nexit 0\n"), key) |
| + if false { |
| + rootFloorSignRunnerBytes(t, opt, systemPrevPath(opt), "v2.0.0", []byte("#!/bin/sh\nexit 0 #prev\n"), key) |
| + } |
| + identities, e := rootstate.Open(filepath.Join(opt, "system", "guard", "identities"), false, true) |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + names, e := identities.Names() |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + for _, name := range names { |
| + raw, e := identities.Read(name) |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + var p release.SystemPointer |
| + if release.VerifyRootEnvelope(pub, raw, &p) != nil { |
| + t.Fatal("identity") |
| + } |
| + p.Current.SeedsProtocol = 1 |
| + wire, e := release.SignRootEnvelope(release.RootSigner(key), p) |
| + if e != nil { |
| + t.Fatal(e) |
| + } |
| + if e := identities.Write(name, wire); e != nil { |
| + t.Fatal(e) |
| + } |
| + } |
| + identities.Close() |
| + f, err := openRootProtocolFloors(rootSeedsFloorDir(opt), id, true) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer f.close() |
| + a := moves.Floor{Min: 1, MinRelease: "v1.0.0"} |
| + if err := f.reconstruct(t.Context(), rootFloorReconstruction{Identity: id, Floor: &a, Source: "root history", Digest: floorTestDigest, Authorization: floorTestAuthorization(t, f)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + j := rootFloorJudge{floors: f, current: systemBinaryPath(opt), prev: systemPrevPath(opt), binary: func(path string) (rootFloorBinary, error) { return readRootSeedsBinary(opt, path) }, idle: func(context.Context) error { return nil }} |
| + if err := j.judge(t.Context()); err != nil { |
| + t.Fatal(err) |
| + } |
| + initial, err := release.SignRootEnvelope(release.RootSigner(key), rootSeedsPublication{Schema: 1, Deployment: id.Deployment, Purpose: seeds.FloorKey, Floor: a}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := acceptRootSeedsPublication(t.Context(), f, initial); err != nil { |
| + t.Fatal(err) |
| + } |
| + moved := movesFloorContext{State: "accepted"} |
| + if got := seedsFloorFields(dd, opt, id.Box, moved); got.MinRelease != a.MinRelease { |
| + t.Fatalf("a projection naming this box was not accepted: %+v", got) |
| + } |
| + got := seedsFloorFields(dd, opt, "not-"+id.Box, moved) |
| + if got.FloorState != "quarantined" || got.MinRelease != "" || got.PrevAllowedFor != "" { |
| + t.Fatalf("a projection naming another box = %+v, want quarantined", got) |
| + } |
| +} |