Public: anyone can read this; the crew can change it.
Full suite red: test/security-floor-routes.test.ts #17443
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
1 file
changed +10
−5
test/security-floor-routes.test.ts +10 −5
| @@ -243,15 +243,19 @@ const paramsOf = (pattern: string): string[] => | ||
| 243 | 243 | [...pattern.matchAll(/[:*]([a-z_]+)/g)].map((m) => m[1]!); |
| 244 | 244 | |
| 245 | 245 | /** |
| 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 | |
| 247 | 247 | * 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). | |
| 249 | 249 | */ |
| 250 | 250 | const PARTS = { |
| 251 | 251 | "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)), | |
| 253 | 254 | "API": () => getPatternsFrom(buildApiRouter), |
| 254 | 255 | } as const; |
| 256 | function otherPages(): string[] { | |
| 257 | return getPatternsFrom(buildRouter).filter((p) => !p.startsWith("/:owner/:name")); | |
| 258 | } | |
| 255 | 259 | type Part = keyof typeof PARTS; |
| 256 | 260 | const PART_NAMES = Object.keys(PARTS) as Part[]; |
| 257 | 261 | |
| @@ -299,7 +303,8 @@ const FLOOR = ["content-security-policy", "x-content-type-options", "referrer-po | ||
| 299 | 303 | /** Each part's GET paths, and an unknown path that part's router answers. */ |
| 300 | 304 | const UNKNOWN: Record<Part, string> = { |
| 301 | 305 | "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", | |
| 303 | 308 | "API": "/api/v1/no-such-route", |
| 304 | 309 | }; |
| 305 | 310 | const pathsOf = (part: Part): string[] => [...new Set(PARTS[part]())].map(pathFor).concat(UNKNOWN[part]); |
| @@ -318,7 +323,7 @@ for (const part of PART_NAMES) { | ||
| 318 | 323 | }, 9_000); |
| 319 | 324 | } |
| 320 | 325 | |
| 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", () => { | |
| 322 | 327 | const walked = new Set(PART_NAMES.flatMap((part) => PARTS[part]())); |
| 323 | 328 | expect(getPatterns().filter((p) => !walked.has(p))).toEqual([]); |
| 324 | 329 | for (const part of PART_NAMES) expect(`${part} ${PARTS[part]().length > 50}`).toBe(`${part} true`); |
new above
offline
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.