Skip to content

Commit 4f0d0cd

Browse files
committed
[red] Guard public beta staging and activation
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent d701eab commit 4f0d0cd

3 files changed

Lines changed: 94 additions & 1 deletion

File tree

‎tools/web/src/test/build-contract.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,15 @@ describe("production build contract", () => {
251251
/https?:\/\/(?:unpkg\.com|cdn\.jsdelivr\.net|esm\.sh)/i,
252252
);
253253
});
254+
255+
it("gives an active public beta truthful page-level context", async () => {
256+
const page = await readFile(
257+
join(process.cwd(), "src", "app", "flash", "page.tsx"),
258+
"utf8",
259+
);
260+
261+
expect(page).toContain('release?.deployment === "public-beta"');
262+
expect(page).toMatch(/unqualified beta/i);
263+
expect(page).toMatch(/full hardware.*validation.*pending/i);
264+
});
254265
});

‎tools/web/src/test/firmware-staging.test.ts‎

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ import { promisify } from "node:util";
1919

2020
import { afterEach, describe, expect, it } from "vitest";
2121

22-
import { stageFirmwareRelease } from "../../scripts/stage-firmware-release";
22+
import {
23+
stageFirmwareRelease,
24+
validateAttestedPublicBetaBundle,
25+
validatePreservedPublicFirmwareRelease,
26+
} from "../../scripts/stage-firmware-release";
2327
import {
2428
bundleFiles,
2529
createFirmwareReleaseFixture,
@@ -180,6 +184,67 @@ describe("external firmware bundle staging", () => {
180184
).rejects.toThrow();
181185
});
182186

187+
it("stages an unrestricted pending public beta but rejects false beta status claims", async () => {
188+
const fixture = createFirmwareReleaseFixture({
189+
deployment: "public-beta",
190+
accessControlled: false,
191+
hilStatus: "pending",
192+
});
193+
const bundleDirectory = await temporaryDirectory("public-beta-bundle");
194+
await writeExternalBundle(bundleDirectory, fixture);
195+
196+
const stagedRoot = await temporaryDirectory("public-beta-staged");
197+
await expect(
198+
stageFixture({
199+
accessControlled: false,
200+
bundleDirectory,
201+
deployment: "public-beta",
202+
outputDirectory: stagedRoot,
203+
}),
204+
).resolves.toMatchObject({
205+
accessControlled: false,
206+
deployment: "public-beta",
207+
hilStatus: "pending",
208+
version: "0.4.1",
209+
});
210+
await expect(
211+
validatePreservedPublicFirmwareRelease(stagedRoot, {
212+
releaseValidator: acceptSyntheticFixture,
213+
}),
214+
).resolves.toMatchObject({ deployment: "public-beta" });
215+
216+
await expect(
217+
stageFixture({
218+
accessControlled: true,
219+
bundleDirectory,
220+
deployment: "public-beta",
221+
outputDirectory: await temporaryDirectory("controlled-public-beta"),
222+
}),
223+
).rejects.toThrow(/public beta/i);
224+
await expect(
225+
stageFixture({
226+
accessControlled: false,
227+
bundleDirectory,
228+
deployment: "public",
229+
outputDirectory: await temporaryDirectory("qualified-pending-beta"),
230+
}),
231+
).rejects.toThrow();
232+
});
233+
234+
it("production beta validation rejects a self-consistent bundle with an unattested release root", async () => {
235+
const fixture = createFirmwareReleaseFixture({
236+
deployment: "public-beta",
237+
accessControlled: false,
238+
hilStatus: "pending",
239+
});
240+
const bundleDirectory = await temporaryDirectory("unattested-beta");
241+
await writeExternalBundle(bundleDirectory, fixture);
242+
243+
await expect(
244+
validateAttestedPublicBetaBundle(bundleDirectory, "public-beta"),
245+
).rejects.toThrow(/attested.*v0\.4\.1/i);
246+
});
247+
183248
it("rejects external bytes that no longer match the generated bundle checksums", async () => {
184249
const fixture = createFirmwareReleaseFixture();
185250
const bundleDirectory = await temporaryDirectory("corrupt-bundle");

‎tools/web/src/test/vps-deployment-contract.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,23 @@ describe("Cloudflare-fronted VPS deployment", () => {
153153
expect(script).not.toMatch(/BEGIN (?:RSA |OPENSSH )?PRIVATE KEY/);
154154
});
155155

156+
it("accepts only the exact unrestricted pending public beta in the activation path", async () => {
157+
const script = await readFile(
158+
join(deploymentRoot, "vps", "deploy.sh"),
159+
"utf8",
160+
);
161+
162+
expect(script).toContain('descriptor.deployment === "public-beta"');
163+
expect(script).toContain('descriptor.hilStatus === "pending"');
164+
expect(script).toContain("descriptor.accessControlled === false");
165+
expect(script).toContain(
166+
"8b84fbb65a0463d20369e1d86dac566ca7a2039ebc30f9186f55c05421962445",
167+
);
168+
expect(script).toMatch(
169+
/public-beta[\s\S]*?(?:skip|does not require)[\s\S]*?annotated tag/i,
170+
);
171+
});
172+
156173
it("retains deployment-evidence cleanup after installing the smoke-test EXIT trap", async () => {
157174
const script = await readFile(
158175
join(deploymentRoot, "vps", "deploy.sh"),

0 commit comments

Comments
 (0)