testing/integration_helpers.ts view source
readonly string[] Field names that must not appear in non-admin HTTP response bodies.
Integration test helpers — route lookup, response validation, and cookie utilities.
11 declarations
testing/integration_helpers.ts view source
readonly string[] Field names that must not appear in non-admin HTTP response bodies.
testing/integration_helpers.ts view source
(body: Record<string, unknown>, context: string): void Assert that an error response contains no leaky field values.
Checks both field names and string values for patterns indicating stack traces, SQL, or internal paths.
bodyparsed error response JSON
Record<string, unknown>contextdescription for error messages
stringvoid testing/integration_helpers.ts view source
(body: unknown, blocklist: readonly string[], context: string): void Assert that a parsed JSON body contains no fields from the given blocklist.
bodyparsed response JSON
unknownblocklistfield names to check for
readonly string[]contextdescription for error messages
stringvoid testing/integration_helpers.ts view source
(response: Response, body: { retry_after: number; }): void Assert that a 429 response includes a valid Retry-After header
matching the JSON body's retry_after field.
responsethe 429 response
Responsebodyparsed JSON body with retry_after field
{ retry_after: number; }void testing/integration_helpers.ts view source
(route_specs: RouteSpec[], method: string, path: string, response: Response): Promise<void> Validate a response body against the route spec's declared schemas.
For 2xx responses, validates against spec.output.
For error responses, validates against the merged error schema for that status code.
Throws with details on mismatch.
route_specsroute specs for schema lookup
RouteSpec[]methodHTTP method of the request
stringpathpath of the request
stringresponsethe Response to validate
ResponsePromise<void> testing/integration_helpers.ts view source
(body: Record<string, unknown>): string[] Assert that an error response body contains no unexpected fields.
Error schemas use z.looseObject (intentional — multiple producers), but
test responses should be checked for fields that could leak information.
Flags any field not in the known-safe set.
bodyparsed error response JSON
Record<string, unknown>string[] array of unexpected field names (empty = clean)
testing/integration_helpers.ts view source
(value: unknown): Set<string> Recursively collect all key names from a parsed JSON value.
Walks objects and arrays to find every property name at any nesting depth.
valueparsed JSON value
unknownSet<string> set of all key names found
testing/integration_helpers.ts view source
(keyring: Keyring, session_options: SessionOptions<string>): Promise<string> Create an expired test cookie — validly signed but with an expiry timestamp in 1970.
keyringkeyring for signing
session_optionssession config
SessionOptions<string>Promise<string> signed cookie value with long-past expiry
testing/integration_helpers.ts view source
(specs: RouteSpec[], suffix: string, method: RouteMethod): RouteSpec | undefined Find an auth route by suffix and method.
Useful for discovering login/logout/verify/revoke paths regardless
of consumer prefix (/api/account/login, /api/auth/login, etc.).
specsroute specs to search
RouteSpec[]suffixpath suffix to match (e.g. '/login')
stringmethodHTTP method
RouteSpec | undefined matching route spec, or undefined
testing/integration_helpers.ts view source
(specs: RouteSpec[], method: string, path: string): RouteSpec | undefined Find a route spec matching the given method and path.
Supports both exact matches and parameterized paths (:param segments).
specsroute specs to search
RouteSpec[]methodHTTP method
stringpathrequest path (exact or with concrete param values)
stringRouteSpec | undefined matching route spec, or undefined
testing/integration_helpers.ts view source
readonly string[] Field names that must never appear in any HTTP response body.