@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
|
@@ -15,6 +15,7 @@ import { API_TOKEN_PREFIX, is_api_token_shaped } from '../../auth/api_token.js';
|
|
|
15
15
|
import { account_token_create_action_spec } from '../../auth/account_action_specs.js';
|
|
16
16
|
import { find_rpc_action } from '../rpc_helpers.js';
|
|
17
17
|
import { SCOPED_TOKEN_ADMITTED_METHOD } from './conformance_case.js';
|
|
18
|
+
import { assert_credential_authenticates } from './setup.js';
|
|
18
19
|
import { mint_narrowed_api_token } from './narrowed_api_token.js';
|
|
19
20
|
/**
|
|
20
21
|
* A deliberately malformed `X-Daemon-Token` value for the `invalid_daemon`
|
|
@@ -74,6 +75,12 @@ const as_lone_bearer = (fixture, token) => ({
|
|
|
74
75
|
* `account_token_create` is session-only, so this runs over the keeper's
|
|
75
76
|
* session — which also makes the mint itself a live assertion that a narrowed
|
|
76
77
|
* scope is *accepted* at the mint boundary, not merely stored.
|
|
78
|
+
*
|
|
79
|
+
* The token is then proven to authenticate as the keeper, alone, on the method
|
|
80
|
+
* it admits (`assert_credential_authenticates`), so every case sent as the
|
|
81
|
+
* principal rests on a working credential of the expected account: a refusal
|
|
82
|
+
* can only be its scope or its channel, never a token that authenticates as
|
|
83
|
+
* no one or as another account.
|
|
77
84
|
*/
|
|
78
85
|
const mint_scoped_token = async (fixture, resolved_rpc_endpoints) => {
|
|
79
86
|
const found = find_rpc_action(resolved_rpc_endpoints, account_token_create_action_spec.method);
|
|
@@ -82,13 +89,27 @@ const mint_scoped_token = async (fixture, resolved_rpc_endpoints) => {
|
|
|
82
89
|
`on the surface to mint its narrowed token, but the method is not registered on ` +
|
|
83
90
|
`rpc_endpoints.`);
|
|
84
91
|
}
|
|
85
|
-
|
|
92
|
+
const admitted = find_rpc_action(resolved_rpc_endpoints, SCOPED_TOKEN_ADMITTED_METHOD);
|
|
93
|
+
if (!admitted) {
|
|
94
|
+
throw new Error(`conformance: principal 'scoped_token' needs '${SCOPED_TOKEN_ADMITTED_METHOD}' on the ` +
|
|
95
|
+
`surface to prove its narrowed token live, but the method is not registered on ` +
|
|
96
|
+
`rpc_endpoints.`);
|
|
97
|
+
}
|
|
98
|
+
const token = await mint_narrowed_api_token({
|
|
86
99
|
app: fixture.transport,
|
|
87
100
|
rpc_path: found.path,
|
|
88
101
|
session_headers: fixture.create_session_headers(),
|
|
89
102
|
methods: [SCOPED_TOKEN_ADMITTED_METHOD],
|
|
90
103
|
name: 'conformance scoped token'
|
|
91
104
|
});
|
|
105
|
+
await assert_credential_authenticates({
|
|
106
|
+
transport: fixture.fresh_transport({ origin: null }),
|
|
107
|
+
rpc_path: admitted.path,
|
|
108
|
+
headers: { authorization: `Bearer ${token}` },
|
|
109
|
+
account_id: fixture.account.id,
|
|
110
|
+
accessor: 'scoped_token'
|
|
111
|
+
});
|
|
112
|
+
return token;
|
|
92
113
|
};
|
|
93
114
|
/**
|
|
94
115
|
* Map a `ConformancePrincipal` onto the transport + headers it
|
|
@@ -221,18 +242,14 @@ export const resolve_conformance_principal = async (fixture, as, principals, res
|
|
|
221
242
|
actor_id: account.actor.id
|
|
222
243
|
};
|
|
223
244
|
}
|
|
224
|
-
case 'expired_session':
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
// is what the DB-row expiry gate refuses.
|
|
229
|
-
const cookie = await fixture.mint_expired_session();
|
|
245
|
+
case 'expired_session':
|
|
246
|
+
// fresh jar, so the expired cookie is the only one sent: its signed
|
|
247
|
+
// payload verifies, and its row's passed `expires_at` is what the
|
|
248
|
+
// DB-row expiry gate refuses
|
|
230
249
|
return {
|
|
231
250
|
transport: fixture.fresh_transport(),
|
|
232
|
-
headers: { cookie }
|
|
233
|
-
actor_id: fixture.actor.id
|
|
251
|
+
headers: { cookie: await fixture.mint_expired_session() }
|
|
234
252
|
};
|
|
235
|
-
}
|
|
236
253
|
case 'tampered_cookie': {
|
|
237
254
|
// fresh jar, so the tampered cookie is the only one sent
|
|
238
255
|
const { cookie } = fixture.create_session_headers();
|
|
@@ -35,6 +35,7 @@ import '../assert_dev_env.js';
|
|
|
35
35
|
*/
|
|
36
36
|
import type { TestProject } from 'vitest/node';
|
|
37
37
|
import type { BackendConfig } from './backend_config.js';
|
|
38
|
+
import { type BootstrappedBackendHandle } from './setup.js';
|
|
38
39
|
export interface DualSpawnGlobalSetupOptions {
|
|
39
40
|
/**
|
|
40
41
|
* The two backend config factories to spawn. `a` is spawned first; on
|
|
@@ -62,9 +63,17 @@ export interface DualSpawnGlobalSetupOptions {
|
|
|
62
63
|
* pre-bootstrap window. Omit for none.
|
|
63
64
|
*/
|
|
64
65
|
readonly before_bootstrap?: (config: BackendConfig) => Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Run against each backend once its keeper bootstrap has succeeded, before
|
|
68
|
+
* the other is spawned and before any test — for a read of what the
|
|
69
|
+
* bootstrap wrote, which per-test resets overwrite. `side` names the
|
|
70
|
+
* config. A throw tears down every backend spawned so far and fails the
|
|
71
|
+
* setup. Omit for none.
|
|
72
|
+
*/
|
|
73
|
+
readonly after_bootstrap?: (handle: BootstrappedBackendHandle, side: 'a' | 'b') => Promise<void>;
|
|
65
74
|
}
|
|
66
75
|
/**
|
|
67
76
|
* Build a vitest `globalSetup` default export that spawns both backends.
|
|
68
77
|
*/
|
|
69
|
-
export declare const create_dual_spawn_global_setup: ({ configs, provide_keys, before_bootstrap }: DualSpawnGlobalSetupOptions) => ((project: TestProject) => Promise<() => Promise<void>>);
|
|
78
|
+
export declare const create_dual_spawn_global_setup: ({ configs, provide_keys, before_bootstrap, after_bootstrap }: DualSpawnGlobalSetupOptions) => ((project: TestProject) => Promise<() => Promise<void>>);
|
|
70
79
|
//# sourceMappingURL=create_dual_spawn_global_setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_dual_spawn_global_setup.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/create_dual_spawn_global_setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"create_dual_spawn_global_setup.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/create_dual_spawn_global_setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAiC,KAAK,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE3F,MAAM,WAAW,2BAA2B;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,aAAa,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,aAAa,CAAA;KAAE,CAAC;IACvF;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,yBAAyB,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACjG;AAED;;GAEG;AACH,eAAO,MAAM,8BAA8B,GAAI,8DAK5C,2BAA2B,KAAG,CAAC,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAgCvF,CAAC"}
|
|
@@ -4,24 +4,50 @@ import { serialize_bootstrapped_handle } from './setup.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Build a vitest `globalSetup` default export that spawns both backends.
|
|
6
6
|
*/
|
|
7
|
-
export const create_dual_spawn_global_setup = ({ configs, provide_keys = { a: 'parity_handle_a', b: 'parity_handle_b' }, before_bootstrap }) => {
|
|
7
|
+
export const create_dual_spawn_global_setup = ({ configs, provide_keys = { a: 'parity_handle_a', b: 'parity_handle_b' }, before_bootstrap, after_bootstrap }) => {
|
|
8
8
|
return async (project) => {
|
|
9
9
|
const a = await bootstrap_backend(configs.a(), { before_bootstrap });
|
|
10
|
-
// Tear
|
|
11
|
-
|
|
10
|
+
// Tear down what is up if `b` fails to spawn or either hook throws — no
|
|
11
|
+
// orphaned child process.
|
|
12
|
+
let b = null;
|
|
12
13
|
try {
|
|
14
|
+
await after_bootstrap?.(a, 'a');
|
|
13
15
|
b = await bootstrap_backend(configs.b(), { before_bootstrap });
|
|
16
|
+
await after_bootstrap?.(b, 'b');
|
|
14
17
|
}
|
|
15
18
|
catch (err) {
|
|
16
|
-
|
|
19
|
+
// the setup's error is the report; a teardown that also failed is
|
|
20
|
+
// logged beside it
|
|
21
|
+
const failures = await teardown_each(b ? [b, a] : [a]);
|
|
22
|
+
for (const failure of failures)
|
|
23
|
+
console.error(failure);
|
|
17
24
|
throw err;
|
|
18
25
|
}
|
|
26
|
+
const spawned_b = b;
|
|
19
27
|
const provide = project.provide;
|
|
20
28
|
provide(provide_keys.a, serialize_bootstrapped_handle(a));
|
|
21
|
-
provide(provide_keys.b, serialize_bootstrapped_handle(
|
|
29
|
+
provide(provide_keys.b, serialize_bootstrapped_handle(spawned_b));
|
|
22
30
|
return async () => {
|
|
23
|
-
|
|
24
|
-
await a
|
|
31
|
+
// both, whichever fails — a failed exit of one must not strand the other
|
|
32
|
+
const failures = await teardown_each([spawned_b, a]);
|
|
33
|
+
if (failures.length === 1)
|
|
34
|
+
throw failures[0];
|
|
35
|
+
if (failures.length > 1) {
|
|
36
|
+
throw new Error(failures.map((f) => (f instanceof Error ? f.message : String(f))).join('\n'));
|
|
37
|
+
}
|
|
25
38
|
};
|
|
26
39
|
};
|
|
27
40
|
};
|
|
41
|
+
/** Tear each handle down in turn, returning the failures rather than stopping at the first. */
|
|
42
|
+
const teardown_each = async (handles) => {
|
|
43
|
+
const failures = [];
|
|
44
|
+
for (const handle of handles) {
|
|
45
|
+
try {
|
|
46
|
+
await handle.teardown();
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
failures.push(error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return failures;
|
|
53
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import '../assert_dev_env.js';
|
|
2
2
|
import type { BackendBootstrapConfig, BackendConfig } from './backend_config.js';
|
|
3
3
|
import type { BackendCapabilities, FamilyDefaultCapabilities } from './capabilities.js';
|
|
4
|
+
import { type BackendLogAllowance } from './backend_log.js';
|
|
4
5
|
import { type TestBackendPaths } from './build_test_backend_paths.js';
|
|
5
6
|
/**
|
|
6
7
|
* The `HOST` both builders bind a backend to — loopback IPv4, since
|
|
@@ -62,7 +63,23 @@ export declare const ts_default_capabilities: FamilyDefaultCapabilities;
|
|
|
62
63
|
* behavior of hyper. Carries no `MountFlag` and no `testing_backdoors`.
|
|
63
64
|
*/
|
|
64
65
|
export declare const rust_default_capabilities: FamilyDefaultCapabilities;
|
|
65
|
-
|
|
66
|
+
/** The backend log options both family builders take. */
|
|
67
|
+
export interface DefaultBackendLogOptions {
|
|
68
|
+
/**
|
|
69
|
+
* The file `spawn_backend` tees the backend's output into, checked at
|
|
70
|
+
* teardown (`BackendConfig.log`). Defaults to `backend.log` under the
|
|
71
|
+
* backend's temp root (`paths.root`); `null` keeps no log and checks
|
|
72
|
+
* nothing.
|
|
73
|
+
*/
|
|
74
|
+
readonly log_path?: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Error lines the backend may log beside `SPINE_CROSS_SUITE_BACKEND_ERRORS`
|
|
77
|
+
* (what the shipped cross suites provoke on purpose) — what a consumer's
|
|
78
|
+
* own suites provoke, each with its reason.
|
|
79
|
+
*/
|
|
80
|
+
readonly log_allow_errors?: ReadonlyArray<BackendLogAllowance>;
|
|
81
|
+
}
|
|
82
|
+
export interface MakeDefaultTsBackendConfigOptions extends DefaultBackendLogOptions {
|
|
66
83
|
/** Diagnostic label; also names the tmpdir (`default_test_backend_paths`) when `paths` is omitted. */
|
|
67
84
|
readonly name: string;
|
|
68
85
|
/** TCP port the binary listens on. */
|
|
@@ -108,14 +125,22 @@ export interface MakeDefaultTsBackendConfigOptions {
|
|
|
108
125
|
*/
|
|
109
126
|
readonly daemon_token_dir_env?: string;
|
|
110
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* The `PUBLIC_LOG_LEVEL` a TS-family backend gets — `'warn'`, so its errors
|
|
130
|
+
* and warnings reach its output without a line per request. Set through the
|
|
131
|
+
* env, not a `Logger` level in `start_testing_server`, because fuz_util reads
|
|
132
|
+
* it as the default level of every `Logger` the binary builds, the app's own
|
|
133
|
+
* included. Override it with `extra_env`.
|
|
134
|
+
*/
|
|
135
|
+
export declare const TS_BACKEND_LOG_LEVEL = "warn";
|
|
111
136
|
/**
|
|
112
137
|
* Shared builder for TS-family backends (Node + Bun). Owns the common
|
|
113
138
|
* env baseline (NODE_ENV, HOST, PORT, in-memory pglet, cookie keys,
|
|
114
|
-
* bootstrap token path) so per-backend factories only
|
|
115
|
-
* genuinely differs.
|
|
139
|
+
* bootstrap token path, `PUBLIC_LOG_LEVEL`) so per-backend factories only
|
|
140
|
+
* declare what genuinely differs.
|
|
116
141
|
*/
|
|
117
142
|
export declare const make_default_ts_backend_config: (opts: MakeDefaultTsBackendConfigOptions) => BackendConfig;
|
|
118
|
-
export interface MakeDefaultRustBackendConfigOptions {
|
|
143
|
+
export interface MakeDefaultRustBackendConfigOptions extends DefaultBackendLogOptions {
|
|
119
144
|
/** Diagnostic label; also names the tmpdir (`default_test_backend_paths`) when `paths` is omitted. */
|
|
120
145
|
readonly name: string;
|
|
121
146
|
/** TCP port the binary listens on. */
|
|
@@ -130,6 +155,14 @@ export interface MakeDefaultRustBackendConfigOptions {
|
|
|
130
155
|
readonly database_url: string;
|
|
131
156
|
/** Merged on top of the generic env baseline; later keys win. */
|
|
132
157
|
readonly extra_env?: Readonly<Record<string, string>>;
|
|
158
|
+
/**
|
|
159
|
+
* Whether the binary drops the database's `public` schema before its
|
|
160
|
+
* migrations on every boot (`FUZ_TESTING_RESET_DB_ON_STARTUP`, written
|
|
161
|
+
* `'true'` or `'false'`). Default `true`, so a run starts on an empty
|
|
162
|
+
* database. `false` for a binary booted over a database another backend
|
|
163
|
+
* left — the backend swap (`backend_swap.ts`).
|
|
164
|
+
*/
|
|
165
|
+
readonly reset_db_on_startup?: boolean;
|
|
133
166
|
/**
|
|
134
167
|
* Every capability, stated: spread `rust_default_capabilities` and add each
|
|
135
168
|
* `MountFlag` and the `testing_backdoors` list. Required, so a mount flag or
|
|
@@ -171,7 +204,7 @@ export interface MakeDefaultRustBackendConfigOptions {
|
|
|
171
204
|
/**
|
|
172
205
|
* Shared builder for Rust-family backends. Owns the common env baseline
|
|
173
206
|
* (RUST_LOG, HOST, port, real Postgres, cookie keys, bootstrap token
|
|
174
|
-
* path, the `FUZ_TESTING_RESET_DB_ON_STARTUP
|
|
207
|
+
* path, the `FUZ_TESTING_RESET_DB_ON_STARTUP` self-wipe gate) plus
|
|
175
208
|
* the 120s startup window for cargo's first-run build cost.
|
|
176
209
|
*/
|
|
177
210
|
export declare const make_default_rust_backend_config: (opts: MakeDefaultRustBackendConfigOptions) => BackendConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default_backend_configs.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/default_backend_configs.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"default_backend_configs.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/default_backend_configs.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4C9B,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,yBA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4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD;;;;;;OAMG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAClC,sEAAsE;IACtE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC/D;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;OAOG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACvC;AAED;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,mCAAmC,KACvC,aAqDF,CAAC"}
|
|
@@ -11,10 +11,17 @@ import '../assert_dev_env.js';
|
|
|
11
11
|
*
|
|
12
12
|
* Defaults baked in by family:
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* Both also tee the backend's output into `backend.log` under its temp root
|
|
15
|
+
* and fail teardown on an error line no allowance names
|
|
16
|
+
* (`DefaultBackendLogOptions`, `backend_log.ts`).
|
|
17
|
+
*
|
|
18
|
+
* - **TS** — `'memory://'` (in-memory pglet), 30s startup window, and
|
|
19
|
+
* `PUBLIC_LOG_LEVEL` set to `TS_BACKEND_LOG_LEVEL` (the spawned binary
|
|
20
|
+
* inherits `VITEST`, which would turn every `Logger` off).
|
|
15
21
|
* - **Rust** — caller-supplied real Postgres URL (an in-process WASM database isn't reachable
|
|
16
22
|
* from `tokio-postgres`), 120s startup window (cargo first-build cost),
|
|
17
|
-
* and the `FUZ_TESTING_RESET_DB_ON_STARTUP
|
|
23
|
+
* and the `FUZ_TESTING_RESET_DB_ON_STARTUP` self-wipe gate, on unless
|
|
24
|
+
* `reset_db_on_startup: false`.
|
|
18
25
|
*
|
|
19
26
|
* Both builders default `port_env_var` to `'PORT'`. Consumers whose
|
|
20
27
|
* binary reads a different name (e.g. zzz's `ZZZ_PORT`) override. Both bind
|
|
@@ -31,7 +38,8 @@ import '../assert_dev_env.js';
|
|
|
31
38
|
*
|
|
32
39
|
* @module
|
|
33
40
|
*/
|
|
34
|
-
import { basename, dirname } from 'node:path';
|
|
41
|
+
import { basename, dirname, join } from 'node:path';
|
|
42
|
+
import { SPINE_CROSS_SUITE_BACKEND_ERRORS } from './backend_log.js';
|
|
35
43
|
import { default_test_backend_paths } from './build_test_backend_paths.js';
|
|
36
44
|
import { default_test_bootstrap_token, default_test_cookie_keys, default_test_keeper_password, default_test_keeper_username } from './default_secrets.js';
|
|
37
45
|
import { ACTION_RATE_LIMIT_ENABLED_ENV, ACTION_RATE_LIMIT_MAX_ATTEMPTS_ENV, AUDIT_SSE_KEEP_ALIVE_MS_ENV, SPINE_ACCOUNT_BOOTSTRAP_PATH, SPINE_RPC_PATH, SPINE_WS_PATH, WS_RECEIVE_TIMEOUT_MS_ENV } from './spine_surface_constants.js';
|
|
@@ -170,11 +178,31 @@ const build_default_bootstrap = (paths, overrides) => ({
|
|
|
170
178
|
daemon_token_path: paths.daemon_token_path,
|
|
171
179
|
...overrides
|
|
172
180
|
});
|
|
181
|
+
/** The `BackendConfig.log` a builder sets, or none for `log_path: null`. */
|
|
182
|
+
const to_default_backend_log = (paths, options) => {
|
|
183
|
+
const { log_path = join(paths.root, 'backend.log'), log_allow_errors = [] } = options;
|
|
184
|
+
return log_path === null
|
|
185
|
+
? {}
|
|
186
|
+
: {
|
|
187
|
+
log: {
|
|
188
|
+
path: log_path,
|
|
189
|
+
allow_errors: [...SPINE_CROSS_SUITE_BACKEND_ERRORS, ...log_allow_errors]
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* The `PUBLIC_LOG_LEVEL` a TS-family backend gets — `'warn'`, so its errors
|
|
195
|
+
* and warnings reach its output without a line per request. Set through the
|
|
196
|
+
* env, not a `Logger` level in `start_testing_server`, because fuz_util reads
|
|
197
|
+
* it as the default level of every `Logger` the binary builds, the app's own
|
|
198
|
+
* included. Override it with `extra_env`.
|
|
199
|
+
*/
|
|
200
|
+
export const TS_BACKEND_LOG_LEVEL = 'warn';
|
|
173
201
|
/**
|
|
174
202
|
* Shared builder for TS-family backends (Node + Bun). Owns the common
|
|
175
203
|
* env baseline (NODE_ENV, HOST, PORT, in-memory pglet, cookie keys,
|
|
176
|
-
* bootstrap token path) so per-backend factories only
|
|
177
|
-
* genuinely differs.
|
|
204
|
+
* bootstrap token path, `PUBLIC_LOG_LEVEL`) so per-backend factories only
|
|
205
|
+
* declare what genuinely differs.
|
|
178
206
|
*/
|
|
179
207
|
export const make_default_ts_backend_config = (opts) => {
|
|
180
208
|
const { name, port, start_command, database_url = 'memory://', extra_env, capabilities, paths = default_test_backend_paths(name), bootstrap_overrides, port_env_var = 'PORT', cookie_name = 'fuz_session', daemon_token_dir_env } = opts;
|
|
@@ -200,21 +228,26 @@ export const make_default_ts_backend_config = (opts) => {
|
|
|
200
228
|
// which boots only with the opt-in
|
|
201
229
|
FUZ_ALLOW_ORIGIN_WILDCARDS: 'true',
|
|
202
230
|
FUZ_BOOTSTRAP_TOKEN_PATH: paths.bootstrap_token_path,
|
|
231
|
+
// the spawned binary inherits `VITEST`, under which fuz_util's default
|
|
232
|
+
// log level is `'off'` — every `Logger` the binary builds would stay
|
|
233
|
+
// silent, and a backend's error logs would never reach its log file
|
|
234
|
+
PUBLIC_LOG_LEVEL: TS_BACKEND_LOG_LEVEL,
|
|
203
235
|
...daemon_token_dir_entry(daemon_token_dir_env, bootstrap),
|
|
204
236
|
...extra_env
|
|
205
237
|
},
|
|
206
238
|
bootstrap,
|
|
207
|
-
capabilities
|
|
239
|
+
capabilities,
|
|
240
|
+
...to_default_backend_log(paths, opts)
|
|
208
241
|
};
|
|
209
242
|
};
|
|
210
243
|
/**
|
|
211
244
|
* Shared builder for Rust-family backends. Owns the common env baseline
|
|
212
245
|
* (RUST_LOG, HOST, port, real Postgres, cookie keys, bootstrap token
|
|
213
|
-
* path, the `FUZ_TESTING_RESET_DB_ON_STARTUP
|
|
246
|
+
* path, the `FUZ_TESTING_RESET_DB_ON_STARTUP` self-wipe gate) plus
|
|
214
247
|
* the 120s startup window for cargo's first-run build cost.
|
|
215
248
|
*/
|
|
216
249
|
export const make_default_rust_backend_config = (opts) => {
|
|
217
|
-
const { name, port, start_command, database_url, extra_env, capabilities, paths = default_test_backend_paths(name), bootstrap_overrides, port_env_var = 'PORT', rust_log = 'info', cookie_name = 'fuz_session', daemon_token_dir_env } = opts;
|
|
250
|
+
const { name, port, start_command, database_url, extra_env, capabilities, paths = default_test_backend_paths(name), bootstrap_overrides, port_env_var = 'PORT', rust_log = 'info', cookie_name = 'fuz_session', daemon_token_dir_env, reset_db_on_startup = true } = opts;
|
|
218
251
|
const bootstrap = build_default_bootstrap(paths, bootstrap_overrides);
|
|
219
252
|
return {
|
|
220
253
|
name,
|
|
@@ -238,16 +271,18 @@ export const make_default_rust_backend_config = (opts) => {
|
|
|
238
271
|
FUZ_ALLOW_ORIGIN_WILDCARDS: 'true',
|
|
239
272
|
FUZ_BOOTSTRAP_TOKEN_PATH: paths.bootstrap_token_path,
|
|
240
273
|
// Self-wipe the auth-namespace schema before migrations on every
|
|
241
|
-
// boot. Read by the hook
|
|
242
|
-
// which the consumer's test
|
|
243
|
-
// `pre_migration_hook`, run between pool
|
|
244
|
-
// `fuz_db::run_migrations
|
|
245
|
-
//
|
|
246
|
-
|
|
274
|
+
// boot, unless the caller turns it off. Read by the hook
|
|
275
|
+
// `fuz_testing::startup_reset_hook` builds, which the consumer's test
|
|
276
|
+
// binary passes as its `pre_migration_hook`, run between pool
|
|
277
|
+
// creation and `fuz_db::run_migrations`; `'false'` is a no-op there.
|
|
278
|
+
// Always written, so an inherited value never decides. The
|
|
279
|
+
// `_testing_reset` RPC action (per-test reset) is orthogonal.
|
|
280
|
+
FUZ_TESTING_RESET_DB_ON_STARTUP: reset_db_on_startup ? 'true' : 'false',
|
|
247
281
|
...daemon_token_dir_entry(daemon_token_dir_env, bootstrap),
|
|
248
282
|
...extra_env
|
|
249
283
|
},
|
|
250
284
|
bootstrap,
|
|
251
|
-
capabilities
|
|
285
|
+
capabilities,
|
|
286
|
+
...to_default_backend_log(paths, opts)
|
|
252
287
|
};
|
|
253
288
|
};
|
|
@@ -125,7 +125,7 @@ export interface DefaultInProcessSuiteOptions {
|
|
|
125
125
|
* Output covers `{setup_test, surface_source, capabilities}` plus every
|
|
126
126
|
* factory input the Tier 1 suites read at their top level
|
|
127
127
|
* (`session_cookie_name`, `create_route_specs`, `rpc_endpoints`), and the
|
|
128
|
-
*
|
|
128
|
+
* middleware-gate suite's `base_url` (`null`, no socket) and `max_body_bytes`
|
|
129
129
|
* (`app_options.max_body_size`, `app_options.host_gate`) — so the call site spreads once and adds
|
|
130
130
|
* only suite-specific extras (`roles`, `skip_routes`, `input_overrides`,
|
|
131
131
|
* `db_factories`, ...).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in_process_setup.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/in_process_setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"in_process_setup.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/in_process_setup.ts"],"names":[],"mappings":"AA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S,CAAC,EAAE,sBAAsB,CAAC;IACnC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACjD;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C;;;OAGG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,gCAAgC,GAAI,KAAK,CAAC,CAAC,SAAS,4BAA4B,EAC5F,SAAS,CAAC,KACR;IACF,UAAU,EAAE,SAAS,CAAC;IACtB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,mBAAmB,CAAC;IAClC,mBAAmB,EAAE,CAAC,CAAC,qBAAqB,CAAC,CAAC;IAC9C,kBAAkB,EAAE,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC5C,aAAa,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC;IAClC,QAAQ,EAAE,IAAI,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CAsClC,CAAC"}
|
|
@@ -11,7 +11,7 @@ import { validate_db_invariant_exclusions } from '../db_invariant_queries.js';
|
|
|
11
11
|
import { find_rpc_action, http_transport, resolve_rpc_endpoints_for_setup } from '../rpc_helpers.js';
|
|
12
12
|
import { query_shorten_credential_expiry } from './testing_reset_actions.js';
|
|
13
13
|
import { in_process_capabilities } from './capabilities.js';
|
|
14
|
-
import { assert_credential_authenticates,
|
|
14
|
+
import { assert_credential_authenticates, EXPIRED_CREDENTIAL_SHORTEN_SECONDS, EXPIRED_CREDENTIAL_WAIT_MS, to_test_account } from './setup.js';
|
|
15
15
|
/**
|
|
16
16
|
* Wrap a Hono-style app into a `FetchTransport`-shaped object so the
|
|
17
17
|
* shared `TestFixture.transport` type holds for both in-process and
|
|
@@ -24,6 +24,22 @@ const in_process_fetch_transport = (app) => {
|
|
|
24
24
|
const transport = ((url, init) => call(url, init));
|
|
25
25
|
return Object.assign(transport, { cookies: () => [] });
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Move every session and API token row of an account back by `ms` — each
|
|
29
|
+
* timestamp the row carries, so their order holds: what the rows would read
|
|
30
|
+
* had they been written `ms` earlier. How the in-process `mint_expired_token`
|
|
31
|
+
* and `mint_expired_session` stand in for the cross-process fixture's wait.
|
|
32
|
+
*
|
|
33
|
+
* @mutates `auth_session` and `api_token` - the account's rows' timestamps
|
|
34
|
+
*/
|
|
35
|
+
const backdate_account_credentials = async (db, account_id, ms) => {
|
|
36
|
+
const shift = `($2::int4 * INTERVAL '1 millisecond')`;
|
|
37
|
+
await db.query(`UPDATE auth_session SET created_at = created_at - ${shift}, expires_at = expires_at - ${shift}
|
|
38
|
+
WHERE account_id = $1`, [account_id, ms]);
|
|
39
|
+
await db.query(`UPDATE api_token SET created_at = created_at - ${shift}, expires_at = expires_at - ${shift},
|
|
40
|
+
last_used_at = last_used_at - ${shift}
|
|
41
|
+
WHERE account_id = $1`, [account_id, ms]);
|
|
42
|
+
};
|
|
27
43
|
/**
|
|
28
44
|
* Build a `SetupTest` that creates a fresh `TestApp` per call via
|
|
29
45
|
* `create_test_app` and projects it into the `TestFixture` shape.
|
|
@@ -96,6 +112,28 @@ export const default_in_process_setup = (options) => {
|
|
|
96
112
|
const seeded_actor = await create_test_extra_actor(test_app.backend.deps.db, test_app.backend.account.id, name);
|
|
97
113
|
extra_actors.push({ id: seeded_actor.id, name: seeded_actor.name });
|
|
98
114
|
}
|
|
115
|
+
// The expired-credential mints' shared shape: a fresh account, its
|
|
116
|
+
// credential proven live, then every credential of the account pulled
|
|
117
|
+
// in with the expiry backdoor's statement — refused for the expiry alone.
|
|
118
|
+
const mint_expired_account = async (accessor, kind, credential) => {
|
|
119
|
+
const db = test_app.backend.deps.db;
|
|
120
|
+
const other = await test_app.create_account();
|
|
121
|
+
await assert_credential_authenticates({
|
|
122
|
+
transport: in_process_fetch_transport(test_app.app),
|
|
123
|
+
rpc_path: account_verify_rpc_path(accessor),
|
|
124
|
+
headers: credential(other),
|
|
125
|
+
account_id: other.account.id,
|
|
126
|
+
accessor
|
|
127
|
+
});
|
|
128
|
+
const shortened = await query_shorten_credential_expiry(db, other.account.id, EXPIRED_CREDENTIAL_SHORTEN_SECONDS);
|
|
129
|
+
if (shortened[kind] < 1)
|
|
130
|
+
throw new Error(`${accessor}: the expiry rewrote no ${kind} row`);
|
|
131
|
+
// in place of the cross-process wait: the account's credential rows
|
|
132
|
+
// moved back by it whole, as if minted, used and shortened that long
|
|
133
|
+
// ago — so `expires_at` lands past, still after `created_at`
|
|
134
|
+
await backdate_account_credentials(db, other.account.id, EXPIRED_CREDENTIAL_WAIT_MS);
|
|
135
|
+
return other;
|
|
136
|
+
};
|
|
99
137
|
const fixture = {
|
|
100
138
|
transport: in_process_fetch_transport(test_app.app),
|
|
101
139
|
// In-process the wrapper is stateless and never auto-adds Origin —
|
|
@@ -112,24 +150,18 @@ export const default_in_process_setup = (options) => {
|
|
|
112
150
|
extra_actors,
|
|
113
151
|
reject_unknown_audit_metadata_keys: options.reject_unknown_audit_metadata_keys ?? false,
|
|
114
152
|
assert_db_invariants: test_app.assert_db_invariants,
|
|
115
|
-
// Forge directly against the live backend's DB + keyring — no wire
|
|
116
|
-
// hop needed in-process.
|
|
117
153
|
mint_expired_session: async () => {
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
expires_in_seconds: EXPIRED_SESSION_OFFSET_SECONDS
|
|
123
|
-
});
|
|
124
|
-
return `${cookie_name}=${session_cookie}`;
|
|
154
|
+
const other = await mint_expired_account('mint_expired_session', 'sessions', (account) => ({
|
|
155
|
+
cookie: `${cookie_name}=${account.session_cookie}`
|
|
156
|
+
}));
|
|
157
|
+
return `${cookie_name}=${other.session_cookie}`;
|
|
125
158
|
},
|
|
126
|
-
// The session mint writes
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
// revocation or the expiry.
|
|
159
|
+
// The revoked-session mint writes its row with `mint_test_session` (a
|
|
160
|
+
// full lifetime past the database's `NOW()`); the token mints, the
|
|
161
|
+
// revocations and the expiries go through the queries the production
|
|
162
|
+
// paths (and the expiry backdoor) write with, so the rows match what
|
|
163
|
+
// the cross-process accessors leave. Each credential is proven live
|
|
164
|
+
// first, so its refusal can only be the revocation or the expiry.
|
|
133
165
|
mint_revoked_session: async () => {
|
|
134
166
|
const db = test_app.backend.deps.db;
|
|
135
167
|
const account_id = test_app.backend.account.id;
|
|
@@ -170,19 +202,9 @@ export const default_in_process_setup = (options) => {
|
|
|
170
202
|
return token;
|
|
171
203
|
},
|
|
172
204
|
mint_expired_token: async () => {
|
|
173
|
-
const other = await
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
rpc_path: account_verify_rpc_path('mint_expired_token'),
|
|
177
|
-
headers: { authorization: `Bearer ${other.api_token}` },
|
|
178
|
-
account_id: other.account.id,
|
|
179
|
-
accessor: 'mint_expired_token'
|
|
180
|
-
});
|
|
181
|
-
const shortened = await query_shorten_credential_expiry(test_app.backend.deps.db, other.account.id, EXPIRED_TOKEN_SHORTEN_SECONDS);
|
|
182
|
-
if (shortened.api_tokens < 1) {
|
|
183
|
-
throw new Error('mint_expired_token: the expiry rewrote no token row');
|
|
184
|
-
}
|
|
185
|
-
await new Promise((resolve) => setTimeout(resolve, EXPIRED_TOKEN_WAIT_MS));
|
|
205
|
+
const other = await mint_expired_account('mint_expired_token', 'api_tokens', (account) => ({
|
|
206
|
+
authorization: `Bearer ${account.api_token}`
|
|
207
|
+
}));
|
|
186
208
|
return other.api_token;
|
|
187
209
|
}
|
|
188
210
|
};
|
|
@@ -201,7 +223,7 @@ export const default_in_process_setup = (options) => {
|
|
|
201
223
|
* Output covers `{setup_test, surface_source, capabilities}` plus every
|
|
202
224
|
* factory input the Tier 1 suites read at their top level
|
|
203
225
|
* (`session_cookie_name`, `create_route_specs`, `rpc_endpoints`), and the
|
|
204
|
-
*
|
|
226
|
+
* middleware-gate suite's `base_url` (`null`, no socket) and `max_body_bytes`
|
|
205
227
|
* (`app_options.max_body_size`, `app_options.host_gate`) — so the call site spreads once and adds
|
|
206
228
|
* only suite-specific extras (`roles`, `skip_routes`, `input_overrides`,
|
|
207
229
|
* `db_factories`, ...).
|
|
@@ -11,6 +11,17 @@ import type { TestFixture } from './setup.js';
|
|
|
11
11
|
* @param body - the JSON request body
|
|
12
12
|
*/
|
|
13
13
|
export declare const cross_post_as: (fixture: TestFixture, account: TestAccount, path: string, body: unknown) => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Revoke the session `account`'s requests are sent on (`account_session_revoke`
|
|
16
|
+
* on that session), asserting it was revoked: the session list, read on the
|
|
17
|
+
* same session, names it as the current one, so the id revoked is the one the
|
|
18
|
+
* caller holds rather than a sibling's.
|
|
19
|
+
*
|
|
20
|
+
* @param fixture - the per-test fixture whose fresh transport carries the requests
|
|
21
|
+
* @param rpc_path - the RPC endpoint path
|
|
22
|
+
* @param account - the account whose session cookie authenticates both calls
|
|
23
|
+
*/
|
|
24
|
+
export declare const cross_session_revoke_current: (fixture: TestFixture, rpc_path: string, account: TestAccount) => Promise<void>;
|
|
14
25
|
/**
|
|
15
26
|
* Revoke every API token of `account_id` over the keeper's admin session
|
|
16
27
|
* (`admin_token_revoke_all`), asserting success.
|
|
@@ -36,7 +47,7 @@ export declare const cross_account_purge: (fixture: TestFixture, rpc_path: strin
|
|
|
36
47
|
* - `account` — every connection of the target account, whatever credential
|
|
37
48
|
* opened it
|
|
38
49
|
* - `session` — only the connections of the session the revocation was sent on
|
|
39
|
-
* (`TestAccount.create_session_headers`'s); the account's other sessions, its
|
|
50
|
+
* or names (`TestAccount.create_session_headers`'s); the account's other sessions, its
|
|
40
51
|
* API tokens, and the daemon token stay valid, and their connections open
|
|
41
52
|
*/
|
|
42
53
|
export type AccountRevocationCloses = 'account' | 'session';
|
|
@@ -75,7 +86,8 @@ export interface AccountRevocationsOptions {
|
|
|
75
86
|
* The revocations of a target account's credentials both transport suites
|
|
76
87
|
* drive: `admin_token_revoke_all`, `POST /password`, and `account_purge`
|
|
77
88
|
* (gated on `capabilities.account_lifecycle`) close every connection of the
|
|
78
|
-
* account; `POST /logout`
|
|
89
|
+
* account; `POST /logout` and `account_session_revoke` of the caller's own
|
|
90
|
+
* session close only the connections of the session they end.
|
|
79
91
|
*
|
|
80
92
|
* @param options - the backend's capabilities and route paths
|
|
81
93
|
* @returns the revocation rows, in a stable order
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revocation_drivers.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/revocation_drivers.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"revocation_drivers.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/revocation_drivers.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAsC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACzB,SAAS,WAAW,EACpB,SAAS,WAAW,EACpB,MAAM,MAAM,EACZ,MAAM,OAAO,KACX,OAAO,CAAC,IAAI,CAOd,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,WA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