Public: anyone can read this; the crew can change it.
Full suite red: test/security-floor-routes.test.ts #17870
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
1 file
changed +10
−5
test/security-floor-routes.test.ts +10 −5
| @@ -244,16 +244,20 @@ const paramsOf = (pattern: string): string[] => | ||
| 244 | 244 | [...pattern.matchAll(/[:*]([a-z_]+)/g)].map((m) => m[1]!); |
| 245 | 245 | |
| 246 | 246 | /** |
| 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 | |
| 249 | 249 | * pages in two halves, and the API. Together they are every GET pattern (checked below). |
| 250 | 250 | */ |
| 251 | 251 | 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)), | |
| 253 | 254 | "other pages, first half": () => otherPages().slice(0, Math.ceil(otherPages().length / 2)), |
| 254 | 255 | "other pages, second half": () => otherPages().slice(Math.ceil(otherPages().length / 2)), |
| 255 | 256 | "API": () => getPatternsFrom(buildApiRouter), |
| 256 | 257 | } as const; |
| 258 | function repoPages(): string[] { | |
| 259 | return getPatternsFrom(buildRouter).filter((p) => p.startsWith("/:owner/:name")); | |
| 260 | } | |
| 257 | 261 | function otherPages(): string[] { |
| 258 | 262 | return getPatternsFrom(buildRouter).filter((p) => !p.startsWith("/:owner/:name")); |
| 259 | 263 | } |
| @@ -303,7 +307,8 @@ const FLOOR = ["content-security-policy", "x-content-type-options", "referrer-po | ||
| 303 | 307 | |
| 304 | 308 | /** Each part's GET paths, and an unknown path that part's router answers. */ |
| 305 | 309 | 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", | |
| 307 | 312 | "other pages, first half": "/no/such/path/at/all", |
| 308 | 313 | "other pages, second half": "/no/such/path/at/all", |
| 309 | 314 | "API": "/api/v1/no-such-route", |
| @@ -324,7 +329,7 @@ for (const part of PART_NAMES) { | ||
| 324 | 329 | }, 9_000); |
| 325 | 330 | } |
| 326 | 331 | |
| 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", () => { | |
| 328 | 333 | const walked = new Set(PART_NAMES.flatMap((part) => PARTS[part]())); |
| 329 | 334 | expect(getPatterns().filter((p) => !walked.has(p))).toEqual([]); |
| 330 | 335 | for (const part of PART_NAMES) expect(`${part} ${PARTS[part]().length > 50}`).toBe(`${part} true`); |
new above
offline
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().