testing/integration_helpers.ts view source
readonly string[] import {admin_only_field_blocklist} from '@fuzdev/fuz_app/testing/integration_helpers.js'; Field names that must not appear in non-admin HTTP response bodies.
Integration test helpers — route lookup, response validation, and cookie utilities.
15 declarations
testing/integration_helpers.ts view source
readonly string[] import {admin_only_field_blocklist} from '@fuzdev/fuz_app/testing/integration_helpers.js'; Field names that must not appear in non-admin HTTP response bodies.
testing/integration_helpers.ts view source
(body: unknown, context: string): void import {assert_no_error_info_leakage} from '@fuzdev/fuz_app/testing/integration_helpers.js'; 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 import {assert_no_sensitive_fields_in_json} from '@fuzdev/fuz_app/testing/integration_helpers.js'; 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 import {assert_rate_limit_retry_after_header} from '@fuzdev/fuz_app/testing/integration_helpers.js'; 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> import {assert_response_matches_spec} from '@fuzdev/fuz_app/testing/integration_helpers.js'; 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[] import {check_error_response_fields} from '@fuzdev/fuz_app/testing/integration_helpers.js'; 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> import {collect_json_keys_recursive} from '@fuzdev/fuz_app/testing/integration_helpers.js'; 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> import {create_expired_test_cookie} from '@fuzdev/fuz_app/testing/integration_helpers.js'; 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: "/bootstrap" | "/login" | "/logout" | "/password" | "/verify" | "/signup", method: RouteMethod): RouteSpec | undefined import {find_auth_route} from '@fuzdev/fuz_app/testing/integration_helpers.js'; 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 an RPC-only method
path (e.g. /sessions/revoke-all) fails loudly at the call site
instead of silently returning undefined.
specsRouteSpec[]suffix"/bootstrap" | "/login" | "/logout" | "/password" | "/verify" | "/signup"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 import {find_route_spec} from '@fuzdev/fuz_app/testing/integration_helpers.js'; 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
KeeperHeaderProvider import type {KeeperHeaderProvider} from '@fuzdev/fuz_app/testing/integration_helpers.js'; Header-builder triple shared by TestApp (in-process) and TestFixture (cross-backend fixture protocol). Both satisfy this shape structurally — pick_auth_headers accepts either without a cast.
create_session_headerstype (extra?: Record<string, string>) => Record<string, string>
create_bearer_headerstype (extra?: Record<string, string>) => Record<string, string>
create_daemon_token_headerstype (extra?: Record<string, string>) => Record<string, string>
testing/integration_helpers.ts view source
(spec: RouteSpec, keeper: KeeperHeaderProvider, authed_account: TestAccount, admin_account: TestAccount): Record<...> import {pick_auth_headers} from '@fuzdev/fuz_app/testing/integration_helpers.js'; Pick request headers matching a route spec's auth requirement.
Maps RouteAuth onto a test account's credentials:
none — origin headers onlyauthenticated — the authed account's session cookierole: admin — the admin account's session cookierole: <other> — the keeper provider's sessionkeeper — the keeper provider's daemon tokenspeckeeperauthed_accountadmin_accountRecord<string, string> testing/integration_helpers.ts view source
readonly ["/login", "/logout", "/password", "/verify", "/signup", "/bootstrap"] import {rest_auth_route_suffixes} from '@fuzdev/fuz_app/testing/integration_helpers.js'; 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
"/bootstrap" | "/login" | "/logout" | "/password" | "/verify" | "/signup" import type {RestAuthRouteSuffix} from '@fuzdev/fuz_app/testing/integration_helpers.js'; testing/integration_helpers.ts view source
readonly string[] import {sensitive_field_blocklist} from '@fuzdev/fuz_app/testing/integration_helpers.js'; Field names that must never appear in any HTTP response body.