| index 8d1c07181..06c5b5380 100644 |
| --- a/internal/console/apisystemupdate_test.go |
| +++ b/internal/console/apisystemupdate_test.go |
| @@ -88,6 +88,17 @@ func seedBox(t *testing.T, fx *consoleFixture, label, platform, channel, rel str |
| } |
| } |
| |
| +// seedFlatBox is seedBox reporting a flat instance layout, so the layout |
| +// downgrade gate (layoutguard.go) lets a named old release through. |
| +func seedFlatBox(t *testing.T, fx *consoleFixture, label, platform, channel, rel string) { |
| + t.Helper() |
| + b := status.CollectBox(nil, status.Probes{Release: rel, Platform: platform, SystemChannel: channel, Layout: &status.LayoutReport{Mode: "flat"}}, time.Now()) |
| + b.Label = label |
| + if err := status.WriteBox(context.Background(), fx.rel, b); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| func TestSystemDoorsAreForOpsOwnersOnly(t *testing.T) { |
| fx := newConsoleFixture(t) |
| if err := fx.st.AddMember(OpsAccountID, "member@keymail.dev", RoleMember, time.Now()); err != nil { |
| @@ -547,6 +558,10 @@ func mustGetObject(t *testing.T, fx *consoleFixture, key string) []byte { |
| // (rootfs apps Plan 3, Task 15 round 4): a named version at the door, the |
| // latest release inside the job, both before anything is reserved or |
| // written; the override goes through and is signed onto that pointer only. |
| +// latestSteerWant is the refusal of a resolved latest below the release a |
| +// channel serves (resolvedSystemLatestAllowed, hunt H6-M3). |
| +const latestSteerWant = "the feed's latest.txt names %s, below the %s that router/canary already serves; a resolved latest never moves a channel back. To step back on purpose name the release with --version, or run carlos system rollback" |
| + |
| func TestSystemDoorsRefuseBelowTheRootfsFloor(t *testing.T) { |
| fx := newConsoleFixture(t) |
| systemFeed(t, fx, map[string][]byte{"carlos-linux-arm64": []byte("ELF arm64")}) |
| @@ -584,14 +599,17 @@ func TestSystemDoorsRefuseBelowTheRootfsFloor(t *testing.T) { |
| if st != http.StatusOK { |
| t.Fatalf("update to the latest = %d %v", st, out) |
| } |
| - if job := waitJob(t, fx, owner, str(t, out, "job")); job["error"] != fmt.Sprintf(want, "v0.18.0") { |
| + // A resolved latest below the release the channel serves is refused |
| + // whatever the overrides say (hunt H6-M3): latest.txt is unsigned. A |
| + // step back is named with --version, below. |
| + if job := waitJob(t, fx, owner, str(t, out, "job")); job["error"] != fmt.Sprintf(latestSteerWant, "v0.18.0", "v0.29.0") { |
| t.Fatalf("the latest (v0.18.0) job = %v", job) |
| } |
| if p := pointer(); p.Current.Version != "v0.29.0" { |
| t.Fatalf("a refused promotion moved the pointer to %s", p.Current.Version) |
| } |
| |
| - st, out = postJSON(t, fx.ts.URL+"/api/cli/system/update", map[string]any{"channel": "canary", "spread": "0s", "allow_below_rootfs_floor": true}, owner) |
| + st, out = postJSON(t, fx.ts.URL+"/api/cli/system/update", map[string]any{"channel": "canary", "version": "v0.18.0", "spread": "0s", "allow_below_rootfs_floor": true}, owner) |
| if st != http.StatusOK { |
| t.Fatalf("update with the override = %d %v", st, out) |
| } |
| @@ -666,14 +684,19 @@ func TestSystemDoorsRefuseBelowTheRegionalFloor(t *testing.T) { |
| if st != http.StatusOK { |
| t.Fatalf("update to the latest = %d %v", st, out) |
| } |
| - if job := waitJob(t, fx, owner, str(t, out, "job")); job["error"] != fmt.Sprintf(want, "v0.18.0") { |
| + // A resolved latest below the release the channel serves is refused |
| + // whatever the overrides say (hunt H6-M3): latest.txt is unsigned. A |
| + // step back is named with --version, below. |
| + if job := waitJob(t, fx, owner, str(t, out, "job")); job["error"] != fmt.Sprintf(latestSteerWant, "v0.18.0", "v0.31.0") { |
| t.Fatalf("the latest (v0.18.0) job = %v", job) |
| } |
| if p := pointer(); p.Current.Version != "v0.31.0" { |
| t.Fatalf("a refused promotion moved the pointer to %s", p.Current.Version) |
| } |
| |
| - st, out = postJSON(t, fx.ts.URL+"/api/cli/system/update", map[string]any{"channel": "canary", "spread": "0s", "allow_below_rootfs_floor": true, "allow_below_regional_floor": true}, owner) |
| + // Named, a step back meets the layout gate too: the box reports flat. |
| + seedFlatBox(t, fx, "ie", "linux-arm64", "canary", "v0.31.0") |
| + st, out = postJSON(t, fx.ts.URL+"/api/cli/system/update", map[string]any{"channel": "canary", "version": "v0.18.0", "spread": "0s", "allow_below_rootfs_floor": true, "allow_below_regional_floor": true}, owner) |
| if st != http.StatusOK { |
| t.Fatalf("update with both overrides = %d %v", st, out) |
| } |