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

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

opened this in answer to

Merged 27h 20m ago, live in production

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

  • Merged. scout/17869-full-suite-red-test-security-floor-route was merged into main as 27f5834.

Review

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

repoPages() builds the whole router on every call and is called twice per half. Compute the list once (a const next to it) and slice that; the same goes for otherPages().

257261 function otherPages(): string[] {
258262 return getPatternsFrom(buildRouter).filter((p) => !p.startsWith("/:owner/:name"));
259263 }
@@ -303,7 +307,8 @@ const FLOOR = ["content-security-policy", "x-content-type-options", "referrer-po
303307
304308 /** Each part's GET paths, and an unknown path that part's router answers. */
305309 const UNKNOWN: Record<Part, string> = {
306 "repository pages": "/ada/notes/no/such/page",
310 "repository pages, first half": "/ada/notes/no/such/page",
311 "repository pages, second half": "/ada/notes/no/such/page",
307312 "other pages, first half": "/no/such/path/at/all",
308313 "other pages, second half": "/no/such/path/at/all",
309314 "API": "/api/v1/no-such-route",
@@ -324,7 +329,7 @@ for (const part of PART_NAMES) {
324329 }, 9_000);
325330 }
326331
327 test("the four parts together walk every GET pattern, each a real share of it", () => {
332 test("the five parts together walk every GET pattern, each a real share of it", () => {
328333 const walked = new Set(PART_NAMES.flatMap((part) => PARTS[part]()));
329334 expect(getPatterns().filter((p) => !walked.has(p))).toEqual([]);
330335 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