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

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

opened this in answer to

Merged 11h 10m ago, live in production

torque/forge:torque/18231-full-suite-red-test-security-floor-route → main 0 commits fork

  • Merged. torque/18231-full-suite-red-test-security-floor-route was merged into main as ecc8b8c.

Review

Sign in to review this change.
1 file changed +16 −9
test/security-floor-routes.test.ts +16 −9
@@ -256,17 +256,22 @@ const paramsOf = (pattern: string): string[] =>
256256 [...pattern.matchAll(/[:*]([a-z_]+)/g)].map((m) => m[1]!);
257257
258258 /**
259 * The GET table in five parts, each walked by its own tests so none runs the
260 * whole table under the 2 s test budget: a repository's pages in two halves, the rest of the
261 * pages in two halves, and the API. Together they are every GET pattern (checked below).
259 * The GET table in seven parts, each walked by its own tests so none runs the
260 * whole table under the 2 s test budget: a repository's pages in four quarters (the first half
261 * alone took 2.48 s of CPU, #18231), the rest of the pages in two halves, and the API. Together
262 * they are every GET pattern (checked below).
262263 */
263264 const PARTS = {
264 "repository pages, first half": () => repoPages().slice(0, Math.ceil(repoPages().length / 2)),
265 "repository pages, second half": () => repoPages().slice(Math.ceil(repoPages().length / 2)),
265 "repository pages, first quarter": () => quarter(repoPages(), 0),
266 "repository pages, second quarter": () => quarter(repoPages(), 1),
267 "repository pages, third quarter": () => quarter(repoPages(), 2),
268 "repository pages, last quarter": () => quarter(repoPages(), 3),
266269 "other pages, first half": () => otherPages().slice(0, Math.ceil(otherPages().length / 2)),
267270 "other pages, second half": () => otherPages().slice(Math.ceil(otherPages().length / 2)),
268271 "API": () => getPatternsFrom(buildApiRouter),
269272 } as const;
273 /** The `i`th of four near-equal slices of a list. */
274 const quarter = (all: string[], i: number): string[] => all.slice(Math.ceil((all.length * i) / 4), Math.ceil((all.length * (i + 1)) / 4));
270275 function repoPages(): string[] {
271276 return getPatternsFrom(buildRouter).filter((p) => p.startsWith("/:owner/:name"));
272277 }
@@ -319,8 +324,10 @@ const FLOOR = ["content-security-policy", "x-content-type-options", "referrer-po
319324
320325 /** Each part's GET paths, and an unknown path that part's router answers. */
321326 const UNKNOWN: Record<Part, string> = {
322 "repository pages, first half": "/ada/notes/no/such/page",
323 "repository pages, second half": "/ada/notes/no/such/page",
327 "repository pages, first quarter": "/ada/notes/no/such/page",
328 "repository pages, second quarter": "/ada/notes/no/such/page",
329 "repository pages, third quarter": "/ada/notes/no/such/page",
330 "repository pages, last quarter": "/ada/notes/no/such/page",
324331 "other pages, first half": "/no/such/path/at/all",
325332 "other pages, second half": "/no/such/path/at/all",
326333 "API": "/api/v1/no-such-route",
@@ -341,10 +348,10 @@ for (const part of PART_NAMES) {
341348 }, 9_000);
342349 }
343350
344 test("the five parts together walk every GET pattern, each a real share of it", () => {
351 test("the parts together walk every GET pattern, each a real share of it", () => {
345352 const walked = new Set(PART_NAMES.flatMap((part) => PARTS[part]()));
346353 expect(getPatterns().filter((p) => !walked.has(p))).toEqual([]);
347 for (const part of PART_NAMES) expect(`${part} ${PARTS[part]().length > 50}`).toBe(`${part} true`);
354 for (const part of PART_NAMES) expect(`${part} ${PARTS[part]().length > 25}`).toBe(`${part} true`);
348355 });
349356
350357 test("the patterns the seed cannot fill are exactly the ones named, each with a reason", () => {

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

Keyboard shortcuts

Docs