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.
14 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: 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. Accepts unknown so callers
pass response bodies / nested envelope fields directly without
intermediate as casts; non-object bodies skip the field-name check.
bodyunknowncontextdescription 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.
bodyunknownblocklistreadonly 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.
responseResponsebody{ 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.
route_specsRouteSpec[]methodstringpathstringresponseResponsePromise<void> Error - if no route spec matches `method` + `path`, if the responsetesting/integration_helpers.ts view source
(body: Record<string, unknown>): string[] List the fields in an error response body that are not in the known-safe set.
Error schemas use z.looseObject (intentional — multiple producers), but
test responses should be checked for fields that could leak information.
bodyRecord<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.
valueunknownSet<string> 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.
keyringsession_optionsSessionOptions<string>Promise<string> testing/integration_helpers.ts view source
(specs: RouteSpec[], suffix: "/login" | "/logout" | "/password" | "/verify" | "/signup" | "/bootstrap", method: RouteMethod): RouteSpec | undefined Find a REST auth route by suffix and method.
Decouples tests from consumer route prefix (/api/account/login,
/api/auth/login, etc.). suffix must be one of
REST_AUTH_ROUTE_SUFFIXES — throws otherwise so a post-migration RPC
method name (e.g. /sessions/revoke-all) fails loudly at the call site
instead of silently returning undefined.
specsRouteSpec[]suffix"/login" | "/logout" | "/password" | "/verify" | "/signup" | "/bootstrap"methodRouteSpec | undefined Error - if `suffix` is not in `REST_AUTH_ROUTE_SUFFIXES`.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).
specsRouteSpec[]methodstringpathrequest path (exact or with concrete param values)
stringRouteSpec | undefined testing/integration_helpers.ts view source
(spec: RouteSpec, test_app: TestApp, authed_account: TestAccount, admin_account: TestAccount): Record<string, string> Pick request headers matching a route spec's auth requirement.
Maps RouteAuth onto a test account's credentials:
- none — origin headers only
- authenticated — the authed account's session cookie
- role: admin — the admin account's session cookie
- role: <other> — the test app's bootstrapped keeper session
- keeper — the test app's daemon token
spectest_appauthed_accountadmin_accountRecord<string, string> testing/integration_helpers.ts view source
readonly ["/login", "/logout", "/password", "/verify", "/signup", "/bootstrap"] REST auth route suffixes on the account/bootstrap surface — the only routes still REST. find_auth_route rejects any other suffix at runtime; session/token CRUD, admin operations, and role_grant flows live on the RPC surface and should be reached via rpc_call.
testing/integration_helpers.ts view source
"/login" | "/logout" | "/password" | "/verify" | "/signup" | "/bootstrap" testing/integration_helpers.ts view source
readonly string[] Field names that must never appear in any HTTP response body.