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

Full suite red: test/security-floor-routes.test.ts #17443

opened this in answer to

Merged 33h 59m ago, live in production

scout/forge:scout/17442-full-suite-red-test-security-floor-route → main 0 commits fork 1 thread · 1 unresolved

  • Merged. scout/17442-full-suite-red-test-security-floor-route was merged into main as a5d060f.

Review

Sign in to review this change.
1 file changed +10 −5
test/security-floor-routes.test.ts +10 −5
@@ -243,15 +243,19 @@ const paramsOf = (pattern: string): string[] =>
243243 [...pattern.matchAll(/[:*]([a-z_]+)/g)].map((m) => m[1]!);
244244
245245 /**
246 * The GET table in three parts, each walked by its own tests so none runs the
246 * The GET table in four parts, each walked by its own tests so none runs the
247247 * whole table under the 2 s test budget: a repository's pages, the rest of the
248 * pages, and the API. Together they are every GET pattern (checked below).
248 * pages in two halves, and the API. Together they are every GET pattern (checked below).
249249 */
250250 const PARTS = {
251251 "repository pages": () => getPatternsFrom(buildRouter).filter((p) => p.startsWith("/:owner/:name")),
252 "other pages": () => getPatternsFrom(buildRouter).filter((p) => !p.startsWith("/:owner/:name")),
252 "other pages, first half": () => otherPages().slice(0, Math.ceil(otherPages().length / 2)),
253 "other pages, second half": () => otherPages().slice(Math.ceil(otherPages().length / 2)),
253254 "API": () => getPatternsFrom(buildApiRouter),
254255 } as const;

Each half rebuilds the router and re-filters on every call, and otherPages() runs twice per half. Compute it once and slice the result. A fixed halving also means the next group of routes will push one half back toward the 2 s budget, so consider chunking by a count.

256 function otherPages(): string[] {
257 return getPatternsFrom(buildRouter).filter((p) => !p.startsWith("/:owner/:name"));
258 }
255259 type Part = keyof typeof PARTS;
256260 const PART_NAMES = Object.keys(PARTS) as Part[];
257261
@@ -299,7 +303,8 @@ const FLOOR = ["content-security-policy", "x-content-type-options", "referrer-po
299303 /** Each part's GET paths, and an unknown path that part's router answers. */
300304 const UNKNOWN: Record<Part, string> = {
301305 "repository pages": "/ada/notes/no/such/page",
302 "other pages": "/no/such/path/at/all",
306 "other pages, first half": "/no/such/path/at/all",
307 "other pages, second half": "/no/such/path/at/all",
303308 "API": "/api/v1/no-such-route",
304309 };
305310 const pathsOf = (part: Part): string[] => [...new Set(PARTS[part]())].map(pathFor).concat(UNKNOWN[part]);
@@ -318,7 +323,7 @@ for (const part of PART_NAMES) {
318323 }, 9_000);
319324 }
320325
321 test("the three parts together walk every GET pattern, each a real share of it", () => {
326 test("the four parts together walk every GET pattern, each a real share of it", () => {
322327 const walked = new Set(PART_NAMES.flatMap((part) => PARTS[part]()));
323328 expect(getPatterns().filter((p) => !walked.has(p))).toEqual([]);
324329 for (const part of PART_NAMES) expect(`${part} ${PARTS[part]().length > 50}`).toBe(`${part} true`);

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs