@fuzdev/fuz_app 0.184.0 → 0.185.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 +4 -1
- 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 +38 -6
- package/dist/auth/CLAUDE.md +7 -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/cleanup.d.ts +34 -3
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +11 -3
- package/dist/http/CLAUDE.md +1 -1
- 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 +73 -41
- 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/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 +5 -1
- 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/in_process_setup.d.ts +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +1 -1
- 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/spawn_backend.d.ts +14 -0
- package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
- package/dist/testing/cross_backend/spawn_backend.js +56 -8
- 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 +33 -13
- 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 +11 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +13 -0
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_bun.js +5 -4
- 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/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/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 +69 -3
- package/dist/testing/test_app.d.ts +3 -2
- package/dist/testing/test_app.d.ts.map +1 -1
- package/dist/testing/test_app.js +5 -4
- package/package.json +1 -1
package/dist/testing/CLAUDE.md
CHANGED
|
@@ -92,6 +92,10 @@ in insert order (lists sort `created_at, id`). The in-process seed and
|
|
|
92
92
|
`query_create_actor_with_clock_timestamp`, so both spines list them alike.
|
|
93
93
|
`query_admin_account_list` is the exception: it sorts `created_at, name, id`
|
|
94
94
|
to keep one actor per account the same on both backends.
|
|
95
|
+
`_testing_reset` stamps each seeded account's session the same way
|
|
96
|
+
(`RESET_SESSION_CLOCK_STAMP_SQL`, `cross_backend/testing_reset_actions.ts`,
|
|
97
|
+
byte for byte the Rust reset's), so the seeded sessions list in seed order on
|
|
98
|
+
both spines rather than tying on one transaction's `NOW()`.
|
|
95
99
|
|
|
96
100
|
`create_test_session_row(db, token_hash, account_id, expires_in_seconds)`
|
|
97
101
|
inserts an `auth_session` row expiring that many seconds past the database's
|
|
@@ -267,9 +271,10 @@ logger. Override via `app_options`. `cleanup()` is the assembled server's idempo
|
|
|
267
271
|
limiters it built, and removes the audit listeners and closer members it
|
|
268
272
|
added.
|
|
269
273
|
|
|
270
|
-
`auth_cleanup` is
|
|
274
|
+
`auth_cleanup` is `'off'` here: a background pass would delete rows and
|
|
271
275
|
write audit rows mid-test. A suite that opts in through `app_options` has the
|
|
272
|
-
schedule stopped by `cleanup()`, which is the assembled server's `close
|
|
276
|
+
schedule stopped by `cleanup()`, which is the assembled server's `close` and
|
|
277
|
+
resolves its `ShutdownDrainGivenUp` report.
|
|
273
278
|
|
|
274
279
|
A fresh Hono app is created on every call because middleware closures bind
|
|
275
280
|
to the server's deps (db, keyring). Hono assembly is cheap;
|
|
@@ -686,7 +691,7 @@ actions and the builtin `ROLE_ADMIN` only, each factory on fresh accounts
|
|
|
686
691
|
and calling as one of them, so any consumer mounting
|
|
687
692
|
`create_standard_rpc_actions` can pass it. The fixtures run last on the
|
|
688
693
|
describe's fixture, since they mutate.
|
|
689
|
-
fuz_app wires it through the standard
|
|
694
|
+
fuz_app wires it through the `standard` suite and in the in-process
|
|
690
695
|
`cross_backend/rpc_round_trip_spine.db.test.ts`.
|
|
691
696
|
|
|
692
697
|
### `sse_round_trip.ts` — `describe_sse_route_tests`
|
|
@@ -815,35 +820,46 @@ cookies + bearer tokens. Its `describe` blocks, by theme:
|
|
|
815
820
|
9. Token revocation + cross-account isolation
|
|
816
821
|
10. Response body schema validation + error-response information leakage
|
|
817
822
|
11. Signup invite edge cases + expired credential rejection + error-coverage breadth
|
|
818
|
-
12. Middleware gates — one test per gate each counted route's error map declares (`middleware_gate_probes.ts`, below)
|
|
819
823
|
|
|
820
824
|
An `ErrorCoverageCollector` runs across groups; `afterAll` filters to
|
|
821
825
|
the routes it counts — login, logout, password, signup (when wired) and the
|
|
822
|
-
RPC path — and asserts `DEFAULT_INTEGRATION_ERROR_COVERAGE` (20%). Bootstrap is
|
|
826
|
+
RPC path (`is_standard_integration_route`, `integration_helpers.ts`) — and asserts `DEFAULT_INTEGRATION_ERROR_COVERAGE` (20%). Bootstrap is
|
|
823
827
|
excluded because no describe block in this suite drives it — its declared
|
|
824
828
|
codes would always be uncovered. Consumer-specific routes aren't exercised
|
|
825
829
|
here either — they don't count against the baseline. The declared paths are
|
|
826
830
|
the route error maps of `surface_source`, middleware included (the origin
|
|
827
831
|
check's 403, the body limit's 413 and 400, and the host gate's 403 where the
|
|
828
832
|
surface declares it), counted per (route, status, code), so
|
|
829
|
-
every error response a test asserts is recorded
|
|
830
|
-
|
|
833
|
+
every error response a test asserts is recorded. The gates' own refusals
|
|
834
|
+
(`MIDDLEWARE_GATE_ERROR_CODES`, `integration_helpers.ts`) are left out of the
|
|
835
|
+
count: `describe_middleware_gate_tests` (below) probes them. Override with
|
|
831
836
|
`error_coverage_min?: number` (set to `0` to skip the assertion — useful for
|
|
832
837
|
minimal route sets whose declared error codes outpace the suite's
|
|
833
838
|
denial-path drivers).
|
|
834
839
|
|
|
835
|
-
Options: `{setup_test, surface_source,
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
840
|
+
Options: `{setup_test, surface_source, capabilities, session_cookie_name,
|
|
841
|
+
rpc_endpoints, error_coverage_min?, check_uncovered_errors?}`; the last is
|
|
842
|
+
called with the declared paths left uncovered before the floor is asserted,
|
|
843
|
+
which fuz_app's own wirings hold to an exact set.
|
|
844
|
+
|
|
845
|
+
### `middleware_gate_probes.ts` — `describe_middleware_gate_tests`
|
|
846
|
+
|
|
847
|
+
`describe_middleware_gate_tests({setup_test, surface_source,
|
|
848
|
+
session_cookie_name, rpc_endpoints, base_url, max_body_bytes?,
|
|
849
|
+
rpc_max_body_bytes?})` — one test per gate each route the integration suite
|
|
850
|
+
counts declares, each refusal's body held to the route's map. Every gate
|
|
851
|
+
refusal (`MIDDLEWARE_GATE_ERROR_CODES`) a counted route declares must have a
|
|
852
|
+
planned probe — the unreadable length aside over a socket — or the call
|
|
853
|
+
throws at collection, so a planner that drops one fails whatever a run
|
|
854
|
+
filters or excludes. A suite of its
|
|
855
|
+
own, beside the integration suite rather than a group of it, because over a
|
|
856
|
+
socket it writes raw heads: the integration suite sends only through the
|
|
857
|
+
fixture transports, so the transcript differential can run it. `base_url` is
|
|
858
|
+
the backend's socket, `null` in-process (`default_in_process_suite_options`
|
|
859
|
+
gives `null`, and `max_body_bytes` from `app_options.max_body_size`); the caps
|
|
842
860
|
default to `SPINE_BODY_LIMIT_DEFAULT_BYTES`, the RPC endpoint's to
|
|
843
861
|
`max_body_bytes`.
|
|
844
862
|
|
|
845
|
-
### `middleware_gate_probes.ts` — the integration suite's gate probes
|
|
846
|
-
|
|
847
863
|
`plan_middleware_gate_probes({route_specs, route_error_maps, base_url,
|
|
848
864
|
max_body_bytes?, rpc_path, rpc_max_body_bytes?})` plans one
|
|
849
865
|
`MiddlewareGateProbe` per gate a route's error map declares, so a carved-out
|
|
@@ -883,7 +899,7 @@ from `db_entities.ts`.
|
|
|
883
899
|
|
|
884
900
|
Required options: `{setup_test, surface_source, session_cookie_name, rpc_endpoints: RpcEndpointsSuiteOption, roles: RoleRegistry, admin_prefix?}`.
|
|
885
901
|
|
|
886
|
-
fuz_app runs it cross-process through
|
|
902
|
+
fuz_app runs it cross-process through `standard_auth`
|
|
887
903
|
and in-process as a consumer wires it
|
|
888
904
|
(`cross_backend/admin_integration_spine.db.test.ts`) — the in-process fixture's
|
|
889
905
|
`create_account` inserts rows directly, writing no `invite_create` or `signup`
|
|
@@ -1066,15 +1082,23 @@ have files of their own.
|
|
|
1066
1082
|
backend closes the connection after an oversized-body 413. Bun 1.4.3 is the
|
|
1067
1083
|
tested floor.
|
|
1068
1084
|
|
|
1069
|
-
### `cross_backend/
|
|
1085
|
+
### `cross_backend/standard_bundle.ts` — `describe_standard_cross_process_tests`
|
|
1086
|
+
|
|
1087
|
+
Wires the standard suites that run against a spawned backend in one call, in
|
|
1088
|
+
two halves, each a registered suite of its own module:
|
|
1070
1089
|
|
|
1071
|
-
|
|
1090
|
+
- `standard_auth.ts` — `describe_standard_auth_cross_tests`: `integration`
|
|
1091
|
+
always, `admin` when `roles` is provided. Every send goes through the
|
|
1092
|
+
fixture transports, so the transcript differential runs it.
|
|
1093
|
+
- `standard.ts` — `describe_standard_cross_tests`: the middleware gates
|
|
1094
|
+
(`describe_middleware_gate_tests`), `round_trip`, `rpc_round_trip`,
|
|
1095
|
+
`data_exposure`. The gate probes write raw request heads and the round
|
|
1096
|
+
trips and data exposure build fixtures in `beforeAll`, which keeps it out of
|
|
1097
|
+
the transcript.
|
|
1072
1098
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
- `rpc_round_trip` — always
|
|
1077
|
-
- `data_exposure` — always
|
|
1099
|
+
`describe_spine_cross_suites` registers the halves apart (`standard_auth`,
|
|
1100
|
+
`standard`); the bundle is for a consumer wiring them outside it, and
|
|
1101
|
+
`STANDALONE_CROSS_SUITES` names it.
|
|
1078
1102
|
|
|
1079
1103
|
Two in-process suites are omitted by design: `rate_limiting` (needs a fresh
|
|
1080
1104
|
per-test `TestApp` for tight rate-limiter overrides; the spawned binary has no
|
|
@@ -1083,9 +1107,8 @@ the in-process backend exposes; wire-level audit observability lives in the
|
|
|
1083
1107
|
consumer's own audit `.cross.test.ts`). The omission rationale lives in the
|
|
1084
1108
|
module doc once instead of repeating in each consumer's `*.cross.test.ts`.
|
|
1085
1109
|
|
|
1086
|
-
`base_url` (required — the
|
|
1087
|
-
|
|
1088
|
-
integration suite;
|
|
1110
|
+
`base_url` (required — the middleware-gate probes write to the socket),
|
|
1111
|
+
`max_body_bytes` and `rpc_max_body_bytes` forward to the gate suite;
|
|
1089
1112
|
`rpc_success_fixtures`, `rpc_skip_methods` and `rpc_input_overrides`
|
|
1090
1113
|
forward to the RPC round-trip's `success_fixtures`, `skip_methods` and
|
|
1091
1114
|
`input_overrides` (`describe_spine_cross_suites` also forwards
|
|
@@ -1096,9 +1119,10 @@ round-trip and data exposure, the two that resolve route paths.
|
|
|
1096
1119
|
|
|
1097
1120
|
Hard-codes the cross-process-safe set with no `skip` knob; if a future
|
|
1098
1121
|
consumer needs partial opt-out, add the knob then.
|
|
1099
|
-
`StandardCrossProcessTestOptions` is
|
|
1100
|
-
|
|
1101
|
-
|
|
1122
|
+
`StandardCrossProcessTestOptions` is both halves' options
|
|
1123
|
+
(`StandardAuthCrossTestOptions`, `StandardCrossTestOptions`): the in-process
|
|
1124
|
+
suites' shared options minus their in-process-only knobs
|
|
1125
|
+
(`create_route_specs`, `rate_limiting_app_options`).
|
|
1102
1126
|
|
|
1103
1127
|
### `cross_backend/spine_suites.ts` — `describe_spine_cross_suites`
|
|
1104
1128
|
|
|
@@ -1109,7 +1133,7 @@ exclude_cases?, expected_skips?, overrides?, suite_roles?, ws_required_roles?, r
|
|
|
1109
1133
|
rpc_skip_methods?, rpc_input_overrides?, rpc_max_body_bytes?, ws_max_message_bytes?})`.
|
|
1110
1134
|
`live_rpc_endpoints` is the backend's whole live mount; given, `rpc_adversarial`
|
|
1111
1135
|
also walks the methods it keeps off the declared surface. `rpc_input_overrides`
|
|
1112
|
-
reaches the standard
|
|
1136
|
+
reaches the `standard` suite's RPC round-trip and `rpc_adversarial`'s
|
|
1113
1137
|
`input_overrides`, so one valid body per method serves both; a key naming a
|
|
1114
1138
|
method on neither the declared surface nor `live_rpc_endpoints` throws at
|
|
1115
1139
|
collection. Without it a consumer writes a file per suite, and a suite added
|
|
@@ -1117,12 +1141,14 @@ here never reaches it.
|
|
|
1117
1141
|
|
|
1118
1142
|
- **The registry.** `SUITE_NAMES` / `SuiteName` — the closed set of suites the
|
|
1119
1143
|
call runs, each named by its module (`ws_round_trip` is
|
|
1120
|
-
`describe_cross_process_ws_tests
|
|
1144
|
+
`describe_cross_process_ws_tests`; `standard_auth` and `standard` the two
|
|
1145
|
+
halves of the standard bundle).
|
|
1121
1146
|
`STANDALONE_CROSS_SUITES` (keyed by the closed `StandaloneSuiteName`) names
|
|
1122
1147
|
the modules left out, each with why: the
|
|
1123
1148
|
`differential` (two handles), `login_security` and `ws_action_rate_limit`
|
|
1124
1149
|
(a backend spawned with live limiters, which the standard suites would
|
|
1125
|
-
exhaust),
|
|
1150
|
+
exhaust), the `conformance_table` runner (the consumer's own cases), and
|
|
1151
|
+
`standard_bundle` (the two standard halves in one call).
|
|
1126
1152
|
`src/test/testing/cross_backend/spine_suites.test.ts` imports every module
|
|
1127
1153
|
under `cross_backend/` and holds the two lists to the ones exporting a
|
|
1128
1154
|
`describe_*` function, whatever the export form (the Bun adapter,
|
|
@@ -1138,7 +1164,7 @@ here never reaches it.
|
|
|
1138
1164
|
called on its own — the daemon token from the handle, and each suite's
|
|
1139
1165
|
`setup_test` from `default_cross_process_setup` over the `setup` options
|
|
1140
1166
|
plus the seeding the suite needs (concatenated): a keeper-only
|
|
1141
|
-
`non_admin_keeper` for
|
|
1167
|
+
`non_admin_keeper` for `standard_auth`'s keeper ≠ admin probe, the
|
|
1142
1168
|
multi-actor keepers of `fact_serving` and `transport_composition`, the
|
|
1143
1169
|
offer grantor of `role_grant_offer_enumeration`, the `cell_editor` holder of
|
|
1144
1170
|
`cell_grant_role`. Suites are registered without a wrapping `describe`, so
|
|
@@ -1154,7 +1180,7 @@ here never reaches it.
|
|
|
1154
1180
|
aren't the spine defaults (`SPINE_BODY_LIMIT_DEFAULT_BYTES`,
|
|
1155
1181
|
`DEFAULT_WS_MAX_MESSAGE_BYTES`). The first reaches `body_size`,
|
|
1156
1182
|
`body_size_smuggling`, `transport_composition`'s RPC over-cap row and the
|
|
1157
|
-
standard
|
|
1183
|
+
`standard` suite's middleware-gate probes of the RPC endpoint (each
|
|
1158
1184
|
takes it as `rpc_max_body_bytes`), the second `ws_round_trip`'s
|
|
1159
1185
|
`max_message_bytes` — one value per limit for every suite probing it.
|
|
1160
1186
|
- **`exclude`** — `{[suite]: reason}`; the reason is required and shows in the
|
|
@@ -1317,8 +1343,7 @@ fixture). fuz_app's own case files and wiring are
|
|
|
1317
1343
|
### Suite modules
|
|
1318
1344
|
|
|
1319
1345
|
Each `SUITE_NAMES` module in `cross_backend/` exports one
|
|
1320
|
-
`describe_<module>_cross_tests(options)`. The exceptions are `
|
|
1321
|
-
(`describe_standard_cross_process_tests`), `ws_round_trip`
|
|
1346
|
+
`describe_<module>_cross_tests(options)`. The exceptions are `ws_round_trip`
|
|
1322
1347
|
(`describe_cross_process_ws_tests`), `sse_round_trip`
|
|
1323
1348
|
(`describe_cross_process_sse_tests`), `peer_ping_ws`
|
|
1324
1349
|
(`describe_peer_ping_ws_tests`) and `role_grant_offer_notification_ws`
|
|
@@ -1375,7 +1400,8 @@ without.
|
|
|
1375
1400
|
| `session_cookie_codec` | exactly one accepted spelling of a signed cookie: non-canonical signature or `expires_at` spellings refused | — |
|
|
1376
1401
|
| `simple_request` | an untyped, CORS-safelisted, or non-JSON `POST` to a JSON route → 415 `unsupported_content_type` | — |
|
|
1377
1402
|
| `sse_round_trip` | the audit stream: connect, a data frame, a close on each revocation of a stream proven admitted, a session-scoped revoke leaving a sibling session's stream open, a revoke of the gating role's global grant closing the stream and a global revoke of another role leaving it open (scope matching is `ws_role_gated`'s), the per-session stream cap | `sse` (delete and purge also `account_lifecycle`) |
|
|
1378
|
-
| `standard` | the
|
|
1403
|
+
| `standard` | the standard bundle less its auth suites: the middleware-gate probes of each counted route, round trip, RPC round trip, data exposure | — |
|
|
1404
|
+
| `standard_auth` | the standard auth suites: integration, and admin when `roles` is given; run by the transcript differential | `account_status` (the status wire-shape case) |
|
|
1379
1405
|
| `testing_backdoor` | the backdoor declaration, and every declared `_testing_*` action refusing anonymous, session, and bearer callers | `testing_backdoors` (the declaration) |
|
|
1380
1406
|
| `token_lifetime` | the API token `lifetime` round trip: ttl mint → `expires_at` on create and list, an eternal control, bad lifetimes → 400, a bearer beside a winning daemon token or a winning session never touched, the request acting as the winner's account; an invalid daemon token falls through to the bearer beside it | — |
|
|
1381
1407
|
| `token_scope_surface` | the `surface:<name>` half of token scoping: a narrowed bearer refused the audit stream and the bare-hash fact read, anonymous on the status read; scope outranks role | `sse`, `fact_serving_admin_hash`, `account_status` (per case) |
|
|
@@ -1526,7 +1552,7 @@ Conventions that hold across them:
|
|
|
1526
1552
|
(`ensure_database_for_url`), then the spawn. A second argument
|
|
1527
1553
|
(`CrossBackendGlobalSetupDeps`) swaps the database creator and the spawn,
|
|
1528
1554
|
for testing the setup itself.
|
|
1529
|
-
- `testing/cross_backend/bootstrap_backend.ts` / `create_dual_spawn_global_setup.ts` — spawn and bootstrap one backend, or two (`provide_keys`); `before_bootstrap(config)` runs once the backend is healthy and before its keeper bootstrap, for a probe of the pre-bootstrap window, and a throw from it tears the backend down and fails the setup.
|
|
1555
|
+
- `testing/cross_backend/bootstrap_backend.ts` / `create_dual_spawn_global_setup.ts` — spawn and bootstrap one backend, or two (`provide_keys`); `before_bootstrap(config)` runs once the backend is healthy and before its keeper bootstrap, for a probe of the pre-bootstrap window, and a throw from it tears the backend down and fails the setup. The dual spawn's `after_bootstrap(handle, side)` runs once a backend's bootstrap has succeeded, before any test, for a read of what the bootstrap wrote; a throw tears down every backend spawned so far.
|
|
1530
1556
|
- `testing/cross_backend/cargo_binary.ts` — `prepare_cargo_binary({workspace_dir,
|
|
1531
1557
|
package, bin?, profile?})` builds a Cargo binary (`cargo build -p --bin
|
|
1532
1558
|
--profile`, output inherited, a failed build throws) unless
|
|
@@ -1565,7 +1591,13 @@ Conventions that hold across them:
|
|
|
1565
1591
|
(`create_output_tail`) for an early exit's error — with its exit code or
|
|
1566
1592
|
signal — and for the log line an unexpected exit after startup writes.
|
|
1567
1593
|
Registers exit-time + signal cleanup so vitest worker death or
|
|
1568
|
-
Ctrl+C kills children before they strand ports.
|
|
1594
|
+
Ctrl+C kills children before they strand ports. `teardown` rejects unless
|
|
1595
|
+
the child exits `0` on its SIGTERM — a non-zero code (a spine whose
|
|
1596
|
+
shutdown gave up or failed), an exit by signal (the SIGKILL escalation), an
|
|
1597
|
+
exit during the run, or a group teardown gave up on — naming the backend,
|
|
1598
|
+
the exit and the stderr tail, so every global setup that awaits it fails
|
|
1599
|
+
the run on an unclean shutdown; the dual-spawn setup tears both down before
|
|
1600
|
+
it throws.
|
|
1569
1601
|
- `testing/transports/fetch_transport.ts` — cookie-threading HTTP transport
|
|
1570
1602
|
satisfying `RpcTestTransport`. Carries a name-keyed cookie jar that
|
|
1571
1603
|
updates on every response's `Set-Cookie` and re-sends on every request;
|
|
@@ -1757,7 +1789,7 @@ The reusable shape for standing up a **spawnable TS** cross-process test
|
|
|
1757
1789
|
binary (the TS analog of the Rust `testing_spine_stub`), so consumers don't
|
|
1758
1790
|
re-roll the serve / daemon-info / drain boilerplate:
|
|
1759
1791
|
|
|
1760
|
-
- `testing/cross_backend/testing_server_core.ts` — `start_testing_server({adapter, daemon_name, host, port, app_version?, build_app})`. Owns the runtime-neutral orchestration: open-host refusal, stale-daemon check, daemon-info write, `serve`, graceful shutdown. Domain-free — the app is the caller's `build_app(context: BuildTestingAppContext): Promise<BuiltTestingApp>` seam (`{app, close}`). WebSocket endpoints mount through `create_app_server`'s `ws_endpoints` on every runtime: the build calls `context.prepare_websocket({max_message_bytes?})`, which has the adapter prepare its WebSocket support for `serve` and returns the runtime's `upgradeWebSocket`, to pass as `upgrade_websocket`. Shutdown starts the listener's `shutdown` (stop accepting), runs `close` — which must end live WebSockets, as `AppServer.close` does — then awaits the drain, since open sockets would otherwise hold it. Exports the `TestingServerAdapter` (`prepare_websocket: (options?: PrepareWebsocketOptions) => UpgradeWebSocket`) / `ServeHandle` / `PrepareWebsocketOptions` / `BuildTestingAppContext` interfaces.
|
|
1792
|
+
- `testing/cross_backend/testing_server_core.ts` — `start_testing_server({adapter, daemon_name, host, port, app_version?, build_app})`. Owns the runtime-neutral orchestration: open-host refusal, stale-daemon check, daemon-info write, `serve`, graceful shutdown. Domain-free — the app is the caller's `build_app(context: BuildTestingAppContext): Promise<BuiltTestingApp>` seam (`{app, close}`). WebSocket endpoints mount through `create_app_server`'s `ws_endpoints` on every runtime: the build calls `context.prepare_websocket({max_message_bytes?})`, which has the adapter prepare its WebSocket support for `serve` and returns the runtime's `upgradeWebSocket`, to pass as `upgrade_websocket`. Shutdown starts the listener's `shutdown` (stop accepting), runs `close` — which must end live WebSockets, as `AppServer.close` does, and resolve its `ShutdownDrainGivenUp` report — then, on a clean close, awaits the drain, since open sockets would otherwise hold it, and exits `0`; it exits `1` without that wait when the report gave up on anything (`shutdown_gave_up`) — a given-up request still holds its connection — or the close threw, twin of the Rust spine's `StartupError::ShutdownGivenUp`. On `pg` a give-up's `close` can still wait on `pool.end()` for a client a wedged handler holds; the harness defaults to pglet and PGlite. Exports the `TestingServerAdapter` (`prepare_websocket: (options?: PrepareWebsocketOptions) => UpgradeWebSocket`) / `ServeHandle` / `PrepareWebsocketOptions` / `BuildTestingAppContext` interfaces.
|
|
1761
1793
|
- `testing/daemon_info.ts` — the `~/.{name}/run/daemon.json` plumbing the core's stale-daemon check and daemon-info write use: `DaemonInfo` (a strict `@fuzdev/fuz_schema` object), `get_app_dir`, `get_daemon_info_path`, `write_daemon_info` (atomic), `read_daemon_info`, `is_daemon_running` (`probe_process`, signal 0 with no program spawned; another user's process or a pid naming no single process reads as not running).
|
|
1762
1794
|
- `testing/cross_backend/testing_server_node.ts` — `create_node_testing_adapter()` (`@hono/node-server`'s `serve` and module-level `upgradeWebSocket`, over a `ws` `WebSocketServer`). Optional peer deps; only test binaries import them. `prepare_websocket` builds the `ws` server (`noServer: true`) with `maxPayload` at twice `max_message_bytes` (default `DEFAULT_WS_MAX_MESSAGE_BYTES`; `ws`'s own default is 100 MiB), and `serve` hands it to `@hono/node-server`, so a grossly oversized message is refused at the frame layer (`WS_CLOSE_MESSAGE_TOO_BIG` with no reason) before it is buffered whole, while one just over the limit reaches the per-message check, which sends `WS_CLOSE_MESSAGE_TOO_BIG_REASON` as every other backend does. Bun's adapter sets the same multiple as its frame cap (see below).
|
|
1763
1795
|
- `testing/cross_backend/testing_server_bun.ts` — `create_bun_testing_adapter()` (`Bun.serve` + `@hono/bun`'s module-level `getConnInfo`, `upgradeWebSocket`, and `websocket`; `Bun.serve` declared locally so it typechecks under the Node toolchain). Needs the optional `@hono/bun` peer dep (the counterpart to Node's `@hono/node-server` + `ws`; `Bun.serve` is built in). Reuses `create_node_runtime` (Bun implements the `node:fs`/`node:process` surface). WS is module-level + stateless — the `websocket` handler is threaded into `serve`, where `Bun.serve` wants it. It carries `maxPayloadLength` at twice `max_message_bytes` rather than Bun's 16 MiB default: past its cap Bun drops the socket without a close frame (1006), so the headroom leaves a message just over the limit to the per-message check (`WS_CLOSE_MESSAGE_TOO_BIG`, as on Node), while a grossly oversized one is refused before Bun buffers it whole.
|
|
@@ -30,7 +30,7 @@ export interface StandardAdminIntegrationTestOptions {
|
|
|
30
30
|
rpc_endpoints: RpcEndpointsSuiteOption;
|
|
31
31
|
/**
|
|
32
32
|
* Path prefix where admin routes are mounted (e.g., `'/api/admin'`).
|
|
33
|
-
* Used by the 401
|
|
33
|
+
* Used by the 401 error-coverage probe to scope to fuz_app admin
|
|
34
34
|
* routes only, avoiding app-specific admin-gated routes that may use
|
|
35
35
|
* stub deps. Default `'/api/admin'`.
|
|
36
36
|
*/
|
|
@@ -41,7 +41,7 @@ export interface StandardAdminIntegrationTestOptions {
|
|
|
41
41
|
*
|
|
42
42
|
* Exercises account listing, role_grant grant/revoke (via RPC), session
|
|
43
43
|
* management, token management, audit log reads, admin-to-admin
|
|
44
|
-
* isolation, and 401
|
|
44
|
+
* isolation, and 401 error-coverage on the admin REST surface.
|
|
45
45
|
* Output-schema conformance is not in scope — see the module docstring
|
|
46
46
|
* for the suites that cover it.
|
|
47
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin_integration.d.ts","sourceRoot":"","sources":["../../src/lib/testing/admin_integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"admin_integration.d.ts","sourceRoot":"","sources":["../../src/lib/testing/admin_integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiC7B,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAYvE,OAAO,EAMN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AA4B1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAC;AAavE;;GAEG;AACH,MAAM,WAAW,mCAAmC;IACnD;;;;OAIG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,+GAA+G;IAC/G,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yGAAyG;IACzG,KAAK,EAAE,YAAY,CAAC;IACpB;;;OAGG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAiBD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yCAAyC,GACrD,SAAS,mCAAmC,KAC1C,IAg/BF,CAAC"}
|
|
@@ -26,6 +26,7 @@ import './assert_dev_env.js';
|
|
|
26
26
|
* @module
|
|
27
27
|
*/
|
|
28
28
|
import { describe, test, assert, afterAll } from 'vitest';
|
|
29
|
+
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
29
30
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
30
31
|
import { GRANT_PATH_ADMIN } from '../auth/grant_path_schema.js';
|
|
31
32
|
import { create_test_request_headers } from './test_origin.js';
|
|
@@ -65,7 +66,7 @@ const pick_grantable_role = (role_specs) => {
|
|
|
65
66
|
*
|
|
66
67
|
* Exercises account listing, role_grant grant/revoke (via RPC), session
|
|
67
68
|
* management, token management, audit log reads, admin-to-admin
|
|
68
|
-
* isolation, and 401
|
|
69
|
+
* isolation, and 401 error-coverage on the admin REST surface.
|
|
69
70
|
* Output-schema conformance is not in scope — see the module docstring
|
|
70
71
|
* for the suites that cover it.
|
|
71
72
|
*
|
|
@@ -852,27 +853,42 @@ export const describe_standard_admin_integration_tests = (options) => {
|
|
|
852
853
|
});
|
|
853
854
|
});
|
|
854
855
|
// --- 8a. Error coverage: unauthenticated access to admin routes ---
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
856
|
+
// `/api/admin` is nearly empty — admin reads and mutations live
|
|
857
|
+
// on the RPC endpoint behind spec-level role auth. The path-prefix carve is still the right scope here
|
|
858
|
+
// because error coverage is tracked against REST `RouteSpec`s,
|
|
859
|
+
// not RPC method specs (`describe_rpc_round_trip_tests` covers
|
|
860
|
+
// the admin RPC surface separately).
|
|
861
|
+
const prefix = options.admin_prefix ?? '/api/admin';
|
|
862
|
+
const admin_routes = route_specs.filter((s) => s.path.startsWith(prefix) &&
|
|
863
|
+
(s.auth.roles?.includes('admin') ?? false) &&
|
|
864
|
+
// params and query validate ahead of the 401 (the route pipeline's
|
|
865
|
+
// order), so a route is driven only when the bare request passes them:
|
|
866
|
+
// no params, and a query that takes none (the audit stream's optional
|
|
867
|
+
// `acting`)
|
|
868
|
+
!s.params &&
|
|
869
|
+
(!s.query || parse(s.query, {}).ok));
|
|
870
|
+
// registered only where such routes exist, the describe too (an empty one
|
|
871
|
+
// fails the run): a plain skip would leave the transcript differential's
|
|
872
|
+
// run partial (its stale-ledger check unjudged), and a gated one would owe
|
|
873
|
+
// every consumer an `expected_skips` entry
|
|
874
|
+
if (admin_routes.length > 0) {
|
|
875
|
+
describe('error coverage breadth', () => {
|
|
876
|
+
test('exercises 401 on admin routes for error coverage', async () => {
|
|
877
|
+
const fixture = await options.setup_test();
|
|
878
|
+
// Hit admin routes without auth to exercise 401 error schemas — a
|
|
879
|
+
// fresh transport, since the fixture's carries the keeper's cookie
|
|
880
|
+
const transport = fixture.fresh_transport();
|
|
881
|
+
for (const route of admin_routes) {
|
|
882
|
+
const res = await transport(route.path, {
|
|
883
|
+
method: route.method,
|
|
884
|
+
headers: { host: 'localhost', 'content-type': to_route_content_type(route) }
|
|
885
|
+
});
|
|
886
|
+
// no credential: every admin route answers 401 before authorization
|
|
887
|
+
assert.strictEqual(res.status, 401, `${route.method} ${route.path}`);
|
|
872
888
|
await error_collector.assert_and_record(route_specs, route.method, route.path, res);
|
|
873
889
|
}
|
|
874
|
-
}
|
|
890
|
+
});
|
|
875
891
|
});
|
|
876
|
-
}
|
|
892
|
+
}
|
|
877
893
|
});
|
|
878
894
|
};
|
|
@@ -19,7 +19,9 @@ import '../assert_dev_env.js';
|
|
|
19
19
|
*
|
|
20
20
|
* If `bootstrap()` throws — typically a bad token, port collision, or
|
|
21
21
|
* keeper-username mismatch — the spawned binary is torn down before the
|
|
22
|
-
* error propagates so vitest doesn't strand the port.
|
|
22
|
+
* error propagates so vitest doesn't strand the port. The returned handle's
|
|
23
|
+
* `teardown` rejects unless the binary exits `0` (`BackendHandle.teardown`),
|
|
24
|
+
* so a global setup that awaits it fails the run on an unclean shutdown.
|
|
23
25
|
*
|
|
24
26
|
* @module
|
|
25
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap_backend.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/bootstrap_backend.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B
|
|
1
|
+
{"version":3,"file":"bootstrap_backend.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/bootstrap_backend.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,uCAAuC;AACvC,MAAM,WAAW,uBAAuB;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrE;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAC7B,QAAQ,aAAa,EACrB,UAAU,uBAAuB,KAC/B,OAAO,CAAC,yBAAyB,CA6BnC,CAAC"}
|
|
@@ -37,7 +37,11 @@ export const bootstrap_backend = async (config, options) => {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
catch (err) {
|
|
40
|
-
|
|
40
|
+
// the bootstrap's error is the report; a teardown that also failed is
|
|
41
|
+
// logged beside it rather than replacing it
|
|
42
|
+
await handle.teardown().catch((teardown_error) => {
|
|
43
|
+
console.error(teardown_error);
|
|
44
|
+
});
|
|
41
45
|
throw err;
|
|
42
46
|
}
|
|
43
47
|
};
|
|
@@ -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
|
+
};
|
|
@@ -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`, ...).
|
|
@@ -201,7 +201,7 @@ export const default_in_process_setup = (options) => {
|
|
|
201
201
|
* Output covers `{setup_test, surface_source, capabilities}` plus every
|
|
202
202
|
* factory input the Tier 1 suites read at their top level
|
|
203
203
|
* (`session_cookie_name`, `create_route_specs`, `rpc_endpoints`), and the
|
|
204
|
-
*
|
|
204
|
+
* middleware-gate suite's `base_url` (`null`, no socket) and `max_body_bytes`
|
|
205
205
|
* (`app_options.max_body_size`, `app_options.host_gate`) — so the call site spreads once and adds
|
|
206
206
|
* only suite-specific extras (`roles`, `skip_routes`, `input_overrides`,
|
|
207
207
|
* `db_factories`, ...).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc_success_fixtures.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/rpc_success_fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc_success_fixtures.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/rpc_success_fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAsC9B,OAAO,KAAK,EAAqB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAOlF,uDAAuD;AACvD,MAAM,WAAW,8BAA8B;IAC9C,gGAAgG;IAChG,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iCAAiC,GAC7C,UAAS,8BAAmC,KAC1C,kBAwHF,CAAC"}
|
|
@@ -12,7 +12,8 @@ import '../assert_dev_env.js';
|
|
|
12
12
|
*
|
|
13
13
|
* Spine-generic: the fixtures use only standard RPC actions and the builtin
|
|
14
14
|
* `ROLE_ADMIN`, so any consumer mounting `create_standard_rpc_actions` can
|
|
15
|
-
* pass the map to `
|
|
15
|
+
* pass the map to `describe_spine_cross_suites` or
|
|
16
|
+
* `describe_standard_cross_process_tests` (as
|
|
16
17
|
* `rpc_success_fixtures`) or `describe_rpc_round_trip_tests` (as
|
|
17
18
|
* `success_fixtures`). Each fixture mints
|
|
18
19
|
* its own accounts and calls as one of them, so none touches or calls as the
|
|
@@ -30,6 +30,13 @@ import '../assert_dev_env.js';
|
|
|
30
30
|
* a startup failure reports it with the exit code or signal, and an exit
|
|
31
31
|
* after startup that teardown didn't cause is logged with it.
|
|
32
32
|
*
|
|
33
|
+
* Teardown holds the backend to a clean exit: a spine whose graceful
|
|
34
|
+
* shutdown gave up on work still running, or threw, exits `1` (the TS core's
|
|
35
|
+
* `start_testing_server`, the Rust spine's `StartupError::ShutdownGivenUp`),
|
|
36
|
+
* and `teardown` rejects on anything but exit code `0` — naming the backend,
|
|
37
|
+
* its exit code or signal, and its stderr tail — as it does for a backend
|
|
38
|
+
* that exited during the run or had to be killed.
|
|
39
|
+
*
|
|
33
40
|
* Bootstrapping (`POST /api/account/bootstrap`) is a separate concern —
|
|
34
41
|
* the caller composes `bootstrap()` from `testing/transports/bootstrap.ts`
|
|
35
42
|
* against a `FetchTransport` built around `handle.config.base_url`.
|
|
@@ -59,6 +66,13 @@ export interface BackendHandle {
|
|
|
59
66
|
* escalating to SIGKILL after a grace window. Idempotent — later calls
|
|
60
67
|
* await the same exit. A descendant that left the group — spawned detached,
|
|
61
68
|
* or one that called `setsid` — is out of reach and survives teardown.
|
|
69
|
+
*
|
|
70
|
+
* Rejects unless the child exited `0` on the SIGTERM: an exit code other
|
|
71
|
+
* than `0` (a shutdown that gave up or failed), an exit by signal (the
|
|
72
|
+
* SIGKILL escalation among them), an exit before teardown (already
|
|
73
|
+
* logged when it happened), or a group still running when teardown gave
|
|
74
|
+
* up. The error names the backend and the exit, with the stderr tail. The
|
|
75
|
+
* group is torn down either way.
|
|
62
76
|
*/
|
|
63
77
|
readonly teardown: () => Promise<void>;
|
|
64
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn_backend.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/spawn_backend.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B
|
|
1
|
+
{"version":3,"file":"spawn_backend.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/spawn_backend.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAK9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC7B,yFAAyF;IACzF,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAgBD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAY,CAAC;AAmE/C;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CAenE,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE,MAAM,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,UAmBtD,CAAC;AA8FF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAU,QAAQ,aAAa,KAAG,OAAO,CAAC,aAAa,CA2OhF,CAAC"}
|