@fuzdev/fuz_app 0.184.0 → 0.186.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +18 -3
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +36 -5
- package/dist/actions/register_action_ws.d.ts +14 -7
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.d.ts +17 -4
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +41 -7
- package/dist/auth/CLAUDE.md +18 -9
- package/dist/auth/account_queries.d.ts +53 -40
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +57 -50
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +59 -25
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +26 -9
- package/dist/auth/audit_emitter.js +2 -2
- package/dist/auth/audit_log_queries.d.ts +11 -3
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +4 -4
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +3 -2
- package/dist/auth/audit_log_schema.js +1 -1
- package/dist/auth/auth_ddl.d.ts.map +1 -1
- package/dist/auth/auth_ddl.js +4 -0
- package/dist/auth/cleanup.d.ts +34 -3
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +12 -4
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +35 -0
- package/dist/auth/role_grant_offer_queries.d.ts +13 -13
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +12 -13
- package/dist/auth/role_grant_queries.d.ts +16 -9
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +16 -9
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +15 -0
- package/dist/auth/session_queries.d.ts +24 -0
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +28 -0
- package/dist/db/CLAUDE.md +3 -3
- package/dist/db/cell_ddl.d.ts +8 -3
- package/dist/db/cell_ddl.d.ts.map +1 -1
- package/dist/db/cell_ddl.js +10 -5
- package/dist/http/CLAUDE.md +1 -1
- package/dist/http/body_limit.d.ts +4 -4
- package/dist/http/body_limit.js +4 -4
- package/dist/http/pending_effects.d.ts +8 -4
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/route_spec.d.ts +3 -3
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/realtime/audit_log_sse.d.ts +1 -1
- package/dist/realtime/sse.d.ts +2 -2
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse_constants.d.ts +1 -1
- package/dist/realtime/sse_constants.js +1 -1
- package/dist/server/app_server.d.ts +59 -71
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +52 -60
- package/dist/server/shutdown_drain.d.ts +69 -0
- package/dist/server/shutdown_drain.d.ts.map +1 -0
- package/dist/server/shutdown_drain.js +77 -0
- package/dist/testing/CLAUDE.md +197 -66
- package/dist/testing/admin_integration.d.ts +2 -2
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +36 -20
- package/dist/testing/app_server.d.ts +5 -7
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +5 -7
- package/dist/testing/auth_apps.d.ts +3 -1
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +22 -5
- package/dist/testing/cross_backend/backend_config.d.ts +8 -0
- package/dist/testing/cross_backend/backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/backend_log.d.ts +71 -0
- package/dist/testing/cross_backend/backend_log.d.ts.map +1 -0
- package/dist/testing/cross_backend/backend_log.js +134 -0
- package/dist/testing/cross_backend/backend_swap.d.ts +41 -0
- package/dist/testing/cross_backend/backend_swap.d.ts.map +1 -0
- package/dist/testing/cross_backend/backend_swap.js +431 -0
- package/dist/testing/cross_backend/body_size_smuggling.js +3 -3
- package/dist/testing/cross_backend/bootstrap_backend.d.ts +3 -1
- package/dist/testing/cross_backend/bootstrap_backend.d.ts.map +1 -1
- package/dist/testing/cross_backend/bootstrap_backend.js +9 -5
- package/dist/testing/cross_backend/conformance_case.d.ts +11 -6
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_case.js +4 -0
- package/dist/testing/cross_backend/conformance_principal.d.ts +2 -2
- package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_principal.js +27 -10
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +10 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +33 -7
- package/dist/testing/cross_backend/default_backend_configs.d.ts +38 -5
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +50 -15
- package/dist/testing/cross_backend/in_process_setup.d.ts +1 -1
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +53 -31
- package/dist/testing/cross_backend/revocation_drivers.d.ts +14 -2
- package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
- package/dist/testing/cross_backend/revocation_drivers.js +36 -8
- package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
- package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +7 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -2
- package/dist/testing/cross_backend/setup.d.ts +44 -43
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +64 -62
- package/dist/testing/cross_backend/spawn_backend.d.ts +19 -1
- package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
- package/dist/testing/cross_backend/spawn_backend.js +138 -11
- package/dist/testing/cross_backend/spine_suites.d.ts +17 -14
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +37 -15
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +4 -2
- package/dist/testing/cross_backend/standard.d.ts +18 -82
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.js +6 -21
- package/dist/testing/cross_backend/standard_auth.d.ts +74 -0
- package/dist/testing/cross_backend/standard_auth.d.ts.map +1 -0
- package/dist/testing/cross_backend/standard_auth.js +28 -0
- package/dist/testing/cross_backend/standard_bundle.d.ts +48 -0
- package/dist/testing/cross_backend/standard_bundle.d.ts.map +1 -0
- package/dist/testing/cross_backend/standard_bundle.js +43 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +18 -6
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +23 -8
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_bun.js +7 -30
- package/dist/testing/cross_backend/testing_server_core.d.ts +16 -3
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +20 -4
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +6 -2
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -3
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +4 -3
- package/dist/testing/data_exposure.d.ts +4 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +93 -25
- package/dist/testing/db_invariants.d.ts +5 -5
- package/dist/testing/db_invariants.js +5 -5
- package/dist/testing/error_coverage.d.ts +5 -0
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +2 -1
- package/dist/testing/integration.d.ts +4 -20
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +49 -79
- package/dist/testing/integration_helpers.d.ts +16 -0
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +29 -1
- package/dist/testing/logged_errors.d.ts +61 -0
- package/dist/testing/logged_errors.d.ts.map +1 -0
- package/dist/testing/logged_errors.js +285 -0
- package/dist/testing/middleware_gate_probes.d.ts +55 -1
- package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
- package/dist/testing/middleware_gate_probes.js +76 -3
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +41 -16
- package/dist/testing/stubs.d.ts +5 -1
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +6 -3
- package/dist/testing/test_app.d.ts +39 -9
- package/dist/testing/test_app.d.ts.map +1 -1
- package/dist/testing/test_app.js +70 -12
- package/dist/testing/transports/fetch_transport.d.ts +10 -0
- package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
- package/dist/testing/transports/fetch_transport.js +13 -0
- package/package.json +4 -3
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
2
|
import type { RouteMethod, RouteSpec } from '../http/route_spec.js';
|
|
3
|
+
import type { AppSurfaceSpec } from '../http/surface.js';
|
|
3
4
|
import { type RouteErrorMap } from '../http/route_errors.js';
|
|
4
5
|
import { type RestErrorDef } from '../http/error_schemas.js';
|
|
5
|
-
import
|
|
6
|
+
import { ErrorCoverageCollector } from './error_coverage.js';
|
|
7
|
+
import { type RpcEndpointsSuiteOption } from './rpc_helpers.js';
|
|
8
|
+
import type { SetupTest } from './cross_backend/setup.js';
|
|
6
9
|
/** The `Origin` the origin probe sends — no allowlist names it. */
|
|
7
10
|
export declare const GATE_PROBE_FOREIGN_ORIGIN = "https://gate-probe.invalid";
|
|
8
11
|
/** The `Host` the host probe sends — neither loopback nor named by an allowed origin. */
|
|
@@ -87,4 +90,55 @@ export declare const send_middleware_gate_probe: (probe: MiddlewareGateProbe, ba
|
|
|
87
90
|
* declared refusal, or its body is off the route's map
|
|
88
91
|
*/
|
|
89
92
|
export declare const assert_middleware_gate_refusal: (probe: MiddlewareGateProbe, response: Response, collector: ErrorCoverageCollector, route_specs: Array<RouteSpec>) => Promise<void>;
|
|
93
|
+
/** Configuration for `describe_middleware_gate_tests`. */
|
|
94
|
+
export interface MiddlewareGateTestOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Per-test fixture-producing function. Read in-process only, once, for the
|
|
97
|
+
* transport every probe shares; over a socket the probes need no fixture.
|
|
98
|
+
*/
|
|
99
|
+
setup_test: SetupTest;
|
|
100
|
+
/** App surface: the counted routes and their error maps, middleware included. */
|
|
101
|
+
surface_source: AppSurfaceSpec;
|
|
102
|
+
/** The session cookie's name, to resolve factory-form `rpc_endpoints` at setup. */
|
|
103
|
+
session_cookie_name: string;
|
|
104
|
+
/** RPC endpoint specs — the endpoint's path is a counted route. */
|
|
105
|
+
rpc_endpoints: RpcEndpointsSuiteOption;
|
|
106
|
+
/**
|
|
107
|
+
* Base URL the backend is reachable at, or `null` in-process. Over a socket
|
|
108
|
+
* the probes write their heads to it (`fetch` replaces a caller's `Host` and
|
|
109
|
+
* `Content-Length`); in-process they go through the fixture's transport.
|
|
110
|
+
*/
|
|
111
|
+
base_url: string | null;
|
|
112
|
+
/**
|
|
113
|
+
* The backend's request-body cap on every counted route but the RPC
|
|
114
|
+
* endpoint, in bytes — the body-limit probe declares one byte more.
|
|
115
|
+
*
|
|
116
|
+
* @default SPINE_BODY_LIMIT_DEFAULT_BYTES
|
|
117
|
+
*/
|
|
118
|
+
max_body_bytes?: number;
|
|
119
|
+
/**
|
|
120
|
+
* The backend's request-body cap on the RPC endpoint, in bytes, when it
|
|
121
|
+
* isn't `max_body_bytes`.
|
|
122
|
+
*/
|
|
123
|
+
rpc_max_body_bytes?: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* One test per middleware gate each route the standard integration suite
|
|
127
|
+
* counts declares in its error map (`plan_middleware_gate_probes`): the origin
|
|
128
|
+
* check, the host gate, the body limit, and in-process the unreadable length.
|
|
129
|
+
* Each probe is a bodiless head with no credential that the gate refuses
|
|
130
|
+
* before auth, rate limiting or body parsing, so the probes leave no state; a
|
|
131
|
+
* gate a route's map doesn't declare (a carve-out, a backend without the
|
|
132
|
+
* layer) gets no probe. Each refusal's body is held to the route's map.
|
|
133
|
+
*
|
|
134
|
+
* Every gate refusal (`MIDDLEWARE_GATE_ERROR_CODES`) a counted route declares
|
|
135
|
+
* must have a planned probe — the unreadable length aside over a socket — or
|
|
136
|
+
* the call throws at collection, so a planner that drops a probe can't pass by
|
|
137
|
+
* registering fewer tests, whatever a run filters or excludes.
|
|
138
|
+
*
|
|
139
|
+
* @param options - the routes, the backend's socket and its caps
|
|
140
|
+
* @throws Error at setup when `options.rpc_endpoints` names no single endpoint,
|
|
141
|
+
* or a declared gate refusal has no planned probe
|
|
142
|
+
*/
|
|
143
|
+
export declare const describe_middleware_gate_tests: (options: MiddlewareGateTestOptions) => void;
|
|
90
144
|
//# sourceMappingURL=middleware_gate_probes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware_gate_probes.d.ts","sourceRoot":"","sources":["../../src/lib/testing/middleware_gate_probes.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"middleware_gate_probes.d.ts","sourceRoot":"","sources":["../../src/lib/test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;IACnE,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;OAIG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,yBAAyB,KAAG,IAwDnF,CAAC"}
|
|
@@ -23,15 +23,22 @@ import './assert_dev_env.js';
|
|
|
23
23
|
* the answer a Bun server gives when a request repeats an equal
|
|
24
24
|
* `Content-Length`, which Bun hands over joined into one value.
|
|
25
25
|
*
|
|
26
|
-
* `
|
|
27
|
-
*
|
|
26
|
+
* `describe_middleware_gate_tests` runs one per declared gate of each route
|
|
27
|
+
* the standard integration suite counts (`is_standard_integration_route`). It
|
|
28
|
+
* is a suite of its own, not a group of that one, because over a socket it
|
|
29
|
+
* writes raw heads: the suites that send only through the fixture transports
|
|
30
|
+
* stay free of a raw-socket sender.
|
|
28
31
|
*
|
|
29
32
|
* @module
|
|
30
33
|
*/
|
|
31
|
-
import { assert } from 'vitest';
|
|
34
|
+
import { assert, beforeAll, describe, test } from 'vitest';
|
|
32
35
|
import { get_route_error_map } from '../http/route_errors.js';
|
|
33
36
|
import { split_route_template } from '../http/route_error_check.js';
|
|
34
37
|
import { REST_FORBIDDEN_HOST, REST_FORBIDDEN_ORIGIN, REST_INVALID_CONTENT_LENGTH, REST_PAYLOAD_TOO_LARGE } from '../http/error_schemas.js';
|
|
38
|
+
import { ErrorCoverageCollector } from './error_coverage.js';
|
|
39
|
+
import { is_standard_integration_route, MIDDLEWARE_GATE_ERROR_CODES } from './integration_helpers.js';
|
|
40
|
+
import { require_rpc_endpoint_path, resolve_rpc_endpoints_for_setup } from './rpc_helpers.js';
|
|
41
|
+
import { check_db_invariants_after_all } from './db_invariants.js';
|
|
35
42
|
import { to_route_content_type } from './schema_generators.js';
|
|
36
43
|
import { raw_http_send_head } from './transports/raw_http.js';
|
|
37
44
|
import { SPINE_BODY_LIMIT_DEFAULT_BYTES } from './cross_backend/spine_surface_constants.js';
|
|
@@ -177,3 +184,69 @@ export const assert_middleware_gate_refusal = async (probe, response, collector,
|
|
|
177
184
|
assert.strictEqual(body?.error, probe.expected.code, `${label}: answered ${JSON.stringify(body)}`);
|
|
178
185
|
await collector.assert_and_record(route_specs, probe.method, probe.path, response);
|
|
179
186
|
};
|
|
187
|
+
/**
|
|
188
|
+
* One test per middleware gate each route the standard integration suite
|
|
189
|
+
* counts declares in its error map (`plan_middleware_gate_probes`): the origin
|
|
190
|
+
* check, the host gate, the body limit, and in-process the unreadable length.
|
|
191
|
+
* Each probe is a bodiless head with no credential that the gate refuses
|
|
192
|
+
* before auth, rate limiting or body parsing, so the probes leave no state; a
|
|
193
|
+
* gate a route's map doesn't declare (a carve-out, a backend without the
|
|
194
|
+
* layer) gets no probe. Each refusal's body is held to the route's map.
|
|
195
|
+
*
|
|
196
|
+
* Every gate refusal (`MIDDLEWARE_GATE_ERROR_CODES`) a counted route declares
|
|
197
|
+
* must have a planned probe — the unreadable length aside over a socket — or
|
|
198
|
+
* the call throws at collection, so a planner that drops a probe can't pass by
|
|
199
|
+
* registering fewer tests, whatever a run filters or excludes.
|
|
200
|
+
*
|
|
201
|
+
* @param options - the routes, the backend's socket and its caps
|
|
202
|
+
* @throws Error at setup when `options.rpc_endpoints` names no single endpoint,
|
|
203
|
+
* or a declared gate refusal has no planned probe
|
|
204
|
+
*/
|
|
205
|
+
export const describe_middleware_gate_tests = (options) => {
|
|
206
|
+
const route_specs = options.surface_source.route_specs;
|
|
207
|
+
const rpc_path = require_rpc_endpoint_path(resolve_rpc_endpoints_for_setup(options.rpc_endpoints, options.session_cookie_name));
|
|
208
|
+
const counted_routes = route_specs.filter((s) => is_standard_integration_route(s, rpc_path));
|
|
209
|
+
const probes = plan_middleware_gate_probes({
|
|
210
|
+
route_specs: counted_routes,
|
|
211
|
+
route_error_maps: options.surface_source.route_error_maps,
|
|
212
|
+
base_url: options.base_url,
|
|
213
|
+
max_body_bytes: options.max_body_bytes,
|
|
214
|
+
rpc_path,
|
|
215
|
+
rpc_max_body_bytes: options.rpc_max_body_bytes
|
|
216
|
+
});
|
|
217
|
+
// every gate refusal a counted route declares has a probe planned — checked
|
|
218
|
+
// at collection, so a planner that drops one fails whatever a run filters or
|
|
219
|
+
// excludes; the unreadable length goes unprobed over a socket (the module doc)
|
|
220
|
+
const planned = new Set(probes.map((p) => `${p.method} ${p.path} ${p.expected.status} ${p.expected.code}`));
|
|
221
|
+
const unplanned = new ErrorCoverageCollector(options.surface_source.route_error_maps)
|
|
222
|
+
.uncovered(counted_routes)
|
|
223
|
+
.filter(({ code }) => MIDDLEWARE_GATE_ERROR_CODES.includes(code) &&
|
|
224
|
+
!(options.base_url !== null && code === REST_INVALID_CONTENT_LENGTH.code))
|
|
225
|
+
.map(({ method, path, status, code }) => `${method} ${path} ${status} ${code}`)
|
|
226
|
+
.filter((key) => !planned.has(key));
|
|
227
|
+
if (unplanned.length > 0) {
|
|
228
|
+
throw new Error(`describe_middleware_gate_tests: declared gate refusals no probe plans: ${unplanned.join(', ')}`);
|
|
229
|
+
}
|
|
230
|
+
describe('middleware gates', () => {
|
|
231
|
+
const collector = new ErrorCoverageCollector(options.surface_source.route_error_maps);
|
|
232
|
+
// in-process the probes share one fixture, built ahead of them so it
|
|
233
|
+
// outlives each test (an app built in a test is closed when it
|
|
234
|
+
// finishes) and checked once they are done; over a socket they need
|
|
235
|
+
// none, as they read and write no state
|
|
236
|
+
let fixture = null;
|
|
237
|
+
let in_process_transport = null;
|
|
238
|
+
if (options.base_url === null) {
|
|
239
|
+
beforeAll(async () => {
|
|
240
|
+
fixture = await options.setup_test();
|
|
241
|
+
in_process_transport = fixture.fresh_transport({ origin: null });
|
|
242
|
+
});
|
|
243
|
+
check_db_invariants_after_all(() => fixture);
|
|
244
|
+
}
|
|
245
|
+
for (const probe of probes) {
|
|
246
|
+
test(format_middleware_gate_probe(probe), async () => {
|
|
247
|
+
const res = await send_middleware_gate_probe(probe, options.base_url, in_process_transport);
|
|
248
|
+
await assert_middleware_gate_refusal(probe, res, collector, route_specs);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc_attack_surface.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rpc_attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc_attack_surface.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rpc_attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAoB7B,OAAO,KAAK,EAGX,cAAc,EACd,MAAM,oBAAoB,CAAC;AAmC5B,uDAAuD;AACvD,MAAM,WAAW,uBAAuB;IACvC,+FAA+F;IAC/F,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC/D;AA+bD;;;;;;;;;GASG;AACH,eAAO,MAAM,iCAAiC,GAAI,SAAS,uBAAuB,KAAG,IAOpF,CAAC"}
|
|
@@ -14,6 +14,7 @@ import './assert_dev_env.js';
|
|
|
14
14
|
*/
|
|
15
15
|
import { test, assert, describe } from 'vitest';
|
|
16
16
|
import { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
17
|
+
import { to_error_message } from '@fuzdev/fuz_util/error.ts';
|
|
17
18
|
import { is_keeper_auth, is_public_auth, is_role_auth } from '../http/auth_shape.js';
|
|
18
19
|
import { JSONRPC_ERROR_CODES } from '../http/jsonrpc_errors.js';
|
|
19
20
|
import { create_auth_test_apps, create_test_app_from_specs, create_test_request_context, select_auth_app } from './auth_apps.js';
|
|
@@ -41,16 +42,35 @@ const find_rpc_action = (rpc_endpoint_specs, endpoint_path, method_name) => {
|
|
|
41
42
|
};
|
|
42
43
|
/** The key a recording stub notes its call under: the endpoint path and method. */
|
|
43
44
|
const to_reached_key = (endpoint_path, method_name) => `${endpoint_path} ${method_name}`;
|
|
45
|
+
/**
|
|
46
|
+
* A stub handler's answer: a value generated to pass the action's output
|
|
47
|
+
* schema (`generate_valid_body`; `null` for a null output), so DEV output
|
|
48
|
+
* validation has nothing to report. An output the generator can't reach
|
|
49
|
+
* makes the handler throw, naming the action — the method's "correct auth
|
|
50
|
+
* passes" test fails on the 500, and a logged-error gate on the log line.
|
|
51
|
+
*/
|
|
52
|
+
const create_stub_output = (action) => {
|
|
53
|
+
try {
|
|
54
|
+
const output = generate_valid_body(action.spec.output) ?? null;
|
|
55
|
+
return () => output;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const message = `stub handler for '${action.spec.method}' has no generated output: ${to_error_message(error)}`;
|
|
59
|
+
return () => {
|
|
60
|
+
throw new Error(message);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
44
64
|
/**
|
|
45
65
|
* The route specs with every RPC endpoint's routes rebuilt over its actions,
|
|
46
66
|
* each handler swapped for a stub that records its call in `reached` and
|
|
47
|
-
* answers
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
67
|
+
* answers a generated schema-valid output (`create_stub_output`), so a test
|
|
68
|
+
* that the handler is reached never depends on what the handler would do
|
|
69
|
+
* over stub deps (a live re-read's 401). Each endpoint's routes take the
|
|
70
|
+
* place of its first route in the list, matched on method and path, so
|
|
71
|
+
* another route at the endpoint's path stays; the rest of the list is kept
|
|
72
|
+
* in order. The endpoints mount with no rate limiters, a silent logger, and
|
|
73
|
+
* the no-op notification sender.
|
|
54
74
|
*
|
|
55
75
|
* @param route_specs - the app's route specs, the endpoints' routes among them
|
|
56
76
|
* @param rpc_endpoint_specs - the endpoints whose handlers are stubbed
|
|
@@ -64,13 +84,16 @@ const stub_rpc_endpoint_handlers = (route_specs, rpc_endpoint_specs, reached) =>
|
|
|
64
84
|
for (const endpoint of rpc_endpoint_specs) {
|
|
65
85
|
const rebuilt = create_rpc_endpoint({
|
|
66
86
|
path: endpoint.path,
|
|
67
|
-
actions: endpoint.actions.map((action) =>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
actions: endpoint.actions.map((action) => {
|
|
88
|
+
const answer = create_stub_output(action);
|
|
89
|
+
return {
|
|
90
|
+
spec: action.spec,
|
|
91
|
+
handler: () => {
|
|
92
|
+
reached.add(to_reached_key(endpoint.path, action.spec.method));
|
|
93
|
+
return answer();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}),
|
|
74
97
|
log,
|
|
75
98
|
action_ip_rate_limiter: null,
|
|
76
99
|
action_account_rate_limiter: null,
|
|
@@ -204,8 +227,10 @@ const describe_rpc_auth = (options) => {
|
|
|
204
227
|
reached.delete(key);
|
|
205
228
|
const app = select_auth_app(stubbed_apps, method.auth);
|
|
206
229
|
const res = await app.request(endpoint.path, create_rpc_post_init(method.name, params));
|
|
207
|
-
|
|
208
|
-
assert.
|
|
230
|
+
const text = await res.text();
|
|
231
|
+
assert.ok(reached.has(key), `${method.name} should reach its handler, got ${res.status}: ${text}`);
|
|
232
|
+
// a stub with no generated output throws, naming why, in the 500's body
|
|
233
|
+
assert.strictEqual(res.status, 200, `${method.name} should answer 200, got: ${text}`);
|
|
209
234
|
});
|
|
210
235
|
}
|
|
211
236
|
});
|
package/dist/testing/stubs.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare const create_throwing_stub: <T = any>(label: string) => T;
|
|
|
38
38
|
* this auto-updates when interfaces change.
|
|
39
39
|
*
|
|
40
40
|
* @param label - descriptive name for debug purposes
|
|
41
|
-
* @param overrides - explicit properties to set (e.g. `{
|
|
41
|
+
* @param overrides - explicit properties to set (e.g. `{sign: ...}` on a keyring)
|
|
42
42
|
*/
|
|
43
43
|
export declare const create_noop_stub: <T = any>(_label: string, overrides?: Record<string, unknown>) => T;
|
|
44
44
|
/** Throwing stub — use for deps that should never be reached. */
|
|
@@ -95,6 +95,10 @@ export declare const create_test_audit_emitter: () => AuditEmitter;
|
|
|
95
95
|
export declare const create_stub_audit_sse: () => AuditLogSse;
|
|
96
96
|
/**
|
|
97
97
|
* Create no-op `AppDeps` for auth surface testing.
|
|
98
|
+
*
|
|
99
|
+
* The `db` is a fresh `create_stub_db()`: a transaction runs its callback,
|
|
100
|
+
* and the pool-level `Db` reads as outside one, so a handler on stub deps
|
|
101
|
+
* runs the path it runs in production.
|
|
98
102
|
*/
|
|
99
103
|
export declare const create_stub_app_deps: () => AppDeps;
|
|
100
104
|
/** Options for `create_stub_app_backend`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../../src/lib/testing/stubs.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAyB,MAAM,aAAa,CAAC;AACxD,OAAO,E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,CAAC,CAAC;IAC/B;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAC7F;;;;;;;;OAQG;IACH,YAAY,CAAC,EACZ,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,gBAAgB,KAAK,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC;IAC5F;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/E;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC9C;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,cAmHF,CAAC"}
|
package/dist/testing/stubs.js
CHANGED
|
@@ -69,7 +69,7 @@ export const create_throwing_stub = (label) => new Proxy({}, {
|
|
|
69
69
|
* this auto-updates when interfaces change.
|
|
70
70
|
*
|
|
71
71
|
* @param label - descriptive name for debug purposes
|
|
72
|
-
* @param overrides - explicit properties to set (e.g. `{
|
|
72
|
+
* @param overrides - explicit properties to set (e.g. `{sign: ...}` on a keyring)
|
|
73
73
|
*/
|
|
74
74
|
export const create_noop_stub = (_label, overrides) => new Proxy({ ...(overrides ?? {}) }, {
|
|
75
75
|
get: (target, prop) => {
|
|
@@ -117,7 +117,6 @@ attach_route_handler(shape, () => {
|
|
|
117
117
|
});
|
|
118
118
|
/** Stub middleware that passes through. */
|
|
119
119
|
export const stub_mw = async (_c, next) => next();
|
|
120
|
-
const stub_db = create_noop_stub('stub_db');
|
|
121
120
|
/**
|
|
122
121
|
* Build a no-op `AuditEmitter` for tests that don't assert on audit fan-out.
|
|
123
122
|
*
|
|
@@ -166,6 +165,10 @@ export const create_stub_audit_sse = () => {
|
|
|
166
165
|
};
|
|
167
166
|
/**
|
|
168
167
|
* Create no-op `AppDeps` for auth surface testing.
|
|
168
|
+
*
|
|
169
|
+
* The `db` is a fresh `create_stub_db()`: a transaction runs its callback,
|
|
170
|
+
* and the pool-level `Db` reads as outside one, so a handler on stub deps
|
|
171
|
+
* runs the path it runs in production.
|
|
169
172
|
*/
|
|
170
173
|
export const create_stub_app_deps = () => ({
|
|
171
174
|
// `sign` answers a string, as a keyring does, so a route that signs a
|
|
@@ -174,7 +177,7 @@ export const create_stub_app_deps = () => ({
|
|
|
174
177
|
sign: async (value) => `${value}.stub_signature`
|
|
175
178
|
}),
|
|
176
179
|
password: create_noop_stub('password'),
|
|
177
|
-
db:
|
|
180
|
+
db: create_stub_db(),
|
|
178
181
|
log: new Logger('test', { level: 'off' }),
|
|
179
182
|
audit: create_test_audit_emitter(),
|
|
180
183
|
connection_closer: create_realtime_closer(),
|
|
@@ -5,8 +5,9 @@ import './assert_dev_env.js';
|
|
|
5
5
|
* `create_test_app` combines `create_test_app_server` (`testing/app_server.ts`,
|
|
6
6
|
* the vitest-free backend primitives) with `create_app_server`, and hands back
|
|
7
7
|
* the app, the backend, the surface, and request header builders. Built inside
|
|
8
|
-
* a test, the app's database is held to the
|
|
9
|
-
* test finishes
|
|
8
|
+
* a test (its body or a `beforeEach`), the app's database is held to the
|
|
9
|
+
* auth-schema invariants when the test finishes, and the app is closed then,
|
|
10
|
+
* failing the test on a close that gave up on work still in flight.
|
|
10
11
|
*
|
|
11
12
|
* @module
|
|
12
13
|
*/
|
|
@@ -105,7 +106,9 @@ export interface CreateTestAppAccountArgs {
|
|
|
105
106
|
email?: string;
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
108
|
-
* A fully assembled test app — Hono app + backend + helpers.
|
|
109
|
+
* A fully assembled test app — Hono app + backend + helpers. Never built inside
|
|
110
|
+
* a concurrent test (`create_test_app` throws): build a concurrent suite's app
|
|
111
|
+
* in `beforeAll` and close it in `afterAll`.
|
|
109
112
|
*/
|
|
110
113
|
export interface TestApp {
|
|
111
114
|
app: Hono;
|
|
@@ -114,7 +117,10 @@ export interface TestApp {
|
|
|
114
117
|
* The assembled `AppServer` — reach for what `create_app_server` built
|
|
115
118
|
* beyond the fields lifted onto `TestApp`: `audit_sse` (with
|
|
116
119
|
* `audit_log_sse` in `app_options`), the `ws_endpoints` transports,
|
|
117
|
-
* `bootstrap_status`, `migration_results`.
|
|
120
|
+
* `bootstrap_status`, `migration_results`. Its `close` resolves the
|
|
121
|
+
* `ShutdownDrainGivenUp` report, for a test that gives up on purpose, and
|
|
122
|
+
* marks the app closed by the test, so the close when the test finishes
|
|
123
|
+
* leaves the outcome to it.
|
|
118
124
|
*/
|
|
119
125
|
server: AppServer;
|
|
120
126
|
surface_spec: AppSurfaceSpec;
|
|
@@ -137,9 +143,27 @@ export interface TestApp {
|
|
|
137
143
|
* @throws Error listing every broken invariant and its rows
|
|
138
144
|
*/
|
|
139
145
|
assert_db_invariants: () => Promise<void>;
|
|
140
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* Cleanup resources — `AppServer.close`: stops an opted-in auth cleanup
|
|
148
|
+
* schedule, closes live connections, drains the work in flight within its
|
|
149
|
+
* bound (`TEST_SHUTDOWN_DRAIN_TIMEOUT_MS` unless `app_options` sets one),
|
|
150
|
+
* disposes the limiters the server built and removes the audit listeners
|
|
151
|
+
* and closer members it added, then the backend's `close`. Idempotent. A
|
|
152
|
+
* test that gives up on purpose calls `server.close()`, which resolves the
|
|
153
|
+
* report instead.
|
|
154
|
+
*
|
|
155
|
+
* @throws Error naming the `ShutdownDrainGivenUp` report when the drain
|
|
156
|
+
* gave up on work still in flight
|
|
157
|
+
*/
|
|
141
158
|
cleanup: () => Promise<void>;
|
|
142
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* The bound on a test app's shutdown drain (`shutdown_drain_timeout_ms`), in
|
|
162
|
+
* ms: under vitest's per-test timeout, so a test whose app gives up fails on
|
|
163
|
+
* the give-up rather than timing out, and short, since a test's work in
|
|
164
|
+
* flight is milliseconds. Override through `app_options`.
|
|
165
|
+
*/
|
|
166
|
+
export declare const TEST_SHUTDOWN_DRAIN_TIMEOUT_MS = 1000;
|
|
143
167
|
/**
|
|
144
168
|
* Create a fully assembled test app with a Hono server, middleware, and routes.
|
|
145
169
|
*
|
|
@@ -152,15 +176,21 @@ export interface TestApp {
|
|
|
152
176
|
* server's deps (db, keyring), so reuse across servers is unsafe.
|
|
153
177
|
* The expensive resource (the WASM database) is cached separately in `testing/db.ts`.
|
|
154
178
|
*
|
|
155
|
-
* Built inside a running test, it registers
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
179
|
+
* Built inside a running test (its body or a `beforeEach`), it registers one
|
|
180
|
+
* hook for when the test finishes: the database invariant check (skipped when
|
|
181
|
+
* the test already failed, as `register_db_invariants_check` does), then the
|
|
182
|
+
* close. The close throws when it gave up on work still in flight, unless the
|
|
183
|
+
* test failed or closed the app itself (`cleanup`, or `server.close()`, whose
|
|
184
|
+
* outcome is the test's). So an app built in a test lives only for that test.
|
|
185
|
+
* Built in `beforeAll`, nothing is registered: the suite closes the app, and
|
|
186
|
+
* calls `check_db_invariants_after_all(() => test_app)`, or, when the describe
|
|
159
187
|
* closes the app in its own `afterAll`, `check_db_invariants_after_suite(suite,
|
|
160
188
|
* test_app)` inside that hook ahead of the close.
|
|
161
189
|
*
|
|
162
190
|
* @param options - test app configuration
|
|
163
191
|
* @returns a `TestApp` ready for HTTP testing
|
|
192
|
+
* @throws Error when called inside a concurrent test, whose finish vitest
|
|
193
|
+
* can't tell from a sibling's — build the app in `beforeAll` instead
|
|
164
194
|
* @throws Error on an `exclude_db_invariants` entry naming no invariant or
|
|
165
195
|
* carrying no reason
|
|
166
196
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_app.d.ts","sourceRoot":"","sources":["../../src/lib/testing/test_app.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B
|
|
1
|
+
{"version":3,"file":"test_app.d.ts","sourceRoot":"","sources":["../../src/lib/testing/test_app.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAEN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAKN,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IACjE,qEAAqE;IACrE,mBAAmB,EAAE,M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 -1,10 +1,19 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
+
import { onTestFinished, TestRunner } from 'vitest';
|
|
2
3
|
import { DEFAULT_TEST_PASSWORD } from './test_credentials.js';
|
|
3
4
|
import { create_app_server } from '../server/app_server.js';
|
|
5
|
+
import { shutdown_gave_up } from '../server/shutdown_drain.js';
|
|
4
6
|
import { generate_daemon_token, DAEMON_TOKEN_HEADER } from '../auth/daemon_token.js';
|
|
5
7
|
import { create_test_request_headers } from './test_origin.js';
|
|
6
8
|
import { create_loopback_app_server_options, create_test_account_with_credentials, create_test_app_server, stub_password_deps } from './app_server.js';
|
|
7
|
-
import { announce_db_invariant_exclusions, assert_db_invariants
|
|
9
|
+
import { announce_db_invariant_exclusions, assert_db_invariants } from './db_invariants.js';
|
|
10
|
+
/**
|
|
11
|
+
* The bound on a test app's shutdown drain (`shutdown_drain_timeout_ms`), in
|
|
12
|
+
* ms: under vitest's per-test timeout, so a test whose app gives up fails on
|
|
13
|
+
* the give-up rather than timing out, and short, since a test's work in
|
|
14
|
+
* flight is milliseconds. Override through `app_options`.
|
|
15
|
+
*/
|
|
16
|
+
export const TEST_SHUTDOWN_DRAIN_TIMEOUT_MS = 1000;
|
|
8
17
|
/**
|
|
9
18
|
* The `create_app_server` options both test-app builders share — a fresh
|
|
10
19
|
* object per call, spread ahead of the per-builder options and `app_options`.
|
|
@@ -14,8 +23,16 @@ const test_app_options = () => ({
|
|
|
14
23
|
// every limiter off unless `app_options` passes one — a rate-limit test
|
|
15
24
|
// enables just the limiter it pins
|
|
16
25
|
rate_limiters: 'disabled_for_testing',
|
|
17
|
-
await_pending_effects: true
|
|
26
|
+
await_pending_effects: true,
|
|
27
|
+
// off: a background pass would delete rows and write audit rows mid-test.
|
|
28
|
+
// A suite that opts in through `app_options` has the schedule stopped by
|
|
29
|
+
// `cleanup`.
|
|
30
|
+
auth_cleanup: 'off',
|
|
31
|
+
shutdown_drain_timeout_ms: TEST_SHUTDOWN_DRAIN_TIMEOUT_MS
|
|
18
32
|
});
|
|
33
|
+
/** The error a test app's close that gave up throws, naming the report. */
|
|
34
|
+
const format_close_given_up = (closer, given_up) => `create_test_app: ${closer} gave up on work still in flight ${JSON.stringify(given_up)} — ` +
|
|
35
|
+
'a request, WS message or audit write the test left running';
|
|
19
36
|
/** Build request headers carrying `session_cookie` in the `cookie_name` cookie. */
|
|
20
37
|
const create_session_headers_builder = (cookie_name, session_cookie) => (extra) => create_test_request_headers({ cookie: `${cookie_name}=${session_cookie}`, ...extra });
|
|
21
38
|
/** Build request headers carrying `api_token` as a Bearer token. */
|
|
@@ -36,19 +53,31 @@ const create_bearer_headers_builder = (api_token) => (extra) => ({
|
|
|
36
53
|
* server's deps (db, keyring), so reuse across servers is unsafe.
|
|
37
54
|
* The expensive resource (the WASM database) is cached separately in `testing/db.ts`.
|
|
38
55
|
*
|
|
39
|
-
* Built inside a running test, it registers
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
56
|
+
* Built inside a running test (its body or a `beforeEach`), it registers one
|
|
57
|
+
* hook for when the test finishes: the database invariant check (skipped when
|
|
58
|
+
* the test already failed, as `register_db_invariants_check` does), then the
|
|
59
|
+
* close. The close throws when it gave up on work still in flight, unless the
|
|
60
|
+
* test failed or closed the app itself (`cleanup`, or `server.close()`, whose
|
|
61
|
+
* outcome is the test's). So an app built in a test lives only for that test.
|
|
62
|
+
* Built in `beforeAll`, nothing is registered: the suite closes the app, and
|
|
63
|
+
* calls `check_db_invariants_after_all(() => test_app)`, or, when the describe
|
|
43
64
|
* closes the app in its own `afterAll`, `check_db_invariants_after_suite(suite,
|
|
44
65
|
* test_app)` inside that hook ahead of the close.
|
|
45
66
|
*
|
|
46
67
|
* @param options - test app configuration
|
|
47
68
|
* @returns a `TestApp` ready for HTTP testing
|
|
69
|
+
* @throws Error when called inside a concurrent test, whose finish vitest
|
|
70
|
+
* can't tell from a sibling's — build the app in `beforeAll` instead
|
|
48
71
|
* @throws Error on an `exclude_db_invariants` entry naming no invariant or
|
|
49
72
|
* carrying no reason
|
|
50
73
|
*/
|
|
51
74
|
export const create_test_app = async (options) => {
|
|
75
|
+
const current_test = TestRunner.getCurrentTest();
|
|
76
|
+
// vitest names whichever concurrent test started last current, so the
|
|
77
|
+
// close at a concurrent test's finish would land on a sibling's app
|
|
78
|
+
if (current_test?.concurrent) {
|
|
79
|
+
throw new Error('create_test_app: built in a concurrent test, whose finish would close the app under a sibling — build it in `beforeAll` and close it in `afterAll`');
|
|
80
|
+
}
|
|
52
81
|
const { exclude_db_invariants } = options;
|
|
53
82
|
announce_db_invariant_exclusions(exclude_db_invariants, 'create_test_app');
|
|
54
83
|
const test_server = await create_test_app_server(options);
|
|
@@ -68,9 +97,6 @@ export const create_test_app = async (options) => {
|
|
|
68
97
|
daemon_token_state,
|
|
69
98
|
rpc_endpoints: options.rpc_endpoints,
|
|
70
99
|
bootstrap: options.bootstrap,
|
|
71
|
-
// `auth_cleanup` stays at its default, off: a background pass would
|
|
72
|
-
// delete rows and write audit rows mid-test. A suite that opts in
|
|
73
|
-
// through `app_options` has the schedule stopped by `cleanup`.
|
|
74
100
|
...options.app_options,
|
|
75
101
|
create_route_specs: options.create_route_specs
|
|
76
102
|
});
|
|
@@ -103,11 +129,39 @@ export const create_test_app = async (options) => {
|
|
|
103
129
|
};
|
|
104
130
|
};
|
|
105
131
|
const check_db_invariants = () => assert_db_invariants({ db: test_server.deps.db }, 'in-process', exclude_db_invariants);
|
|
106
|
-
|
|
132
|
+
// a test that closes the app itself owns the outcome
|
|
133
|
+
let closed_by_test = false;
|
|
134
|
+
const close = () => {
|
|
135
|
+
closed_by_test = true;
|
|
136
|
+
return result.close();
|
|
137
|
+
};
|
|
138
|
+
// one hook, so the check runs ahead of the close
|
|
139
|
+
if (current_test) {
|
|
140
|
+
onTestFinished(async ({ task }) => {
|
|
141
|
+
const failed = task.result?.state === 'fail';
|
|
142
|
+
// the close runs whatever the check found; a violation is the report
|
|
143
|
+
let violation = null;
|
|
144
|
+
if (!failed) {
|
|
145
|
+
try {
|
|
146
|
+
await check_db_invariants();
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
violation = { error };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const owned_by_test = closed_by_test;
|
|
153
|
+
const given_up = await result.close();
|
|
154
|
+
if (violation)
|
|
155
|
+
throw violation.error;
|
|
156
|
+
if (!failed && !owned_by_test && shutdown_gave_up(given_up)) {
|
|
157
|
+
throw new Error(format_close_given_up('the close when the test finished', given_up));
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
107
161
|
return {
|
|
108
162
|
app,
|
|
109
163
|
backend: test_server,
|
|
110
|
-
server: result,
|
|
164
|
+
server: { ...result, close },
|
|
111
165
|
surface_spec,
|
|
112
166
|
surface: surface_spec.surface,
|
|
113
167
|
route_specs: surface_spec.route_specs,
|
|
@@ -118,6 +172,10 @@ export const create_test_app = async (options) => {
|
|
|
118
172
|
assert_db_invariants: check_db_invariants,
|
|
119
173
|
// the server's `close`, not the backend's: it also stops an auth cleanup
|
|
120
174
|
// schedule a suite opted into
|
|
121
|
-
cleanup: () =>
|
|
175
|
+
cleanup: async () => {
|
|
176
|
+
const given_up = await close();
|
|
177
|
+
if (shutdown_gave_up(given_up))
|
|
178
|
+
throw new Error(format_close_given_up('cleanup', given_up));
|
|
179
|
+
}
|
|
122
180
|
};
|
|
123
181
|
};
|
|
@@ -23,6 +23,13 @@ import '../assert_dev_env.js';
|
|
|
23
23
|
* a cleared session cookie kept as `name=` would be re-sent as an invalid
|
|
24
24
|
* cookie, which both spines answer by clearing it again.
|
|
25
25
|
*
|
|
26
|
+
* A request naming a credential of its own (`Authorization`, `X-Daemon-Token`)
|
|
27
|
+
* while the jar holds a cookie throws unless it names its `Cookie` too: the
|
|
28
|
+
* jar would ride along, so a dead token beside it would authenticate as the
|
|
29
|
+
* jar's principal and a refusal the test expects would never be reached. A
|
|
30
|
+
* test sends such a request over a cookie-free transport, or both credentials
|
|
31
|
+
* on purpose by passing `Cookie` itself.
|
|
32
|
+
*
|
|
26
33
|
* @module
|
|
27
34
|
*/
|
|
28
35
|
import type { RpcTestTransport } from '../rpc_helpers.js';
|
|
@@ -79,6 +86,9 @@ export interface FetchTransport extends RpcTestTransport {
|
|
|
79
86
|
* - `Origin` is set to `options.origin ?? base_url` unless the caller
|
|
80
87
|
* already provided one.
|
|
81
88
|
* - `Cookie` is set from the jar unless the caller already provided one.
|
|
89
|
+
*
|
|
90
|
+
* @throws Error when a request names `Authorization` or `X-Daemon-Token`,
|
|
91
|
+
* no `Cookie`, and the jar is non-empty
|
|
82
92
|
*/
|
|
83
93
|
export declare const create_fetch_transport: (options: FetchTransportOptions) => FetchTransport;
|
|
84
94
|
//# sourceMappingURL=fetch_transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch_transport.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/transports/fetch_transport.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B
|
|
1
|
+
{"version":3,"file":"fetch_transport.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/transports/fetch_transport.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAK1D,yDAAyD;AACzD,MAAM,WAAW,qBAAqB;IACrC,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACjD;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACvD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;CAC9C;AAsCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,sBAAsB,GAAI,SAAS,qBAAqB,KAAG,cA6CvE,CAAC"}
|