@fuzdev/fuz_app 0.183.0 → 0.184.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 +535 -1223
- package/dist/actions/action_codegen.d.ts +1 -1
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +3 -2
- package/dist/actions/connection_closer.d.ts +11 -9
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +11 -9
- package/dist/actions/frontend_rpc_client.d.ts +1 -1
- package/dist/actions/register_action_ws.d.ts +14 -1
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +2 -1
- package/dist/actions/ws_socket_session.d.ts +9 -1
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +43 -19
- package/dist/auth/CLAUDE.md +430 -1048
- package/dist/auth/account_queries.d.ts +1 -1
- package/dist/auth/account_queries.js +1 -1
- package/dist/auth/account_routes.d.ts +4 -5
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +8 -10
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +10 -11
- package/dist/auth/api_token.d.ts +20 -3
- package/dist/auth/api_token.d.ts.map +1 -1
- package/dist/auth/api_token.js +28 -9
- package/dist/auth/api_token_queries.d.ts +2 -2
- package/dist/auth/api_token_queries.js +2 -2
- package/dist/auth/audit_log_schema.d.ts +15 -9
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +1 -2
- package/dist/auth/auth_guard_resolver.d.ts +1 -1
- package/dist/auth/auth_guard_resolver.js +1 -1
- package/dist/auth/bearer_auth.d.ts +2 -5
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +4 -13
- package/dist/auth/bootstrap_account.d.ts +13 -15
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +9 -11
- package/dist/auth/bootstrap_routes.d.ts +20 -21
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +21 -19
- package/dist/auth/bootstrap_token_store.d.ts +3 -4
- package/dist/auth/bootstrap_token_store.d.ts.map +1 -1
- package/dist/auth/bootstrap_token_store.js +1 -1
- package/dist/auth/daemon_token.d.ts +5 -1
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.d.ts +12 -8
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +15 -21
- package/dist/auth/deps.d.ts +11 -0
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/invite_queries.d.ts +51 -3
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +81 -6
- package/dist/auth/invite_schema.d.ts +2 -1
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/middleware.d.ts +2 -3
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +3 -3
- package/dist/auth/request_context.d.ts +3 -3
- package/dist/auth/request_context.js +3 -3
- package/dist/auth/role_grant_offer_actions.d.ts +2 -2
- package/dist/auth/role_grant_offer_actions.js +2 -2
- package/dist/auth/session_cookie.d.ts +82 -174
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +80 -130
- package/dist/auth/session_middleware.d.ts +8 -17
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +14 -23
- package/dist/auth/session_queries.d.ts +9 -14
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +8 -9
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +4 -6
- package/dist/db/CLAUDE.md +5 -3
- package/dist/dev/setup.d.ts +3 -1
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +3 -1
- package/dist/http/CLAUDE.md +315 -768
- package/dist/http/db_routes.d.ts +1 -1
- package/dist/http/db_routes.js +1 -1
- package/dist/http/origin.d.ts +7 -8
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +7 -8
- package/dist/http/pending_effects.d.ts +78 -4
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +82 -4
- package/dist/http/route_result.d.ts +1 -1
- package/dist/http/route_spec.d.ts +14 -11
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/realtime/sse.d.ts +4 -23
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +4 -25
- package/dist/server/app_backend.d.ts +4 -5
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +3 -1
- package/dist/server/app_server.d.ts +53 -30
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +81 -53
- package/dist/server/app_server_context.d.ts +1 -2
- package/dist/server/app_server_context.d.ts.map +1 -1
- package/dist/server/env.js +2 -2
- package/dist/testing/CLAUDE.md +17 -17
- package/dist/testing/admin_integration.d.ts +2 -3
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +3 -3
- package/dist/testing/app_server.d.ts +3 -8
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +10 -9
- package/dist/testing/attack_surface.d.ts +1 -1
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/audit_completeness.d.ts +2 -3
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +1 -1
- package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -1
- package/dist/testing/cross_backend/capability_mounts.js +16 -11
- package/dist/testing/cross_backend/conformance_table.d.ts +5 -6
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +4 -4
- package/dist/testing/cross_backend/cookie_attributes.js +1 -1
- package/dist/testing/cross_backend/default_backend_configs.d.ts +3 -3
- package/dist/testing/cross_backend/default_spine_surface.d.ts +0 -6
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +4 -9
- package/dist/testing/cross_backend/differential.d.ts +2 -3
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +1 -1
- package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -42
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +45 -4
- package/dist/testing/cross_backend/in_process_setup.d.ts +6 -7
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +9 -12
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -4
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +2 -2
- package/dist/testing/cross_backend/setup.d.ts +1 -1
- package/dist/testing/cross_backend/spine_suites.d.ts +2 -3
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +5 -5
- package/dist/testing/cross_backend/standard.d.ts +2 -3
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.js +3 -3
- package/dist/testing/cross_backend/testing_credential_read.d.ts +10 -11
- package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_credential_read.js +12 -12
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +35 -30
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +39 -31
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +2 -3
- package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
- package/dist/testing/daemon_token_rotation.js +2 -3
- package/dist/testing/integration.d.ts +2 -3
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +4 -4
- package/dist/testing/rate_limiting.d.ts +2 -3
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +3 -3
- package/dist/testing/rpc_helpers.d.ts +1 -2
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +3 -3
- package/dist/testing/rpc_round_trip.d.ts +2 -3
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +1 -1
- package/dist/testing/sse_round_trip.d.ts +2 -3
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/stubs.d.ts +5 -6
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +10 -8
- package/dist/testing/test_app.d.ts +5 -3
- package/dist/testing/test_app.d.ts.map +1 -1
- package/dist/testing/test_app.js +2 -3
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +3 -0
- package/dist/ui/ui_format.d.ts.map +1 -1
- package/dist/ui/ui_format.js +1 -2
- package/package.json +1 -1
package/dist/testing/CLAUDE.md
CHANGED
|
@@ -33,12 +33,12 @@ time (never runtime), where a throwing guard would break `vite build`.
|
|
|
33
33
|
- `stub_handler()` — a `route_raw` text answer (`stub`), a handler that fits any route (`attach_route_handler(shape, stub_handler)`).
|
|
34
34
|
- `stub_route_spec(shape)` — a spec for a surface that is described and never served: `shape` with a handler that throws when run (the spine routes of `create_rust_spine_consumer_surface_spec`).
|
|
35
35
|
- `stub_mw` — pass-through middleware (`async (_c, next) => next()`).
|
|
36
|
-
- `create_stub_app_deps()` — factory: fresh `AppDeps` with a stub keyring (`sign` answers `<value>.stub_signature`, so
|
|
36
|
+
- `create_stub_app_deps()` — factory: fresh `AppDeps` with a stub keyring (`sign` answers `<value>.stub_signature`, so a session cookie signed on stub deps is a line; nothing else of it does anything), no-op password, a `create_noop_stub` DB, silent `Logger`, no-op `audit`, an empty `connection_closer` and `notification_sender`.
|
|
37
37
|
- `create_test_audit_emitter()` — no-op `AuditEmitter`; `emit` / `emit_role_grant_target` / `emit_pool` resolve immediately, `notify` no-op, `add_listener` throws (use `create_recording_audit_emitter` for a listener-accepting emitter), `listener_count` returns 0, `drain_inflight` resolves immediately, `inflight_count` returns 0.
|
|
38
38
|
- `create_stub_audit_sse()` — no-op `AuditLogSse` for surface-test wiring without booting real SSE. `on_audit_event` no-op (nothing is broadcast); `required_role` is `admin`; `registry` is a fresh `SseRegistry` (live `.count` / `.close_*` for registry-state tests, isolated per call). For real SSE plumbing build via `create_audit_log_sse` against `create_test_app`.
|
|
39
|
-
- `create_stub_api_middleware({include_daemon_token?, origin_carve_outs?})` — stub `MiddlewareSpec[]` with `create_auth_middleware_specs`'s names, paths, order and declared `errors` (pinned against it by `auth/middleware.mounted.test.ts`), each layer its own pass-through handler so `assert_middleware_stack_mounted` tells them apart. A stub declaring more errors than the real layer would widen every route's error map under its path.
|
|
39
|
+
- `create_stub_api_middleware({include_daemon_token?, origin_carve_outs?})` — stub `MiddlewareSpec[]` with `create_auth_middleware_specs`'s names, paths, order and declared `errors` (pinned against it by `auth/middleware.mounted.test.ts`), each layer its own pass-through handler so `assert_middleware_stack_mounted` tells them apart. A stub declaring more errors than the real layer would widen every route's error map under its path. The real stack: `auth/CLAUDE.md` §Middleware.
|
|
40
40
|
- `create_stub_app_backend(options?)` — stub `AppBackend` with no database: `create_stub_app_deps()` (or `options.deps`), no migration results, a `close` that does nothing (or `options.close`). For assembling a server in tests that never reach the database.
|
|
41
|
-
- `create_stub_app_server_context(
|
|
41
|
+
- `create_stub_app_server_context(session_cookie_name)` — stub `AppServerContext` over `create_stub_app_backend()`; rate limiters null, `bootstrap_status.available: false`.
|
|
42
42
|
- `create_test_app_surface_spec(options)` — the `AppSurfaceSpec` `create_app_server` would build, in its order (consumer routes, bootstrap, RPC endpoints, `GET /api/surface` when `surface_route: true` — pass both the same value), over a stub middleware list mirroring the real one (body limit, host gate, `trusted_proxy`, the stub auth stack). Single source of truth for attack-surface tests — track `create_app_server` wiring changes here; `testing/test_app_server.db.test.ts` pins it against `create_test_app`. It throws where `create_app_server` throws (the assembly asserts of `auth/CLAUDE.md` §Middleware, and a `ws_endpoints` spec with no `allowed_origins` when none is given). Options: `CreateTestAppSurfaceSpecOptions` TSDoc.
|
|
43
43
|
|
|
44
44
|
Throwing stubs surface mock escape: a test that accidentally reaches into
|
|
@@ -240,7 +240,7 @@ cookie" flow, split by intent:
|
|
|
240
240
|
- `bootstrap_test_keeper(options)` — keeper path used by `create_test_app_server`. Same body as the general helper plus a lock flip (`UPDATE bootstrap_lock SET bootstrapped = true ...`) so test DB state matches a real bootstrap completion, letting production code trust the lock as the single signal.
|
|
241
241
|
- `create_test_account_with_credentials(options)` — general path used by `TestApp.create_account` for additional non-keeper accounts. Same body, no lock interaction (additional accounts aren't bootstraps).
|
|
242
242
|
|
|
243
|
-
Both take `{db, keyring,
|
|
243
|
+
Both take `{db, keyring, password, username?, password_value?, roles?}`
|
|
244
244
|
(shared `CreateTestAccountWithCredentialsOptions` / `BootstrapTestKeeperOptions`),
|
|
245
245
|
and store the username lowercased, as the Rust spine's `_testing_reset` seeds
|
|
246
246
|
do, so the returned `account.username` is its lowercase.
|
|
@@ -248,8 +248,8 @@ do, so the returned `account.username` is its lowercase.
|
|
|
248
248
|
Types:
|
|
249
249
|
|
|
250
250
|
- `TestAppServer extends AppBackend` — adds `account`, `actor`, `api_token`, `session_cookie`, `keyring`, `cleanup()`.
|
|
251
|
-
- `TestAppServerOptions` —
|
|
252
|
-
- `CreateTestAppOptions extends TestAppServerOptions` (`test_app.ts`, as `TestAccount`, `TestApp` and `SuiteAppOptions`) — adds `create_route_specs` (required), `rpc_endpoints?: RpcEndpointsSuiteOption` (top-level only — single source of truth, symmetric with the suite-level option), `bootstrap?: BootstrapServerOptions` (top-level only — same precedent as `rpc_endpoints`), and `app_options?: SuiteAppOptions` (`Partial<AppServerOptions>` excluding the five fields the helper manages: `backend`, `
|
|
251
|
+
- `TestAppServerOptions` — optional `db`, `db_type`, `migration_namespaces`, `password`, `username`, `password_value`, `roles` (default `DEFAULT_TEST_KEEPER_ROLES`, keeper and admin, as a production bootstrap grants), `audit_factory`. `migration_namespaces` runs extra namespaces after auth in the auto-created in-memory database (mirrors `create_app_backend`); mutually exclusive with `db` (caller-migrated) — passing both throws. The optional `audit_factory` defaults to `default_audit_factory` (no-listener `create_audit_emitter` over the test backend's `{db, log}`); pass a custom factory to compose `on_audit_event` / `audit_log_config`, instrument `emit` with `emit_decorator`, or otherwise replace the emitter. Mirrors `CreateAppBackendOptions`.
|
|
252
|
+
- `CreateTestAppOptions extends TestAppServerOptions` (`test_app.ts`, as `TestAccount`, `TestApp` and `SuiteAppOptions`) — adds `session_cookie_name` and `create_route_specs` (required), `rpc_endpoints?: RpcEndpointsSuiteOption` (top-level only — single source of truth, symmetric with the suite-level option), `bootstrap?: BootstrapServerOptions` (top-level only — same precedent as `rpc_endpoints`), and `app_options?: SuiteAppOptions` (`Partial<AppServerOptions>` excluding the five fields the helper manages: `backend`, `session_cookie_name`, `create_route_specs`, `rpc_endpoints`, `bootstrap`), and `exclude_db_invariants?` (§`db_invariant_queries.ts` + `db_invariants.ts`).
|
|
253
253
|
- `TestAccount` — `{account, actor, session_cookie, api_token, create_session_headers, create_bearer_headers}`.
|
|
254
254
|
- `TestApp` — `{app, backend, server, surface_spec, surface, route_specs, create_session_headers, create_bearer_headers, create_daemon_token_headers, create_account, assert_db_invariants, cleanup}`. `server` is the assembled `AppServer`, for what `create_app_server` built beyond the lifted fields — `require_audit_sse(test_app.server)` with `audit_log_sse` in `app_options`, `test_app.server.ws_endpoints[path]` — instead of capturing them from a `create_route_specs` closure.
|
|
255
255
|
|
|
@@ -654,7 +654,7 @@ valid credential must name its reason** — `data.reason` over RPC (pass
|
|
|
654
654
|
`{reason}` to `jsonrpc_errors.unauthenticated`), the flat `error` over REST. A
|
|
655
655
|
≥500 carrying a declared code (503 `service_unavailable`, 504 `timeout`, a
|
|
656
656
|
consumer's `register_jsonrpc_error_code`) passes. Options: `{setup_test,
|
|
657
|
-
surface_source,
|
|
657
|
+
surface_source, session_cookie_name, rpc_endpoints, skip_methods?,
|
|
658
658
|
input_overrides?, success_fixtures?}`; a method no picked principal can reach
|
|
659
659
|
goes in `skip_methods`.
|
|
660
660
|
|
|
@@ -789,7 +789,7 @@ Each group asserts its required route exists with a descriptive message.
|
|
|
789
789
|
Creates a tight rate limiter (default `max_attempts: 2`, `window_ms: 60_000`)
|
|
790
790
|
per test and disposes it in `finally`.
|
|
791
791
|
|
|
792
|
-
Options: `{
|
|
792
|
+
Options: `{session_cookie_name, create_route_specs, rpc_endpoints?, app_options?, db_factories?, max_attempts?}`.
|
|
793
793
|
Reads inputs directly from the options bag instead of going through the
|
|
794
794
|
`setup_test` fixture protocol — the per-test rate-limiter overrides need a
|
|
795
795
|
fresh `TestApp` per test that the single-fixture model can't carry.
|
|
@@ -832,7 +832,7 @@ probes each gate on each counted route. Override with
|
|
|
832
832
|
minimal route sets whose declared error codes outpace the suite's
|
|
833
833
|
denial-path drivers).
|
|
834
834
|
|
|
835
|
-
Options: `{setup_test, surface_source,
|
|
835
|
+
Options: `{setup_test, surface_source, session_cookie_name, rpc_endpoints, base_url,
|
|
836
836
|
max_body_bytes?, rpc_max_body_bytes?, error_coverage_min?,
|
|
837
837
|
check_uncovered_errors?}`; the last is called with the declared paths left
|
|
838
838
|
uncovered before the floor is asserted, which fuz_app's own wirings hold to an
|
|
@@ -881,7 +881,7 @@ header/account mismatch. Direct-grant fixtures (test focuses on revoke or
|
|
|
881
881
|
isolation, not the consent path) go through `create_test_role_grant_direct`
|
|
882
882
|
from `db_entities.ts`.
|
|
883
883
|
|
|
884
|
-
Required options: `{setup_test, surface_source,
|
|
884
|
+
Required options: `{setup_test, surface_source, session_cookie_name, rpc_endpoints: RpcEndpointsSuiteOption, roles: RoleRegistry, admin_prefix?}`.
|
|
885
885
|
|
|
886
886
|
fuz_app runs it cross-process through the standard bundle
|
|
887
887
|
and in-process as a consumer wires it
|
|
@@ -979,7 +979,7 @@ Registry lookups:
|
|
|
979
979
|
- `find_rpc_method(rpc_endpoints, method)` — surface-shape lookup over `AppSurfaceRpcEndpoint[]` (generated by `generate_app_surface`).
|
|
980
980
|
- `require_rpc_endpoint_path(rpc_endpoints)` — returns the single endpoint path; throws descriptively on zero or multiple endpoints. Used by the admin/audit suites to hard-fail at setup.
|
|
981
981
|
- `RpcEndpointsSuiteOption` — union `Array<RpcEndpointSpec> | ((ctx: AppServerContext) => Array<RpcEndpointSpec>)` accepted by every DB-backed suite's `rpc_endpoints` field.
|
|
982
|
-
- `resolve_rpc_endpoints_for_setup(rpc_endpoints,
|
|
982
|
+
- `resolve_rpc_endpoints_for_setup(rpc_endpoints, session_cookie_name)` — resolves the union to an array for setup-time inspection (path lookup, `find_rpc_action` presence checks). Factory form is invoked once with a stub `AppServerContext`; the produced actions are discarded because `create_app_server` invokes the factory a second time per-test with its real ctx. Safe when the factory is pure wrt endpoint `path` and action `spec.method` list.
|
|
983
983
|
|
|
984
984
|
### `rpc_attack_surface.ts` + `rpc_envelope_cases.ts` — `describe_rpc_attack_surface_tests`
|
|
985
985
|
|
|
@@ -1104,7 +1104,7 @@ minus their in-process-only knobs (`create_route_specs`,
|
|
|
1104
1104
|
|
|
1105
1105
|
One call that runs every shipped single-backend cross suite against one
|
|
1106
1106
|
spawned backend: `describe_spine_cross_suites(handle, {surface_source,
|
|
1107
|
-
|
|
1107
|
+
session_cookie_name, rpc_endpoints, live_rpc_endpoints?, roles?, setup?, exclude?,
|
|
1108
1108
|
exclude_cases?, expected_skips?, overrides?, suite_roles?, ws_required_roles?, rpc_success_fixtures?,
|
|
1109
1109
|
rpc_skip_methods?, rpc_input_overrides?, rpc_max_body_bytes?, ws_max_message_bytes?})`.
|
|
1110
1110
|
`live_rpc_endpoints` is the backend's whole live mount; given, `rpc_adversarial`
|
|
@@ -1163,7 +1163,7 @@ here never reaches it.
|
|
|
1163
1163
|
(`testing_backdoor`, which checks the backdoor declaration the gating reads,
|
|
1164
1164
|
and `capability_mounts`, which checks the mount flags), or a suite already
|
|
1165
1165
|
skipping itself for an undeclared backdoor throws before anything registers.
|
|
1166
|
-
- **Backdoors.** `capabilities.testing_backdoors` must declare `SPINE_SUITES_REQUIRED_BACKDOORS` (`_testing_reset`, `_testing_drain_effects`), plus `_testing_put_fact` with `fact_serving` and `_testing_room_evict` with `rooms`, or the call throws. A suite whose every case drives another backdoor (`SuiteEntry.backdoors`) skips itself, with the reason, on a backend not declaring it — an exclude, override or `exclude_cases` entry for it throws as dead; `spine_suites.test.ts` holds each entry's `backdoors` to the names its module uses.
|
|
1166
|
+
- **Backdoors.** `capabilities.testing_backdoors` must declare `SPINE_SUITES_REQUIRED_BACKDOORS` (`_testing_reset`, `_testing_drain_effects`), `_testing_db_invariants` unless `setup` turns the invariant check off (`exclude_db_invariants: {all: reason}`), plus `_testing_put_fact` with `fact_serving` and `_testing_room_evict` with `rooms`, or the call throws. A suite whose every case drives another backdoor (`SuiteEntry.backdoors`) skips itself, with the reason, on a backend not declaring it — an exclude, override or `exclude_cases` entry for it throws as dead; `spine_suites.test.ts` holds each entry's `backdoors` to the names its module uses.
|
|
1167
1167
|
- **`exclude_cases`** — `SuiteCaseExclusions`, `{[suite]: {[name path]: reason}}`: single tests of a running suite by full name path (describe titles and test name joined with `' > '`, below the calling suite), skipped at run time with the reason. An entry for an unknown, excluded, self-skipping or unexcludable suite throws at collection; one naming no collected test fails the closing test (`check_spine_case_exclusions`).
|
|
1168
1168
|
- **`expected_skips`** — `{[name path]: reason}`: the gated skips the backend
|
|
1169
1169
|
owes — the cases a suite skips because the backend lacks what they gate on
|
|
@@ -1204,7 +1204,7 @@ builtin, and `sse_round_trip`'s other-role keep case for `ROLE_ADMIN`. fuz_app's
|
|
|
1204
1204
|
### `cross_backend/rust_spine_consumer_surface.ts` — `create_rust_spine_consumer_surface_spec`
|
|
1205
1205
|
|
|
1206
1206
|
The declared surface of a consumer served by the Rust spine, for its cross
|
|
1207
|
-
suites: `create_rust_spine_consumer_surface_spec({
|
|
1207
|
+
suites: `create_rust_spine_consumer_surface_spec({session_cookie_name,
|
|
1208
1208
|
domain_action_specs, extra_rpc_actions?, roles?, exclude_methods?,
|
|
1209
1209
|
rpc_path?, host_gate?})`, built on `create_test_app_surface_spec` from the hono-free route
|
|
1210
1210
|
shapes. It declares `/health`, the `ACCOUNT_ROUTER_PATHS` under
|
|
@@ -1246,7 +1246,7 @@ conformance cases assert _expected behavior_ — the security negatives
|
|
|
1246
1246
|
wire-shape check passes green on even when behavior is wrong.
|
|
1247
1247
|
|
|
1248
1248
|
- `conformance_case.ts` — the `ConformanceCase` type (data, never parsed): `{name, request: {method, params?, params_json?, as, acting?, verb?}, expect: {status, error_reason?, error_code?, fields?, headers?, set_cookie?, equivalence_group?}, note?, xfail?}`. `method` resolves its schemas from the live registry (RPC) or the REST auth routes. `as` is a closed `ConformancePrincipal` — fixture accessors, never inline minting; what each principal sends and which leg refuses it is on the type. `acting` (`ConformanceActingBinding`) has the runner fill `params.acting` with a real actor id. Beyond status and reason (`error_reason: null` pins an RPC denial carrying no `data.reason`): `error_code` (else the status's default JSON-RPC code), `equivalence_group` (members answer byte-identical `{status, body}`), `headers` (present-and-equal, or `null` for absent), `set_cookie` (a `SessionCookieEffect`; **omitted means `'none'`**). Always checked: no fingerprint header (`FINGERPRINT_HEADERS`), and no session cookie minted outside 2xx. `check_conformance_cases` refuses a row that can't mean anything.
|
|
1249
|
-
- `conformance_table.ts` — `describe_conformance_table_tests({cases, setup_test, surface_source, capabilities, rpc_endpoints, live_rpc_endpoints?,
|
|
1249
|
+
- `conformance_table.ts` — `describe_conformance_table_tests({cases, setup_test, surface_source, capabilities, rpc_endpoints, live_rpc_endpoints?, session_cookie_name, principals?, ws?, suite_name?})`, on the Tier 1 fixture protocol, so **one case array runs in-process and cross-process**. Methods resolve from `rpc_endpoints`, then `live_rpc_endpoints` (methods kept off the declared surface; fuz_app's is `create_spine_live_rpc_endpoints()`) — `resolve_conformance_rpc_endpoints`; `send_conformance_case` is the send half the differential shares; `role_holder` / `wrong_role` read an `extra_accounts` username named in `principals`. `ws` (cross-process only) re-sends each case `is_ws_conformance_case` admits as one frame on a socket the principal opens, under the same expectations; an equivalence group left with one member there is dropped.
|
|
1250
1250
|
- `conformance_rpc_auth.ts` — `generate_rpc_auth_conformance_cases({surface_source,
|
|
1251
1251
|
live_rpc_endpoints?, skip_methods?})` → `ConformanceCase[]` from each declared RPC method's
|
|
1252
1252
|
`RouteAuth`, then each live-mounted one the declared surface lacks
|
|
@@ -1684,7 +1684,7 @@ Conventions that hold across them:
|
|
|
1684
1684
|
| action | bundled | does |
|
|
1685
1685
|
| --- | --- | --- |
|
|
1686
1686
|
| `_testing_reset` | yes | the consumer's `reset_state(db)` first, on the same transaction (domain rows depend on auth rows); then every auth row wiped, `app_settings` and `bootstrap_lock` reset, a fresh keeper and any `extra_accounts` seeded through the in-process primitives |
|
|
1687
|
-
| `_testing_drain_effects` | yes | answers `{ok: true}` once no audit pool write is in flight,
|
|
1687
|
+
| `_testing_drain_effects` | yes | answers `{ok: true}` once no request's effect flush (`deps.request_tracker`) and no audit pool write is in flight, those started while it waits included — never a handler still running, its own among them; the barrier before an audit or effect read (WS replies before its effects flush) |
|
|
1688
1688
|
| `_testing_db_invariants` | yes | every row breaking a `DB_INVARIANTS` check, read after each test |
|
|
1689
1689
|
| `_testing_mint_session` | yes | a backdated session row behind a valid cookie (the `expired_session` principal) |
|
|
1690
1690
|
| `_testing_put_fact` | yes | seeds a fact, with an optional holder or external URL |
|
|
@@ -1761,7 +1761,7 @@ re-roll the serve / daemon-info / drain boilerplate:
|
|
|
1761
1761
|
- `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
1762
|
- `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
1763
|
- `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.
|
|
1764
|
-
- `testing/cross_backend/default_spine_surface.ts` — the canonical no-domain spine surface (account/admin/audit/signup + bootstrap): `
|
|
1764
|
+
- `testing/cross_backend/default_spine_surface.ts` — the canonical no-domain spine surface (account/admin/audit/signup + bootstrap): `spine_roles`, `create_spine_route_specs`, `create_spine_ready_route_spec` (the `/ready` route over the committed `expected_schema.json`), `spine_rpc_endpoints`, `create_spine_surface_spec`. This is the **declared** surface — the `create_standard_rpc_actions` bundle the spec-derived suites auto-enumerate. It passes `daemon_token: true` (both spine binaries mount the daemon-token layer) and leaves `GET /api/surface` at its default, off — the TS spine binary does too, and the Rust `testing_spine_stub` serves none. Shared by the spine_stub cross test, the TS cross tests, and the binary.
|
|
1765
1765
|
- `testing/cross_backend/full_spine_mount.ts` — `build_full_spine_rpc_actions(deps, options)` — the **full** live RPC mount: the declared bundle **plus** the off-declared-surface families the binary live-mounts (`_testing_*` backdoors, the cell verb set, the opt-in `actor_lookup` / `actor_search` resolvers). `build_full_spine_mount(deps, options)` builds it once for both of the binary's endpoints, returning `FullSpineMount` (`{rpc_actions, ws_actions}`): the WS list is `protocol_actions` plus every RPC action not already among them, then the WS-only room verbs and `room_notification_actions`, twinning the Rust `testing_spine_stub`, which serves one registry on RPC and WS (the one difference is `cancel` — a registered protocol action on TS, owned by the read loop on Rust — and the stub's RPC dispatcher refuses its `ws_only` room verbs). `options.room_registry` is the registry the room verbs, `_testing_room_evict`, and `_testing_reset` (which clears it) share — the binary builds it with `create_spine_room_registry(connections)` (exclusive, the default bounds; the twin of the stub's `stub_room_registry`) over its WS endpoints' connection registry; omitted, one over a fresh connection registry serves enumeration. Single-sources the mount so the binary and the `spine_method_coverage` reconciliation test build the same list. `create_spine_live_rpc_endpoints()` wraps the list, built on stub deps, as one endpoint at `SPINE_RPC_PATH` — the `live_rpc_endpoints` value the conformance table, the differential and the auth-row generator resolve off-surface methods from (no handler built there runs).
|
|
1766
1766
|
- `testing/cross_backend/ts_spine_backend_config.ts` — `ts_spine_node_backend_config()` / `ts_spine_bun_backend_config()` presets (in-memory pglet, no external infra), the TS analog of `rust_spine_stub_backend_config()`.
|
|
1767
1767
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
-
import type { SessionOptions } from '../auth/session_cookie.js';
|
|
3
2
|
import { type RoleRegistry } from '../auth/role_schema.js';
|
|
4
3
|
import { type RpcEndpointsSuiteOption } from './rpc_helpers.js';
|
|
5
4
|
import type { AppSurfaceSpec } from '../http/surface.js';
|
|
@@ -20,8 +19,8 @@ export interface StandardAdminIntegrationTestOptions {
|
|
|
20
19
|
* shape for in-process and cross-process tests).
|
|
21
20
|
*/
|
|
22
21
|
surface_source: AppSurfaceSpec;
|
|
23
|
-
/**
|
|
24
|
-
|
|
22
|
+
/** The session cookie's name — read for the session cookie and the factory-form `rpc_endpoints` resolution. */
|
|
23
|
+
session_cookie_name: string;
|
|
25
24
|
/** Role registry from `create_role_registry()` — used to determine valid/invalid/web-grantable roles. */
|
|
26
25
|
roles: RoleRegistry;
|
|
27
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin_integration.d.ts","sourceRoot":"","sources":["../../src/lib/testing/admin_integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAgC7B,OAAO,
|
|
1
|
+
{"version":3,"file":"admin_integration.d.ts","sourceRoot":"","sources":["../../src/lib/testing/admin_integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAgC7B,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"}
|
|
@@ -7,7 +7,7 @@ import './assert_dev_env.js';
|
|
|
7
7
|
* surface — see `role_grant_offer_create` / `role_grant_revoke`), session/token
|
|
8
8
|
* management, and audit log routes against a real database.
|
|
9
9
|
*
|
|
10
|
-
* Consumers call it with their route factory, session
|
|
10
|
+
* Consumers call it with their route factory, session cookie name, role registry,
|
|
11
11
|
* and RPC endpoint specs — all admin route tests come for free.
|
|
12
12
|
*
|
|
13
13
|
* Scope: admin *semantics* — cross-admin isolation, role_grant grant/revoke
|
|
@@ -78,10 +78,10 @@ export const describe_standard_admin_integration_tests = (options) => {
|
|
|
78
78
|
const route_specs = options.surface_source.route_specs;
|
|
79
79
|
// Hard-fail early so consumers see a clear setup error instead of a
|
|
80
80
|
// confusing test failure when `rpc_endpoints` is missing.
|
|
81
|
-
const rpc_endpoints_for_setup = resolve_rpc_endpoints_for_setup(options.rpc_endpoints, options.
|
|
81
|
+
const rpc_endpoints_for_setup = resolve_rpc_endpoints_for_setup(options.rpc_endpoints, options.session_cookie_name);
|
|
82
82
|
const rpc_path = require_rpc_endpoint_path(rpc_endpoints_for_setup);
|
|
83
83
|
describe('standard_admin_integration', () => {
|
|
84
|
-
const
|
|
84
|
+
const cookie_name = options.session_cookie_name;
|
|
85
85
|
const { role_specs } = options.roles;
|
|
86
86
|
const grantable_role = pick_grantable_role(role_specs);
|
|
87
87
|
// Error coverage tracking across test groups
|
|
@@ -3,7 +3,6 @@ import type { Uuid } from '../primitive_schemas.js';
|
|
|
3
3
|
import { type Keyring } from '../auth/keyring.js';
|
|
4
4
|
import type { Db, DbType } from '../db/db.js';
|
|
5
5
|
import type { PasswordHashDeps } from '../auth/password.js';
|
|
6
|
-
import { type SessionOptions } from '../auth/session_cookie.js';
|
|
7
6
|
import { type MigrationNamespace } from '../db/migrate.js';
|
|
8
7
|
import { type AppBackend, type AuditFactory } from '../server/app_backend.js';
|
|
9
8
|
import type { AppServerOptions } from '../server/app_server.js';
|
|
@@ -32,7 +31,6 @@ export declare const TEST_COOKIE_SECRET: string;
|
|
|
32
31
|
export interface CreateTestAccountWithCredentialsOptions {
|
|
33
32
|
db: Db;
|
|
34
33
|
keyring: Keyring;
|
|
35
|
-
session_options: SessionOptions<string>;
|
|
36
34
|
password: PasswordHashDeps;
|
|
37
35
|
username?: string;
|
|
38
36
|
password_value?: string;
|
|
@@ -72,7 +70,6 @@ export declare const create_test_account_with_credentials: (options: CreateTestA
|
|
|
72
70
|
export interface MintTestSessionOptions {
|
|
73
71
|
db: Db;
|
|
74
72
|
keyring: Keyring;
|
|
75
|
-
session_options: SessionOptions<string>;
|
|
76
73
|
/** Account the minted session belongs to. */
|
|
77
74
|
account_id: string;
|
|
78
75
|
/**
|
|
@@ -81,7 +78,7 @@ export interface MintTestSessionOptions {
|
|
|
81
78
|
* the authoritative DB-row expiry gate (`query_session_get_valid` —
|
|
82
79
|
* `WHERE expires_at > NOW()`) rejects it, while the returned cookie's
|
|
83
80
|
* own signed payload stays valid (future). Resolution therefore passes
|
|
84
|
-
* the cookie-payload check in `
|
|
81
|
+
* the cookie-payload check in `parse_session_from_cookies` and is refused at the
|
|
85
82
|
* DB-row gate — the gate the in-process payload-expiry tests never
|
|
86
83
|
* reach and the one that structurally needs a server-side mint.
|
|
87
84
|
*/
|
|
@@ -108,7 +105,7 @@ export declare const mint_test_session: (options: MintTestSessionOptions) => Pro
|
|
|
108
105
|
* Bootstrap the test-DB keeper. Direct-query shortcut for the default
|
|
109
106
|
* `create_test_app` path — bootstrap is not what most tests exercise, so
|
|
110
107
|
* we skip the real `bootstrap_account` flow (no audit row, no
|
|
111
|
-
*
|
|
108
|
+
* keeper set on a daemon-token state); the cross-backend harness drives the real
|
|
112
109
|
* `POST /bootstrap` against every backend it spawns.
|
|
113
110
|
*
|
|
114
111
|
* Flips `bootstrap_lock.bootstrapped = true` so the post-insert DB state
|
|
@@ -158,8 +155,6 @@ export interface TestAppServer extends AppBackend {
|
|
|
158
155
|
* Configuration for `create_test_app_server`.
|
|
159
156
|
*/
|
|
160
157
|
export interface TestAppServerOptions {
|
|
161
|
-
/** Session options — needed for cookie signing. */
|
|
162
|
-
session_options: SessionOptions<string>;
|
|
163
158
|
/** Existing database — skips internal DB creation when provided. Caller owns the DB lifecycle. */
|
|
164
159
|
db?: Db;
|
|
165
160
|
/** Database driver type — only used when `db` is provided. Default: `'pglet-memory'`. */
|
|
@@ -219,7 +214,7 @@ export interface TestAppServerOptions {
|
|
|
219
214
|
* Uses `stub_password_deps` by default — deterministic hashing that works
|
|
220
215
|
* correctly for login/logout tests without Argon2 overhead.
|
|
221
216
|
*
|
|
222
|
-
* @param options -
|
|
217
|
+
* @param options - the database, the keeper's credentials and roles, and the audit factory
|
|
223
218
|
* @returns a `TestAppServer` ready for HTTP testing
|
|
224
219
|
* @mutates the underlying database — when `db` is supplied, first resets the
|
|
225
220
|
* `app_settings` row (`open_signup`, `updated_at`, `updated_by`); in either
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_server.d.ts","sourceRoot":"","sources":["../../src/lib/testing/app_server.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAIpD,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"app_server.d.ts","sourceRoot":"","sources":["../../src/lib/testing/app_server.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B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CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,kGAAkG;IAClG,EAAE,CAAC,EAAE,EAAE,CAAC;IACR,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;OASG;IACH,oBAAoB,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACzD,yHAAyH;IACzH,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB;;;;;;;;;;;;;OAaG;IACH,aAAa,CAAC,EAAE,YAAY,CAAC;CAC7B;AAyFD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,sBAAsB,GAClC,SAAS,oBAAoB,KAC3B,OAAO,CAAC,aAAa,CAyBvB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kCAAkC,QAAO,IAAI,CACzD,gBAAgB,EAChB,iBAAiB,GAAG,OAAO,GAAG,YAAY,CAa1C,CAAC"}
|
|
@@ -37,6 +37,7 @@ import { create_default_db_factory } from './db.js';
|
|
|
37
37
|
import { token_scope_full } from '../auth/token_scope.js';
|
|
38
38
|
import { format_allowed_origins_error, parse_allowed_origins } from '../http/origin.js';
|
|
39
39
|
import { TEST_ORIGIN } from './test_origin.js';
|
|
40
|
+
import { create_request_tracker } from '../http/pending_effects.js';
|
|
40
41
|
/**
|
|
41
42
|
* Fast password stub for tests that don't exercise login/password flows.
|
|
42
43
|
*
|
|
@@ -109,7 +110,7 @@ const resolve_fallback_factory = (migration_namespaces) => {
|
|
|
109
110
|
* `role_grant` (one per role), `api_token`, and `auth_session`.
|
|
110
111
|
*/
|
|
111
112
|
export const create_test_account_with_credentials = async (options) => {
|
|
112
|
-
const { db, keyring,
|
|
113
|
+
const { db, keyring, password, username = 'keeper', password_value = DEFAULT_TEST_PASSWORD, roles = [], email } = options;
|
|
113
114
|
const deps = { db };
|
|
114
115
|
const password_hash = await password.hash_password(password_value);
|
|
115
116
|
// lowercase, as `Username` stores every name production creates, and as the
|
|
@@ -131,7 +132,7 @@ export const create_test_account_with_credentials = async (options) => {
|
|
|
131
132
|
// database clock), as the Rust reset seeds through its production minter.
|
|
132
133
|
const session_token = generate_session_token();
|
|
133
134
|
await query_create_session({ db }, hash_session_token(session_token), account.id);
|
|
134
|
-
const session_cookie = await create_session_cookie_value(keyring, session_token
|
|
135
|
+
const session_cookie = await create_session_cookie_value(keyring, session_token);
|
|
135
136
|
return {
|
|
136
137
|
account: { id: account.id, username: account.username },
|
|
137
138
|
actor: { id: actor.id },
|
|
@@ -153,18 +154,18 @@ export const create_test_account_with_credentials = async (options) => {
|
|
|
153
154
|
* @mutates `options.db` — inserts one `auth_session` row.
|
|
154
155
|
*/
|
|
155
156
|
export const mint_test_session = async (options) => {
|
|
156
|
-
const { db, keyring,
|
|
157
|
+
const { db, keyring, account_id, expires_in_seconds } = options;
|
|
157
158
|
const session_token = generate_session_token();
|
|
158
159
|
const session_hash = hash_session_token(session_token);
|
|
159
160
|
await create_test_session_row(db, session_hash, account_id, expires_in_seconds);
|
|
160
|
-
const session_cookie = await create_session_cookie_value(keyring, session_token
|
|
161
|
+
const session_cookie = await create_session_cookie_value(keyring, session_token);
|
|
161
162
|
return { session_cookie, session_hash };
|
|
162
163
|
};
|
|
163
164
|
/**
|
|
164
165
|
* Bootstrap the test-DB keeper. Direct-query shortcut for the default
|
|
165
166
|
* `create_test_app` path — bootstrap is not what most tests exercise, so
|
|
166
167
|
* we skip the real `bootstrap_account` flow (no audit row, no
|
|
167
|
-
*
|
|
168
|
+
* keeper set on a daemon-token state); the cross-backend harness drives the real
|
|
168
169
|
* `POST /bootstrap` against every backend it spawns.
|
|
169
170
|
*
|
|
170
171
|
* Flips `bootstrap_lock.bootstrapped = true` so the post-insert DB state
|
|
@@ -243,7 +244,8 @@ const _build_test_backend = async (options) => {
|
|
|
243
244
|
log: test_log,
|
|
244
245
|
audit: audit_factory({ db, log: test_log }),
|
|
245
246
|
connection_closer: create_realtime_closer(),
|
|
246
|
-
notification_sender: create_realtime_notification_sender()
|
|
247
|
+
notification_sender: create_realtime_notification_sender(),
|
|
248
|
+
request_tracker: create_request_tracker()
|
|
247
249
|
}
|
|
248
250
|
};
|
|
249
251
|
return { backend, keyring: keyring_result.keyring };
|
|
@@ -262,7 +264,7 @@ const _build_test_backend = async (options) => {
|
|
|
262
264
|
* Uses `stub_password_deps` by default — deterministic hashing that works
|
|
263
265
|
* correctly for login/logout tests without Argon2 overhead.
|
|
264
266
|
*
|
|
265
|
-
* @param options -
|
|
267
|
+
* @param options - the database, the keeper's credentials and roles, and the audit factory
|
|
266
268
|
* @returns a `TestAppServer` ready for HTTP testing
|
|
267
269
|
* @mutates the underlying database — when `db` is supplied, first resets the
|
|
268
270
|
* `app_settings` row (`open_signup`, `updated_at`, `updated_by`); in either
|
|
@@ -270,12 +272,11 @@ const _build_test_backend = async (options) => {
|
|
|
270
272
|
* row, and flips `bootstrap_lock.bootstrapped` (`bootstrap_test_keeper`).
|
|
271
273
|
*/
|
|
272
274
|
export const create_test_app_server = async (options) => {
|
|
273
|
-
const {
|
|
275
|
+
const { password = stub_password_deps, username = 'keeper', password_value = DEFAULT_TEST_PASSWORD, roles } = options;
|
|
274
276
|
const { backend, keyring } = await _build_test_backend(options);
|
|
275
277
|
const bootstrapped = await bootstrap_test_keeper({
|
|
276
278
|
db: backend.deps.db,
|
|
277
279
|
keyring,
|
|
278
|
-
session_options,
|
|
279
280
|
password,
|
|
280
281
|
username,
|
|
281
282
|
password_value,
|
|
@@ -44,7 +44,7 @@ export interface StandardAttackSurfaceOptions {
|
|
|
44
44
|
snapshot_path: string;
|
|
45
45
|
/** Expected public routes, e.g. `['GET /health', 'POST /api/account/login']`. */
|
|
46
46
|
expected_public_routes: Array<string>;
|
|
47
|
-
/** Expected middleware names for API routes, e.g. `['trusted_proxy', 'origin', 'session', 'request_context', 'bearer_auth']`. */
|
|
47
|
+
/** Expected middleware names for API routes, e.g. `['body_limit', 'host', 'trusted_proxy', 'origin', 'session', 'request_context', 'bearer_auth']`. */
|
|
48
48
|
expected_api_middleware: Array<string>;
|
|
49
49
|
/** All roles in the app (e.g. `['admin', 'keeper']`). */
|
|
50
50
|
roles: Array<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attack_surface.d.ts","sourceRoot":"","sources":["../../src/lib/testing/attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAoB7B,OAAO,EAIN,KAAK,4BAA4B,EACjC,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,wBAAwB,CAAC;AAWhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAgCzD,oFAAoF;AACpF,MAAM,WAAW,sBAAsB;IACtC,+EAA+E;IAC/E,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,sBAAsB,KAAG,IA6K3E,CAAC;AAIF,0DAA0D;AAC1D,MAAM,WAAW,4BAA4B;IAC5C,+EAA+E;IAC/E,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,aAAa,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,sBAAsB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,
|
|
1
|
+
{"version":3,"file":"attack_sur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;;;;;;;GAiBG;AACH,eAAO,MAAM,sCAAsC,GAClD,SAAS,4BAA4B,KACnC,IAqDF,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
-
import type { SessionOptions } from '../auth/session_cookie.js';
|
|
3
2
|
import { type RpcEndpointsSuiteOption } from './rpc_helpers.js';
|
|
4
3
|
import type { AppSurfaceSpec } from '../http/surface.js';
|
|
5
4
|
import type { SetupTest } from './cross_backend/setup.js';
|
|
@@ -22,8 +21,8 @@ export interface AuditCompletenessTestOptions {
|
|
|
22
21
|
* options uniformity.
|
|
23
22
|
*/
|
|
24
23
|
surface_source: AppSurfaceSpec;
|
|
25
|
-
/**
|
|
26
|
-
|
|
24
|
+
/** The session cookie's name — needed for factory-form rpc_endpoints resolution. */
|
|
25
|
+
session_cookie_name: string;
|
|
27
26
|
/**
|
|
28
27
|
* RPC endpoint specs — required. The admin role_grant flow is RPC-only
|
|
29
28
|
* and the suite hard-fails without it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_completeness.d.ts","sourceRoot":"","sources":["../../src/lib/testing/audit_completeness.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"audit_completeness.d.ts","sourceRoot":"","sources":["../../src/lib/testing/audit_completeness.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsC7B,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AA2B1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;;;;OAKG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;;;OAMG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,oFAAoF;IACpF,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,aAAa,EAAE,uBAAuB,CAAC;CACvC;AAkGD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iCAAiC,GAAI,SAAS,4BAA4B,KAAG,IAgnBzF,CAAC"}
|
|
@@ -112,7 +112,7 @@ export const describe_audit_completeness_tests = (options) => {
|
|
|
112
112
|
const route_specs = options.surface_source.route_specs;
|
|
113
113
|
// Hard-fail early so consumers see a clear setup error instead of a
|
|
114
114
|
// confusing test failure when `rpc_endpoints` is missing.
|
|
115
|
-
const rpc_endpoints_for_setup = resolve_rpc_endpoints_for_setup(options.rpc_endpoints, options.
|
|
115
|
+
const rpc_endpoints_for_setup = resolve_rpc_endpoints_for_setup(options.rpc_endpoints, options.session_cookie_name);
|
|
116
116
|
const rpc_path = require_rpc_endpoint_path(rpc_endpoints_for_setup);
|
|
117
117
|
describe('audit_log_completeness', () => {
|
|
118
118
|
// --- Account routes ---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability_mounts.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/capability_mounts.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAyF9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EAAE,uCAAuC,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAUlG,kFAAkF;AAClF,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CACxC,mBAAmB,EACjB,IAAI,GACJ,KAAK,GACL,WAAW,GACX,gBAAgB,GAChB,cAAc,GACd,yBAAyB,GACzB,OAAO,GACP,gBAAgB,GAChB,oBAAoB,GACpB,eAAe,CACjB,CAAC;AAEF,8FAA8F;AAC9F,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;AAEtF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,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CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gCAAgC,GAC5C,SAAS,IAAI,CAAC,gCAAgC,EAAE,YAAY,GAAG,cAAc,CAAC,KAC5E,sBAOD,CAAC;AAmCH;;;GAGG;AACH,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAoNnE,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,gBAAgB,CAE/D,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,KAAK,EACb,mBAAmB,GAAG,2BAA2B,GAAG,8BAA8B,CAAC;IACpF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;IACtD,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,GACtC,cAAc,mBAAmB,EACjC,QAAQ,sBAAsB,EAC9B,aAAY,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAM,KAClE,KAAK,CAAC,kBAAkB,CA4F1B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sCAAsC,GAClD,SAAS,gCAAgC,KACvC,IAyBF,CAAC"}
|
|
@@ -15,8 +15,8 @@ import '../assert_dev_env.js';
|
|
|
15
15
|
* Each probe is the cheapest honest request — anonymous, so no setup state
|
|
16
16
|
* shapes the answer — and none of them answers a mounted surface with a `404`.
|
|
17
17
|
* An unmounted path under `/api` answers `404`: the spine's JSON
|
|
18
|
-
* `route_not_found`, or
|
|
19
|
-
*
|
|
18
|
+
* `route_not_found`, or, for a refused upgrade only, no body where the runtime
|
|
19
|
+
* drops it (`ws_refusal_body`).
|
|
20
20
|
*
|
|
21
21
|
* - **RPC verbs** (`cell_crud`: `cell_create`, `cell_relations`:
|
|
22
22
|
* `cell_grant_create`) — both spines look a method up before they
|
|
@@ -27,8 +27,8 @@ import '../assert_dev_env.js';
|
|
|
27
27
|
* - **The fact routes** (`fact_serving`, `fact_serving_admin_hash`) — a
|
|
28
28
|
* malformed `hash` param: both spines validate a route's params ahead of
|
|
29
29
|
* auth, so a mounted route answers `400` `invalid_route_params`. (The cell
|
|
30
|
-
* route's masked `404` for a cell no row names can't tell itself from
|
|
31
|
-
*
|
|
30
|
+
* route's masked `404` for a cell no row names can't tell itself from an
|
|
31
|
+
* unmatched `404`.)
|
|
32
32
|
* - **`ready`** — `GET /ready` answers `200 {ready: true}`, or `503` with
|
|
33
33
|
* `schema_drift` / `db_unreachable` (mounted, if drifted — the readiness
|
|
34
34
|
* suite fails that); unmounted, a `404` (any body — the spine fallback's
|
|
@@ -151,12 +151,17 @@ const error_of = (json) => json !== null && typeof json === 'object' ? json.erro
|
|
|
151
151
|
const describe_answer = (status, text) => `${status} ${text === '' ? '(no body)' : text.slice(0, 200)}`;
|
|
152
152
|
/**
|
|
153
153
|
* Whether an answer is an unmatched path's `404` under `/api`: the spine's JSON
|
|
154
|
-
* `route_not_found
|
|
155
|
-
* upgrade's body (`ws_refusal_body`) sends, and a backend whose own fallback
|
|
156
|
-
* answers `/api` paths. No probe's mounted answer is a `404`.
|
|
154
|
+
* `route_not_found`. No probe's mounted answer is a `404`.
|
|
157
155
|
*/
|
|
158
|
-
const is_unmatched_404 = (status, text) => status === 404 &&
|
|
159
|
-
const UNMATCHED_404 = `404
|
|
156
|
+
const is_unmatched_404 = (status, text) => status === 404 && error_of(parse_json(text)) === ERROR_ROUTE_NOT_FOUND;
|
|
157
|
+
const UNMATCHED_404 = `404 ${ERROR_ROUTE_NOT_FOUND}`;
|
|
158
|
+
/**
|
|
159
|
+
* Whether a refused upgrade is an unmatched path's `404`: `is_unmatched_404`,
|
|
160
|
+
* or a bodiless one — what a runtime dropping a refused upgrade's body
|
|
161
|
+
* (`ws_refusal_body`) sends.
|
|
162
|
+
*/
|
|
163
|
+
const is_unmatched_upgrade_404 = (status, text) => is_unmatched_404(status, text) || (status === 404 && text === '');
|
|
164
|
+
const UNMATCHED_UPGRADE_404 = `404 (${ERROR_ROUTE_NOT_FOUND} or no body)`;
|
|
160
165
|
/** An anonymous RPC call: `401` mounted, `method_not_found` unmounted. */
|
|
161
166
|
const rpc_probe = (declared_method) => ({
|
|
162
167
|
request: (t, absent) => `anonymous \`${absent ? to_absent_method(declared_method) : declared_method}\` on ${t.rpc_path}`,
|
|
@@ -206,7 +211,7 @@ const route_probe = (path_of, mounted) => {
|
|
|
206
211
|
const upgrade_probe = (path_of) => ({
|
|
207
212
|
request: (t, absent) => `anonymous upgrade on ${locate(path_of, t, absent)}`,
|
|
208
213
|
mounted: '401',
|
|
209
|
-
unmounted:
|
|
214
|
+
unmounted: UNMATCHED_UPGRADE_404,
|
|
210
215
|
observe: async (_fixture, t, absent) => {
|
|
211
216
|
const ws_path = locate(path_of, t, absent);
|
|
212
217
|
let refusal;
|
|
@@ -228,7 +233,7 @@ const upgrade_probe = (path_of) => ({
|
|
|
228
233
|
const answer = describe_answer(refusal.status, refusal.body);
|
|
229
234
|
if (refusal.status === 401)
|
|
230
235
|
return { mounted: true, answer };
|
|
231
|
-
if (
|
|
236
|
+
if (is_unmatched_upgrade_404(refusal.status, refusal.body))
|
|
232
237
|
return { mounted: false, answer };
|
|
233
238
|
assert.fail(`upgrade on ${ws_path}: expected a 401 (mounted) or 404 (unmounted) refusal, got ${answer}`);
|
|
234
239
|
}
|
|
@@ -2,7 +2,6 @@ import '../assert_dev_env.js';
|
|
|
2
2
|
import type { AppSurfaceSpec, RpcEndpointSpec } from '../../http/surface.js';
|
|
3
3
|
import type { RouteSpec } from '../../http/route_spec.js';
|
|
4
4
|
import type { RpcAction } from '../../actions/action_types.js';
|
|
5
|
-
import type { SessionOptions } from '../../auth/session_cookie.js';
|
|
6
5
|
import { resolve_rpc_endpoints_for_setup, type RpcEndpointsSuiteOption } from '../rpc_helpers.js';
|
|
7
6
|
import { type ConformanceCase } from './conformance_case.js';
|
|
8
7
|
import type { BackendCapabilities } from './capabilities.js';
|
|
@@ -29,8 +28,8 @@ export interface ConformanceTableOptions {
|
|
|
29
28
|
* live mount is fine. Omitted, only declared methods resolve.
|
|
30
29
|
*/
|
|
31
30
|
readonly live_rpc_endpoints?: RpcEndpointsSuiteOption;
|
|
32
|
-
/**
|
|
33
|
-
readonly
|
|
31
|
+
/** The session cookie's name — needed to resolve the `rpc_endpoints` factory form. */
|
|
32
|
+
readonly session_cookie_name: string;
|
|
34
33
|
/** Maps the `role_holder` / `wrong_role` principals to seeded usernames. */
|
|
35
34
|
readonly principals?: ConformancePrincipalConfig;
|
|
36
35
|
/**
|
|
@@ -49,8 +48,8 @@ export interface ConformanceRpcEndpointsOptions {
|
|
|
49
48
|
readonly rpc_endpoints: RpcEndpointsSuiteOption;
|
|
50
49
|
/** The live-mounted RPC endpoints, for methods off the declared surface. */
|
|
51
50
|
readonly live_rpc_endpoints?: RpcEndpointsSuiteOption;
|
|
52
|
-
/**
|
|
53
|
-
readonly
|
|
51
|
+
/** The session cookie's name — needed to resolve the factory forms. */
|
|
52
|
+
readonly session_cookie_name: string;
|
|
54
53
|
}
|
|
55
54
|
/**
|
|
56
55
|
* Resolve the endpoints a conformance case's RPC method is looked up in: the
|
|
@@ -58,7 +57,7 @@ export interface ConformanceRpcEndpointsOptions {
|
|
|
58
57
|
* takes the first match, so a declared method resolves from the declared
|
|
59
58
|
* surface even when the live mount repeats it.
|
|
60
59
|
*
|
|
61
|
-
* @param options - the declared and live endpoints, and the session
|
|
60
|
+
* @param options - the declared and live endpoints, and the session cookie name
|
|
62
61
|
* @returns the endpoints in lookup order
|
|
63
62
|
*/
|
|
64
63
|
export declare const resolve_conformance_rpc_endpoints: (options: ConformanceRpcEndpointsOptions) => Array<RpcEndpointSpec>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conformance_table.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/conformance_table.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAwD9B,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"conformance_table.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/conformance_table.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAwD9B,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAM/D,OAAO,EAMN,+BAA+B,EAC/B,KAAK,uBAAuB,EAC5B,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAEN,KAAK,eAAe,EAEpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAM7D,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAEN,KAAK,0BAA0B,EAE/B,MAAM,4BAA4B,CAAC;AAEpC,sDAAsD;AACtD,MAAM,WAAW,uBAAuB;IACvC,8CAA8C;IAC9C,QA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uB;IACvC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,GACjC,GAAG,eAAe,EAClB,SAAS,0BAA0B,KACjC,OAAO,CAAC,uBAAuB,CAwFjC,CAAC;AA2OF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,GAAI,OAAO,aAAa,CAAC,eAAe,CAAC,KAAG,IA0B/E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAAI,SAAS,uBAAuB,KAAG,IAwEnF,CAAC"}
|
|
@@ -66,13 +66,13 @@ import { resolve_conformance_principal } from './conformance_principal.js';
|
|
|
66
66
|
* takes the first match, so a declared method resolves from the declared
|
|
67
67
|
* surface even when the live mount repeats it.
|
|
68
68
|
*
|
|
69
|
-
* @param options - the declared and live endpoints, and the session
|
|
69
|
+
* @param options - the declared and live endpoints, and the session cookie name
|
|
70
70
|
* @returns the endpoints in lookup order
|
|
71
71
|
*/
|
|
72
72
|
export const resolve_conformance_rpc_endpoints = (options) => [
|
|
73
|
-
...resolve_rpc_endpoints_for_setup(options.rpc_endpoints, options.
|
|
73
|
+
...resolve_rpc_endpoints_for_setup(options.rpc_endpoints, options.session_cookie_name),
|
|
74
74
|
...(options.live_rpc_endpoints
|
|
75
|
-
? resolve_rpc_endpoints_for_setup(options.live_rpc_endpoints, options.
|
|
75
|
+
? resolve_rpc_endpoints_for_setup(options.live_rpc_endpoints, options.session_cookie_name)
|
|
76
76
|
: [])
|
|
77
77
|
];
|
|
78
78
|
/**
|
|
@@ -420,7 +420,7 @@ const run_case = async (c, options, resolved_rpc_endpoints) => {
|
|
|
420
420
|
assert_response_headers(sent.headers, c);
|
|
421
421
|
// a frame carries no headers, so the cookie assertions are the HTTP legs'
|
|
422
422
|
if (!options.ws)
|
|
423
|
-
assert_session_cookie(sent, c, options.
|
|
423
|
+
assert_session_cookie(sent, c, options.session_cookie_name);
|
|
424
424
|
const normalized = sent.target.kind === 'rest'
|
|
425
425
|
? assert_rest_case(c, sent.target.route, sent)
|
|
426
426
|
: assert_rpc_case(c, sent.target.action, sent);
|
|
@@ -31,7 +31,7 @@ import '../assert_dev_env.js';
|
|
|
31
31
|
* spine, so this is an imperative suite (not a `conformance_table` row) — the
|
|
32
32
|
* sibling of `origin.ts` / `login_security.ts`. Cross-process only: reading the
|
|
33
33
|
* raw `Set-Cookie` attributes needs the wire response (the in-process
|
|
34
|
-
* `
|
|
34
|
+
* `parse_session_from_cookies` / `session_cookie.rs` unit tests cover each impl's cookie
|
|
35
35
|
* codec directly). Cited property: `docs/security.md` §"Session Security"
|
|
36
36
|
* (the "Cookie attributes" bullet — `HttpOnly; Secure; SameSite=Strict; Path=/`).
|
|
37
37
|
*
|