Skip to content

Commit c41bc48

Browse files
committed
[red] Reject cacheable firmware error responses
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent 7c3777c commit c41bc48

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ describe("Cloudflare-fronted VPS deployment", () => {
8989
expect(headers).toContain("Strict-Transport-Security");
9090
});
9191

92+
it("keeps firmware 404 responses non-cacheable through the shared error page", async () => {
93+
const config = await readFile(
94+
join(deploymentRoot, "nginx", "10-pyble-dev-https.conf"),
95+
"utf8",
96+
);
97+
98+
expect(config).toMatch(
99+
/map \$request_uri \$pyble_not_found_cache_control\s*\{[\s\S]*?~\^\/firmware\/ "no-store";[\s\S]*?default "no-cache, no-transform";[\s\S]*?\}/,
100+
);
101+
expect(config).toMatch(
102+
/location = \/404\.html\s*\{[\s\S]*?add_header Cache-Control \$pyble_not_found_cache_control always;/,
103+
);
104+
});
105+
92106
it("routes the exact v0.4.2 public beta through the immutable firmware boundary", async () => {
93107
const config = await readFile(
94108
join(deploymentRoot, "nginx", "10-pyble-dev-https.conf"),
@@ -416,6 +430,27 @@ describe("Cloudflare-fronted VPS deployment", () => {
416430
);
417431
});
418432

433+
it("requires missing firmware and deferred C3 smoke responses to be 404 no-store", async () => {
434+
const script = await readFile(
435+
join(deploymentRoot, "vps", "deploy.sh"),
436+
"utf8",
437+
);
438+
const smokeStart = script.indexOf("firmware_not_found_paths=(");
439+
const smokeEnd = script.indexOf("confirm_activation", smokeStart);
440+
const firmwareNotFoundSmoke = script.slice(smokeStart, smokeEnd);
441+
442+
expect(smokeStart).toBeGreaterThan(-1);
443+
expect(smokeEnd).toBeGreaterThan(smokeStart);
444+
expect(firmwareNotFoundSmoke).toContain("/firmware/not-found-smoke");
445+
expect(firmwareNotFoundSmoke).toContain("esp32-c3-4mb/manifest.json");
446+
expect(firmwareNotFoundSmoke).toContain("--dump-header");
447+
expect(firmwareNotFoundSmoke).toContain("--write-out '%{http_code}'");
448+
expect(firmwareNotFoundSmoke).toMatch(
449+
/firmware_not_found_status[\s\S]*?!= 404/,
450+
);
451+
expect(firmwareNotFoundSmoke).toContain("Cache-Control: *no-store");
452+
});
453+
419454
it("freezes one clean full source commit through the completed website build", async () => {
420455
const script = await readFile(
421456
join(deploymentRoot, "vps", "deploy.sh"),

0 commit comments

Comments
 (0)