Public: anyone can read this; the crew can change it.

Full suite red: test/security-sweep.test.ts #15313

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/15298-full-suite-red-test-security-sweep-test → main 0 commits fork

  • Merged. mason/15298-full-suite-red-test-security-sweep-test was merged into main as 6168046.

Review

Sign in to review this change.
1 file changed +10 −4
test/security-sweep.test.ts +10 −4
@@ -54,6 +54,12 @@ const USERNAME = "ada";
5454 const PASSWORD = "correct-horse-battery";
5555 const EVIL = "https://evil.example";
5656 const FLOOR = ["content-security-policy", "x-content-type-options", "referrer-policy"] as const;
57 /**
58 * A ceiling for a sweep, not a measure: the work is bounded by the route
59 * table, and the default 6 s test limit reddened the full suite when four
60 * files shared the machine (#15298). It only stops a hung server.
61 */
62 const SWEEP_LIMIT = 120_000;
5763 const MUTATING = new Set(["POST", "PUT", "PATCH", "DELETE"]);
5864
5965 /**
@@ -144,7 +150,7 @@ async function send(method: string, path: string, headers: Record<string, string
144150 headers: { "accept-encoding": "identity", ...headers },
145151 body,
146152 redirect: "manual",
147 signal: AbortSignal.timeout(5_000),
153 signal: AbortSignal.timeout(60_000),
148154 });
149155 await res.body?.cancel().catch(() => {});
150156 return {
@@ -204,7 +210,7 @@ test("every registered route and verb, asked anonymously, answers with the floor
204210 expect(statuses).toContain(404);
205211 expect(statuses.some((s) => s >= 400 && s < 500 && s !== 404)).toBe(true);
206212 expect(anonymous.some((s) => s.type.startsWith("text/event-stream"))).toBe(true);
207 });
213 }, SWEEP_LIMIT);
208214
209215 test("an API path asked with a verb it does not take answers 405, naming the ones it does, with the floor", async () => {
210216 const api = buildApiRouter();
@@ -231,7 +237,7 @@ test("an API path asked with a verb it does not take answers 405, naming the one
231237 .map(({ s }) => `${s.label} allow=${s.allow}`);
232238 expect(wrongAnswers).toEqual([]);
233239 expect(wrongMethod.at(-1)!.status).toBe(405); // the home page takes GET, so a PATCH is a wrong method, not a miss
234 });
240 }, SWEEP_LIMIT);
235241
236242 test("a cross-origin mutation with a session cookie is refused before any handler, and the session lives on", async () => {
237243 const mutations = routes().filter((r) => MUTATING.has(r.method));
@@ -243,7 +249,7 @@ test("a cross-origin mutation with a session cookie is refused before any handle
243249 expect(seen.filter((s) => s.cookies.length > 0).map((s) => `${s.label} sets ${s.cookies.map(cookieName).join(", ")}`)).toEqual([]);
244250 const still = sessionOf(app.db, token);
245251 expect(still.ok && still.value.user.username).toBe(USERNAME);
246 });
252 }, SWEEP_LIMIT);
247253
248254 test("signing in from the forge's own page sets the session cookie HttpOnly, with the floor", async () => {
249255 const form = await send(

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs