@fuzdev/fuz_app 0.182.0 → 0.183.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/README.md +2 -0
- package/dist/actions/CLAUDE.md +4 -4
- package/dist/auth/CLAUDE.md +58 -34
- package/dist/auth/account_routes.d.ts +5 -3
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +71 -66
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +22 -17
- package/dist/auth/audit_emitter.d.ts +75 -84
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +83 -71
- package/dist/auth/audit_log_schema.d.ts +10 -5
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +22 -6
- package/dist/auth/bootstrap_account.d.ts +31 -13
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +34 -15
- package/dist/auth/bootstrap_routes.d.ts +1 -1
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +7 -14
- package/dist/auth/deps.d.ts +8 -5
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/deps.js +3 -2
- package/dist/auth/resolved_auth.d.ts +7 -7
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +4 -4
- package/dist/auth/role_grant_offer_actions.d.ts +25 -1
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +40 -33
- package/dist/auth/role_grant_offer_queries.d.ts +60 -4
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +79 -5
- package/dist/auth/role_grant_queries.d.ts +3 -52
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +5 -80
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +11 -22
- package/dist/auth/session_queries.d.ts +6 -3
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +20 -11
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +90 -38
- package/dist/db/sql_columns.d.ts +1 -1
- package/dist/db/sql_columns.js +1 -1
- package/dist/http/CLAUDE.md +15 -10
- package/dist/http/db_routes.d.ts +7 -22
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +72 -72
- package/dist/http/pending_effects.d.ts +42 -4
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +34 -4
- package/dist/server/app_server.d.ts +43 -2
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +57 -3
- package/dist/testing/CLAUDE.md +255 -786
- package/dist/testing/adversarial_404.d.ts +6 -1
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +38 -17
- package/dist/testing/app_server.d.ts +20 -140
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +45 -124
- package/dist/testing/audit_drift_guard.d.ts +11 -6
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +15 -8
- package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
- package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
- package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
- package/dist/testing/cross_backend/capabilities.d.ts +9 -6
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +11 -7
- package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
- package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
- package/dist/testing/cross_backend/capability_mounts.js +423 -0
- package/dist/testing/cross_backend/cell_moderate.js +2 -2
- package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_relations.js +12 -11
- package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
- package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
- package/dist/testing/cross_backend/conformance_principal.js +283 -0
- package/dist/testing/cross_backend/conformance_table.d.ts +2 -50
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +2 -270
- package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
- package/dist/testing/cross_backend/credential_deadline.js +2 -0
- package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
- package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
- package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
- package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
- package/dist/testing/cross_backend/db_state_diff.js +444 -0
- package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
- package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
- package/dist/testing/cross_backend/declared_skips.js +132 -0
- package/dist/testing/cross_backend/differential.d.ts +11 -2
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +35 -11
- package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
- package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential_normalize.js +16 -0
- package/dist/testing/cross_backend/in_process_setup.d.ts +22 -12
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +151 -134
- package/dist/testing/cross_backend/login_security.d.ts +12 -0
- package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
- package/dist/testing/cross_backend/login_security.js +21 -4
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
- package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
- package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
- package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
- package/dist/testing/cross_backend/revocation_drivers.js +18 -10
- package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
- package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
- package/dist/testing/cross_backend/role_grant_participation.js +4 -4
- package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
- package/dist/testing/cross_backend/session_cap.d.ts +2 -2
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +22 -11
- package/dist/testing/cross_backend/setup.d.ts +31 -1
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +32 -1
- package/dist/testing/cross_backend/spine_suites.d.ts +123 -12
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +454 -57
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
- package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +123 -27
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +4 -2
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +59 -27
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +66 -42
- package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +7 -3
- package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +54 -8
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +3 -0
- package/dist/testing/db.d.ts +0 -32
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +0 -86
- package/dist/testing/db_entities.d.ts +14 -0
- package/dist/testing/db_entities.d.ts.map +1 -1
- package/dist/testing/db_entities.js +17 -0
- package/dist/testing/db_invariant_queries.d.ts +259 -0
- package/dist/testing/db_invariant_queries.d.ts.map +1 -0
- package/dist/testing/db_invariant_queries.js +400 -0
- package/dist/testing/db_invariants.d.ts +106 -0
- package/dist/testing/db_invariants.d.ts.map +1 -0
- package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
- package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
- package/dist/testing/db_invariants.gen.sql.js +13 -0
- package/dist/testing/db_invariants.js +141 -0
- package/dist/testing/db_invariants.sql +152 -0
- package/dist/testing/describe_db.d.ts +36 -0
- package/dist/testing/describe_db.d.ts.map +1 -0
- package/dist/testing/describe_db.js +71 -0
- package/dist/testing/integration.d.ts +6 -9
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +9 -13
- package/dist/testing/integration_helpers.d.ts +1 -1
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/rate_limiting.d.ts +1 -1
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +3 -2
- package/dist/testing/role_grant_helpers.d.ts +1 -1
- package/dist/testing/role_grant_helpers.d.ts.map +1 -1
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +3 -0
- package/dist/testing/rpc_attack_surface.d.ts +8 -6
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +69 -6
- package/dist/testing/rpc_round_trip.d.ts +1 -1
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +3 -0
- package/dist/testing/sse_round_trip.d.ts +1 -1
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +13 -4
- package/dist/testing/stubs.d.ts +4 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +10 -5
- package/dist/testing/test_app.d.ts +166 -0
- package/dist/testing/test_app.d.ts.map +1 -0
- package/dist/testing/test_app.js +124 -0
- package/package.json +1 -1
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* Cross-backend suite holding a backend's mount flags to what it mounts, in
|
|
4
|
+
* both directions.
|
|
5
|
+
*
|
|
6
|
+
* A capability flag gates the suites that need its surface: `true` runs them,
|
|
7
|
+
* `false` skips them. Nothing in those suites checks a `false` — a backend
|
|
8
|
+
* declaring `cell_crud: false` while mounting the cell verbs skips the cell
|
|
9
|
+
* suites, and its cell surface goes untested with no failure anywhere. And on a
|
|
10
|
+
* backend declaring every flag `true`, as fuz_app's own spine presets do, a
|
|
11
|
+
* check of the `false` direction alone would never run. So each flag a request
|
|
12
|
+
* can observe is probed once, and the observation must equal the declaration:
|
|
13
|
+
* `true` must answer as mounted, `false` as unmounted.
|
|
14
|
+
*
|
|
15
|
+
* Each probe is the cheapest honest request — anonymous, so no setup state
|
|
16
|
+
* shapes the answer — and none of them answers a mounted surface with a `404`.
|
|
17
|
+
* An unmounted path under `/api` answers `404`: the spine's JSON
|
|
18
|
+
* `route_not_found`, or no body where a runtime drops a refused upgrade's body
|
|
19
|
+
* or a backend's own fallback answers `/api` paths.
|
|
20
|
+
*
|
|
21
|
+
* - **RPC verbs** (`cell_crud`: `cell_create`, `cell_relations`:
|
|
22
|
+
* `cell_grant_create`) — both spines look a method up before they
|
|
23
|
+
* authenticate the caller, so a mounted verb refuses an anonymous call `401`
|
|
24
|
+
* and an unmounted one answers `method_not_found` (`404`).
|
|
25
|
+
* - **Auth-gated routes** (`sse` on `sse_path`, `account_status`) — a mounted
|
|
26
|
+
* route refuses an anonymous `GET` `401`.
|
|
27
|
+
* - **The fact routes** (`fact_serving`, `fact_serving_admin_hash`) — a
|
|
28
|
+
* malformed `hash` param: both spines validate a route's params ahead of
|
|
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 a
|
|
31
|
+
* bodiless unmatched `404`.)
|
|
32
|
+
* - **`ready`** — `GET /ready` answers `200 {ready: true}`, or `503` with
|
|
33
|
+
* `schema_drift` / `db_unreachable` (mounted, if drifted — the readiness
|
|
34
|
+
* suite fails that); unmounted, a `404` (any body — the spine fallback's
|
|
35
|
+
* plain text) or a `200` that isn't JSON (a static page).
|
|
36
|
+
* - **WebSocket endpoints** (`ws` on `ws_path`, `ws_role_gated` on the gated
|
|
37
|
+
* path) — a mounted endpoint refuses an anonymous upgrade `401`.
|
|
38
|
+
* - **`ws_account_actions`** — `account_verify` sent on the keeper's session
|
|
39
|
+
* socket answers unless the endpoint lacks it (`method_not_found`). Needs
|
|
40
|
+
* `ws`: with `ws` declared `false` the probe is skipped when the flag is
|
|
41
|
+
* `false` too, and fails when it is `true`.
|
|
42
|
+
*
|
|
43
|
+
* An answer that is neither the mounted nor the unmounted one fails the probe.
|
|
44
|
+
*
|
|
45
|
+
* **Unmounted controls.** On a backend declaring every probed flag `true`, as
|
|
46
|
+
* fuz_app's spine presets do, no probe meets an unmounted surface, so a
|
|
47
|
+
* classifier reading every answer as mounted would pass. Each flag's own probe
|
|
48
|
+
* is also sent to its surface moved where no backend mounts anything
|
|
49
|
+
* (`CAPABILITY_MOUNTS_ABSENT` — the path under an absent segment, the method
|
|
50
|
+
* renamed), and must read as unmounted, on every backend. So a backend with a
|
|
51
|
+
* catch-all under `/api`, or an RPC dispatcher answering an unknown method,
|
|
52
|
+
* fails the controls: the suite rests on the spine's `404` and
|
|
53
|
+
* `method_not_found` for what isn't mounted.
|
|
54
|
+
*
|
|
55
|
+
* The other flags are listed in `UNPROBED_CAPABILITIES` with why no request
|
|
56
|
+
* checks them, and each shows in the run as a skipped test carrying that
|
|
57
|
+
* reason. `ProbedCapability` and `UNPROBED_CAPABILITIES` together are
|
|
58
|
+
* exhaustive over `BackendCapabilities` by their types, so a new flag fails to
|
|
59
|
+
* compile until it is classified.
|
|
60
|
+
*
|
|
61
|
+
* `describe_spine_cross_suites` runs this suite on every backend and refuses to
|
|
62
|
+
* exclude it, exclude one of its cases, or override any of its options: it
|
|
63
|
+
* checks the declarations every other suite gates on, so each path it probes
|
|
64
|
+
* is the one the suites gated on that flag send to — the backend config's,
|
|
65
|
+
* `ws_role_gated`'s `gated_ws_path`, `ready`'s `ready_path`, and the
|
|
66
|
+
* `SPINE_ACCOUNT_STATUS_PATH` that `query_shape`, `token_scope_surface` and
|
|
67
|
+
* `request_target_conformance_wire` (each gated on `account_status`) send to.
|
|
68
|
+
* A probe whose sibling suite the call excludes falls back to the spine
|
|
69
|
+
* default, and its failure names the remedy (`path_notes`). It runs cross-process
|
|
70
|
+
* only — in-process apps are assembled per test file, each mounting what its
|
|
71
|
+
* suite needs, so no one in-process declaration describes them, and the WS
|
|
72
|
+
* probes need a real socket.
|
|
73
|
+
*
|
|
74
|
+
* @module
|
|
75
|
+
*/
|
|
76
|
+
import { describe, test, assert } from 'vitest';
|
|
77
|
+
import { ERROR_DB_UNREACHABLE, ERROR_INVALID_ROUTE_PARAMS, ERROR_ROUTE_NOT_FOUND, ERROR_SCHEMA_DRIFT } from '../../http/error_schemas.js';
|
|
78
|
+
import { JSONRPC_ERROR_CODES } from '../../http/jsonrpc_errors.js';
|
|
79
|
+
import { rpc_call } from '../rpc_helpers.js';
|
|
80
|
+
import { create_ws_transport, WsUpgradeRefusedError } from '../transports/ws_transport.js';
|
|
81
|
+
import { is_response_for } from '../transports/ws_client.js';
|
|
82
|
+
import { test_skip_gated } from './declared_skips.js';
|
|
83
|
+
import { SPINE_ACCOUNT_STATUS_PATH, SPINE_ROLE_GATED_WS_PATH, SPINE_RPC_PATH, SPINE_SSE_PATH, SPINE_WS_PATH } from './spine_surface_constants.js';
|
|
84
|
+
import { open_session_ws } from './ws_endpoint.js';
|
|
85
|
+
/**
|
|
86
|
+
* Why each unprobed capability has no probe, shown in the run as a skipped
|
|
87
|
+
* test. Keyed by `UnprobedCapability`, so a new flag fails to compile until it
|
|
88
|
+
* is either probed or listed here.
|
|
89
|
+
*/
|
|
90
|
+
export const UNPROBED_CAPABILITIES = Object.freeze({
|
|
91
|
+
account_lifecycle: 'gates behavior, not a mount: the lifecycle verbs are on the declared surface, whose round-trip and attack-surface suites already reach them',
|
|
92
|
+
peer_request: 'the server→client request direction (`peer/ping`, a protocol action), which no request a client sends can observe; the peer suite drives it',
|
|
93
|
+
cell_gated_create: 'names a test policy over the cell verbs, not a mount — a backend mounting the verbs over its own policy states `false`; `cell_crud` probes the verbs',
|
|
94
|
+
rooms: 'names a test policy (the test room authorizer) over the room verbs, not a mount — a backend mounting rooms over its own authorizer states `false`',
|
|
95
|
+
ws_handshake_pipelining: "a trait of the backend's HTTP runtime, not a mount",
|
|
96
|
+
ws_refusal_body: "a trait of the backend's HTTP runtime, not a mount",
|
|
97
|
+
ws_upgrade_runtime_refusals: "a trait of the backend's HTTP runtime, not a mount; the request header wire leg fails a declaration the runtime doesn't honor",
|
|
98
|
+
runtime_resolves_dot_segments: "a trait of the backend's HTTP runtime, not a mount; the request target wire leg fails a declaration the runtime doesn't honor",
|
|
99
|
+
spine_fallback: "the fallback's behavior, not a mount; the request target wire leg's rows outside `/api` fail a `true` the backend doesn't honor",
|
|
100
|
+
host_gate: "the host gate's configuration, not a mount; the request header wire leg's host rows fail a `true` the backend doesn't honor",
|
|
101
|
+
testing_backdoors: 'a list, checked against the backend in both directions by the testing-backdoor suite'
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* Resolve the suite's paths, each option's default filled.
|
|
105
|
+
*
|
|
106
|
+
* @param options - the suite's options
|
|
107
|
+
* @returns where every probe sends
|
|
108
|
+
* @internal Used by the suite's own tests and `describe_spine_cross_suites`, which derives the
|
|
109
|
+
* suite's options resolved — not stable API.
|
|
110
|
+
*/
|
|
111
|
+
export const resolve_capability_mounts_target = (options) => ({
|
|
112
|
+
base_url: options.base_url,
|
|
113
|
+
rpc_path: options.rpc_path ?? SPINE_RPC_PATH,
|
|
114
|
+
ws_path: options.ws_path ?? SPINE_WS_PATH,
|
|
115
|
+
sse_path: options.sse_path ?? SPINE_SSE_PATH,
|
|
116
|
+
gated_ws_path: options.gated_ws_path ?? SPINE_ROLE_GATED_WS_PATH,
|
|
117
|
+
ready_path: options.ready_path ?? '/ready'
|
|
118
|
+
});
|
|
119
|
+
/** A well-formed UUID no row has. */
|
|
120
|
+
const PROBE_CELL_ID = '00000000-0000-4000-8000-000000000000';
|
|
121
|
+
/**
|
|
122
|
+
* A `hash` param no fact route accepts: both spines validate a route's params
|
|
123
|
+
* ahead of auth and answer the flat `400` `invalid_route_params`, an answer
|
|
124
|
+
* only a mounted route gives.
|
|
125
|
+
*/
|
|
126
|
+
const PROBE_MALFORMED_FACT_HASH = 'not-a-hash';
|
|
127
|
+
/**
|
|
128
|
+
* The name the unmounted controls send to: a path segment, RPC method and WS
|
|
129
|
+
* method no backend mounts.
|
|
130
|
+
*/
|
|
131
|
+
export const CAPABILITY_MOUNTS_ABSENT = 'capability_mounts_absent';
|
|
132
|
+
/** A path moved under `CAPABILITY_MOUNTS_ABSENT`, inside `/api` when it was. */
|
|
133
|
+
const to_absent_path = (path) => path.startsWith('/api/')
|
|
134
|
+
? `/api/${CAPABILITY_MOUNTS_ABSENT}${path.slice('/api'.length)}`
|
|
135
|
+
: `/${CAPABILITY_MOUNTS_ABSENT}${path}`;
|
|
136
|
+
/** A method renamed under `CAPABILITY_MOUNTS_ABSENT`. */
|
|
137
|
+
const to_absent_method = (method) => `${CAPABILITY_MOUNTS_ABSENT}_${method}`;
|
|
138
|
+
/** `path_of`'s path, moved when `absent`. */
|
|
139
|
+
const locate = (path_of, t, absent) => (absent ? to_absent_path(path_of(t)) : path_of(t));
|
|
140
|
+
/** Parse JSON text, `undefined` when it isn't JSON. */
|
|
141
|
+
const parse_json = (text) => {
|
|
142
|
+
try {
|
|
143
|
+
return JSON.parse(text);
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const error_of = (json) => json !== null && typeof json === 'object' ? json.error : undefined;
|
|
150
|
+
/** A status and the start of its body, for a failure message. */
|
|
151
|
+
const describe_answer = (status, text) => `${status} ${text === '' ? '(no body)' : text.slice(0, 200)}`;
|
|
152
|
+
/**
|
|
153
|
+
* Whether an answer is an unmatched path's `404` under `/api`: the spine's JSON
|
|
154
|
+
* `route_not_found`, or a bodiless one — what a runtime dropping a refused
|
|
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`.
|
|
157
|
+
*/
|
|
158
|
+
const is_unmatched_404 = (status, text) => status === 404 && (text === '' || error_of(parse_json(text)) === ERROR_ROUTE_NOT_FOUND);
|
|
159
|
+
const UNMATCHED_404 = `404 (${ERROR_ROUTE_NOT_FOUND} or no body)`;
|
|
160
|
+
/** An anonymous RPC call: `401` mounted, `method_not_found` unmounted. */
|
|
161
|
+
const rpc_probe = (declared_method) => ({
|
|
162
|
+
request: (t, absent) => `anonymous \`${absent ? to_absent_method(declared_method) : declared_method}\` on ${t.rpc_path}`,
|
|
163
|
+
mounted: '401',
|
|
164
|
+
unmounted: 'method_not_found',
|
|
165
|
+
observe: async (fixture, t, absent) => {
|
|
166
|
+
const method = absent ? to_absent_method(declared_method) : declared_method;
|
|
167
|
+
const res = await rpc_call({ app: fixture.fresh_transport(), path: t.rpc_path, method });
|
|
168
|
+
const answer = res.ok
|
|
169
|
+
? `${res.status} result`
|
|
170
|
+
: `${res.status} error ${res.error.code} ${res.error.message}`;
|
|
171
|
+
if (!res.ok && res.status === 401 && res.error.code === JSONRPC_ERROR_CODES.unauthenticated) {
|
|
172
|
+
return { mounted: true, answer };
|
|
173
|
+
}
|
|
174
|
+
if (!res.ok && res.status === 404 && res.error.code === JSONRPC_ERROR_CODES.method_not_found) {
|
|
175
|
+
return { mounted: false, answer };
|
|
176
|
+
}
|
|
177
|
+
assert.fail(`${method}: expected 401 (mounted) or method_not_found (unmounted), got ${answer}`);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
/**
|
|
181
|
+
* An anonymous `GET`: the route's own refusal mounted, an unmatched `404`
|
|
182
|
+
* unmounted.
|
|
183
|
+
*/
|
|
184
|
+
const route_probe = (path_of, mounted) => {
|
|
185
|
+
const mounted_label = `${mounted.status}${mounted.error ? ` ${mounted.error}` : ''}`;
|
|
186
|
+
return {
|
|
187
|
+
request: (t, absent) => `anonymous GET ${locate(path_of, t, absent)}`,
|
|
188
|
+
mounted: mounted_label,
|
|
189
|
+
unmounted: UNMATCHED_404,
|
|
190
|
+
observe: async (fixture, t, absent) => {
|
|
191
|
+
const path = locate(path_of, t, absent);
|
|
192
|
+
const res = await fixture.fresh_transport()(path, { method: 'GET' });
|
|
193
|
+
const text = await res.text();
|
|
194
|
+
const answer = describe_answer(res.status, text);
|
|
195
|
+
if (res.status === mounted.status &&
|
|
196
|
+
(mounted.error === undefined || error_of(parse_json(text)) === mounted.error)) {
|
|
197
|
+
return { mounted: true, answer };
|
|
198
|
+
}
|
|
199
|
+
if (is_unmatched_404(res.status, text))
|
|
200
|
+
return { mounted: false, answer };
|
|
201
|
+
assert.fail(`GET ${path}: expected ${mounted_label} (mounted) or ${UNMATCHED_404} (unmounted), got ${answer}`);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
/** An anonymous upgrade: refused `401` mounted, `404` unmounted. */
|
|
206
|
+
const upgrade_probe = (path_of) => ({
|
|
207
|
+
request: (t, absent) => `anonymous upgrade on ${locate(path_of, t, absent)}`,
|
|
208
|
+
mounted: '401',
|
|
209
|
+
unmounted: UNMATCHED_404,
|
|
210
|
+
observe: async (_fixture, t, absent) => {
|
|
211
|
+
const ws_path = locate(path_of, t, absent);
|
|
212
|
+
let refusal;
|
|
213
|
+
try {
|
|
214
|
+
const client = await create_ws_transport({
|
|
215
|
+
base_url: t.base_url,
|
|
216
|
+
ws_path,
|
|
217
|
+
cookies: [],
|
|
218
|
+
origin: t.base_url
|
|
219
|
+
});
|
|
220
|
+
await client.close();
|
|
221
|
+
assert.fail(`upgrade on ${ws_path}: an anonymous socket opened`);
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
if (!(error instanceof WsUpgradeRefusedError))
|
|
225
|
+
throw error;
|
|
226
|
+
refusal = error;
|
|
227
|
+
}
|
|
228
|
+
const answer = describe_answer(refusal.status, refusal.body);
|
|
229
|
+
if (refusal.status === 401)
|
|
230
|
+
return { mounted: true, answer };
|
|
231
|
+
if (is_unmatched_404(refusal.status, refusal.body))
|
|
232
|
+
return { mounted: false, answer };
|
|
233
|
+
assert.fail(`upgrade on ${ws_path}: expected a 401 (mounted) or 404 (unmounted) refusal, got ${answer}`);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
/**
|
|
237
|
+
* `GET` of a readiness route outside `/api`: `200 {ready: true}`, or `503`
|
|
238
|
+
* with a drift code, mounted; a `404` (any body — the fallback's plain text
|
|
239
|
+
* included) or a `200` that isn't JSON (a static page) unmounted.
|
|
240
|
+
*/
|
|
241
|
+
const ready_probe = (path_of) => ({
|
|
242
|
+
request: (t, absent) => `GET ${locate(path_of, t, absent)}`,
|
|
243
|
+
mounted: `200 {ready: true} (or 503 ${ERROR_SCHEMA_DRIFT} / ${ERROR_DB_UNREACHABLE})`,
|
|
244
|
+
unmounted: '404, or a 200 that is not JSON',
|
|
245
|
+
observe: async (fixture, t, absent) => {
|
|
246
|
+
const path = locate(path_of, t, absent);
|
|
247
|
+
const res = await fixture.fresh_transport({ origin: null })(path, { method: 'GET' });
|
|
248
|
+
const text = await res.text();
|
|
249
|
+
const json = parse_json(text);
|
|
250
|
+
const answer = describe_answer(res.status, text);
|
|
251
|
+
const ready = json !== null && typeof json === 'object' && 'ready' in json && json.ready;
|
|
252
|
+
const error = error_of(json);
|
|
253
|
+
if ((res.status === 200 && ready === true) ||
|
|
254
|
+
(res.status === 503 && (error === ERROR_SCHEMA_DRIFT || error === ERROR_DB_UNREACHABLE))) {
|
|
255
|
+
return { mounted: true, answer };
|
|
256
|
+
}
|
|
257
|
+
if (res.status === 404 || (res.status === 200 && json === undefined)) {
|
|
258
|
+
return { mounted: false, answer };
|
|
259
|
+
}
|
|
260
|
+
assert.fail(`GET ${path}: expected 200 {ready: true} or a drift 503 (mounted), or a 404 or a ` +
|
|
261
|
+
`non-JSON 200 (unmounted), got ${answer}`);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
/** A method sent on the keeper's session socket: any answer mounted, `method_not_found` unmounted. */
|
|
265
|
+
const socket_method_probe = (declared_method) => ({
|
|
266
|
+
request: (t, absent) => `\`${absent ? to_absent_method(declared_method) : declared_method}\` on the keeper's session socket on ${t.ws_path}`,
|
|
267
|
+
mounted: 'an answer',
|
|
268
|
+
unmounted: 'method_not_found',
|
|
269
|
+
observe: async (fixture, t, absent) => {
|
|
270
|
+
const method = absent ? to_absent_method(declared_method) : declared_method;
|
|
271
|
+
const client = await open_session_ws({ base_url: t.base_url, ws_path: t.ws_path }, fixture, {
|
|
272
|
+
admitted: true
|
|
273
|
+
});
|
|
274
|
+
try {
|
|
275
|
+
const id = `capability_mounts_${method}`;
|
|
276
|
+
await client.send({ jsonrpc: '2.0', id, method });
|
|
277
|
+
const frame = await client.wait_for(is_response_for(id));
|
|
278
|
+
const answer = JSON.stringify(frame).slice(0, 200);
|
|
279
|
+
return { mounted: frame.error?.code !== JSONRPC_ERROR_CODES.method_not_found, answer };
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
await client.close();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
const PROBES = {
|
|
287
|
+
ws: upgrade_probe((t) => t.ws_path),
|
|
288
|
+
sse: route_probe((t) => t.sse_path, { status: 401 }),
|
|
289
|
+
cell_crud: rpc_probe('cell_create'),
|
|
290
|
+
cell_relations: rpc_probe('cell_grant_create'),
|
|
291
|
+
fact_serving: route_probe(() => `/api/cells/${PROBE_CELL_ID}/facts/${PROBE_MALFORMED_FACT_HASH}`, { status: 400, error: ERROR_INVALID_ROUTE_PARAMS }),
|
|
292
|
+
fact_serving_admin_hash: route_probe(() => `/api/facts/${PROBE_MALFORMED_FACT_HASH}`, {
|
|
293
|
+
status: 400,
|
|
294
|
+
error: ERROR_INVALID_ROUTE_PARAMS
|
|
295
|
+
}),
|
|
296
|
+
ready: ready_probe((t) => t.ready_path),
|
|
297
|
+
account_status: route_probe(() => SPINE_ACCOUNT_STATUS_PATH, { status: 401 }),
|
|
298
|
+
ws_account_actions: socket_method_probe('account_verify'),
|
|
299
|
+
ws_role_gated: upgrade_probe((t) => t.gated_ws_path)
|
|
300
|
+
};
|
|
301
|
+
/** Every probed capability, in the order the suite runs them. */
|
|
302
|
+
export const PROBED_CAPABILITIES = Object.freeze(Object.keys(PROBES));
|
|
303
|
+
/**
|
|
304
|
+
* Plan the suite's tests from a backend's capabilities and paths — what
|
|
305
|
+
* `describe_capability_mounts_cross_tests` registers, as data, so the
|
|
306
|
+
* classification is checkable without a backend.
|
|
307
|
+
*
|
|
308
|
+
* @param capabilities - the backend's declarations
|
|
309
|
+
* @param target - where the probes send
|
|
310
|
+
* @param path_notes - a note per flag added to its probe's failure
|
|
311
|
+
* @returns every row, in registration order
|
|
312
|
+
* @internal Used by the suite's own tests — not stable API.
|
|
313
|
+
*/
|
|
314
|
+
export const plan_capability_mount_rows = (capabilities, target, path_notes = {}) => {
|
|
315
|
+
const rows = [];
|
|
316
|
+
const noop = () => Promise.resolve();
|
|
317
|
+
for (const flag of PROBED_CAPABILITIES) {
|
|
318
|
+
const probe = PROBES[flag];
|
|
319
|
+
const declared = capabilities[flag];
|
|
320
|
+
const name = `${flag} declared ${declared}: ${probe.request(target, false)} → ` +
|
|
321
|
+
(declared ? probe.mounted : probe.unmounted);
|
|
322
|
+
// the account-actions probe needs a socket; with no WS endpoint
|
|
323
|
+
// declared, a `false` has nothing to probe, and a `true` is wrong
|
|
324
|
+
if (flag === 'ws_account_actions' && !capabilities.ws) {
|
|
325
|
+
rows.push(declared
|
|
326
|
+
? {
|
|
327
|
+
group: 'capability mounts',
|
|
328
|
+
name,
|
|
329
|
+
mode: 'fail',
|
|
330
|
+
body: () => Promise.reject(new Error('capabilities.ws_account_actions is true, but capabilities.ws is false — ' +
|
|
331
|
+
'the account actions need a WebSocket endpoint to be mounted on'))
|
|
332
|
+
}
|
|
333
|
+
: {
|
|
334
|
+
group: 'capability mounts',
|
|
335
|
+
name: `${flag}: no WebSocket endpoint to probe (capabilities.ws is false)`,
|
|
336
|
+
mode: 'gated_skip',
|
|
337
|
+
body: noop
|
|
338
|
+
});
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
rows.push({
|
|
342
|
+
group: 'capability mounts',
|
|
343
|
+
name,
|
|
344
|
+
mode: 'run',
|
|
345
|
+
body: async (setup_test) => {
|
|
346
|
+
const observed = await probe.observe(await setup_test(), target, false);
|
|
347
|
+
const mismatch = declared
|
|
348
|
+
? `capabilities.${flag} is true, but the backend doesn't mount it — ` +
|
|
349
|
+
`${probe.request(target, false)} answered ${observed.answer}`
|
|
350
|
+
: `capabilities.${flag} is false, but the backend mounts it — ` +
|
|
351
|
+
`${probe.request(target, false)} answered ${observed.answer}; declare it true`;
|
|
352
|
+
const note = path_notes[flag];
|
|
353
|
+
assert.strictEqual(observed.mounted, declared, note === undefined ? mismatch : `${mismatch} (${note})`);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
for (const flag of PROBED_CAPABILITIES) {
|
|
358
|
+
const probe = PROBES[flag];
|
|
359
|
+
const name = `${flag} control: ${probe.request(target, true)} → ${probe.unmounted}`;
|
|
360
|
+
// the account-actions control sends on the keeper's socket too
|
|
361
|
+
if (flag === 'ws_account_actions' && !capabilities.ws) {
|
|
362
|
+
rows.push({
|
|
363
|
+
group: 'capability mount controls',
|
|
364
|
+
name: `${name}: no WebSocket endpoint (capabilities.ws is false)`,
|
|
365
|
+
mode: 'gated_skip',
|
|
366
|
+
body: noop
|
|
367
|
+
});
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
rows.push({
|
|
371
|
+
group: 'capability mount controls',
|
|
372
|
+
name,
|
|
373
|
+
mode: 'run',
|
|
374
|
+
body: async (setup_test) => {
|
|
375
|
+
const observed = await probe.observe(await setup_test(), target, true);
|
|
376
|
+
assert.strictEqual(observed.mounted, false, `${probe.request(target, true)} reads as mounted (answered ${observed.answer}) — ` +
|
|
377
|
+
`the ${flag} probe's classifier is broken, or the backend answers a surface it doesn't mount`);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
for (const [flag, reason] of Object.entries(UNPROBED_CAPABILITIES)) {
|
|
382
|
+
rows.push({
|
|
383
|
+
group: 'capability mounts not probed',
|
|
384
|
+
name: `${flag}: ${reason}`,
|
|
385
|
+
mode: 'skip',
|
|
386
|
+
body: noop
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
return rows;
|
|
390
|
+
};
|
|
391
|
+
/**
|
|
392
|
+
* Register the capability mount suite: one probe per `ProbedCapability`, each
|
|
393
|
+
* asserting the backend's answer matches its declaration, the same probe again
|
|
394
|
+
* as an unmounted control, and one skipped test per `UNPROBED_CAPABILITIES`
|
|
395
|
+
* entry naming why.
|
|
396
|
+
*
|
|
397
|
+
* @param options - the fixture, the backend's capabilities, and its paths
|
|
398
|
+
*/
|
|
399
|
+
export const describe_capability_mounts_cross_tests = (options) => {
|
|
400
|
+
const { setup_test, capabilities } = options;
|
|
401
|
+
const rows = plan_capability_mount_rows(capabilities, resolve_capability_mounts_target(options), options.path_notes);
|
|
402
|
+
for (const group of [
|
|
403
|
+
'capability mounts',
|
|
404
|
+
'capability mount controls',
|
|
405
|
+
'capability mounts not probed'
|
|
406
|
+
]) {
|
|
407
|
+
describe(group, () => {
|
|
408
|
+
for (const row of rows) {
|
|
409
|
+
if (row.group !== group)
|
|
410
|
+
continue;
|
|
411
|
+
if (row.mode === 'skip') {
|
|
412
|
+
test.skip(row.name, () => { });
|
|
413
|
+
}
|
|
414
|
+
else if (row.mode === 'gated_skip') {
|
|
415
|
+
test_skip_gated(row.name, () => { });
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
test(row.name, () => row.body(setup_test));
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
};
|
|
@@ -380,8 +380,8 @@ export const describe_cell_moderate_cross_tests = (options) => {
|
|
|
380
380
|
const react = expect_output(await cross_rpc_call(fixture.transport, rpc_path, 'cell_create', { kind: 'react', data: {}, parent_id: space.cell.id, visibility: 'public' }, author_h), CellCreateOutput);
|
|
381
381
|
await set_visibility(fixture, author_h, post.cell.id, 'public');
|
|
382
382
|
const collection = expect_output(await cross_rpc_call(fixture.transport, rpc_path, 'cell_create', { kind: 'collection', data: {}, visibility: 'public' }, author_h), CellCreateOutput);
|
|
383
|
-
const pos_a = fractional_index_between(null, null);
|
|
384
|
-
const pos_b = fractional_index_between(pos_a, null);
|
|
383
|
+
const pos_a = fractional_index_between(null, null, { jitter: false });
|
|
384
|
+
const pos_b = fractional_index_between(pos_a, null, { jitter: false });
|
|
385
385
|
for (const [child_id, position] of [
|
|
386
386
|
[post.cell.id, pos_a],
|
|
387
387
|
[react.cell.id, pos_b]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell_relations.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/cell_relations.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"cell_relations.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/cell_relations.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAgH9B,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,YAAY,CAAC;AAuE1E,eAAO,MAAM,mCAAmC,GAC/C,SAAS,uCAAuC,KAC9C,IAwtCF,CAAC"}
|
|
@@ -33,7 +33,8 @@ import '../assert_dev_env.js';
|
|
|
33
33
|
* out-of-range or mistyped `limit` (`0`, `-1`, `1.5`, past the max, `null`,
|
|
34
34
|
* a string) is `invalid_params` in every direction, and the reverse lists
|
|
35
35
|
* read oldest edge first.
|
|
36
|
-
* - **items** — `cell_item_insert` at fractional-index positions
|
|
36
|
+
* - **items** — `cell_item_insert` at fractional-index positions (generated
|
|
37
|
+
* without jitter, so every run and both backends send one key sequence), forward
|
|
37
38
|
* (lex-ordered) + reverse `cell_item_list`, `cell_item_move`, idempotent
|
|
38
39
|
* `cell_item_delete`; an insert or a move onto a taken position →
|
|
39
40
|
* `invalid_params` `cell_item_position_taken`, leaving the rows as they were.
|
|
@@ -90,8 +91,8 @@ const create_cell = async (t, rpc_path, h, params) => expect_output(await cross_
|
|
|
90
91
|
* `auth/cell_relation_visibility.db.test.ts`.
|
|
91
92
|
*/
|
|
92
93
|
const wire_children = async (t, rpc_path, owner_h, parent, pub_child, priv_child) => {
|
|
93
|
-
const pos_a = fractional_index_between(null, null);
|
|
94
|
-
const pos_b = fractional_index_between(pos_a, null);
|
|
94
|
+
const pos_a = fractional_index_between(null, null, { jitter: false });
|
|
95
|
+
const pos_b = fractional_index_between(pos_a, null, { jitter: false });
|
|
95
96
|
expect_output(await cross_rpc_call(t, rpc_path, 'cell_item_insert', { parent_id: parent, child_id: pub_child, position: pos_a }, owner_h), CellItemInsertOutput);
|
|
96
97
|
expect_output(await cross_rpc_call(t, rpc_path, 'cell_item_insert', { parent_id: parent, child_id: priv_child, position: pos_b }, owner_h), CellItemInsertOutput);
|
|
97
98
|
expect_output(await cross_rpc_call(t, rpc_path, 'cell_field_set', { source_id: parent, name: 'pub_link', target_id: pub_child }, owner_h), CellFieldSetOutput);
|
|
@@ -249,7 +250,7 @@ export const describe_cell_relations_cross_tests = (options) => {
|
|
|
249
250
|
const hub = await make();
|
|
250
251
|
const parent = await make();
|
|
251
252
|
const source = await make();
|
|
252
|
-
const positions = fractional_indices_between(null, null, inbound);
|
|
253
|
+
const positions = fractional_indices_between(null, null, inbound, { jitter: false });
|
|
253
254
|
for (let i = 0; i < inbound; i++) {
|
|
254
255
|
expect_output(await cross_rpc_call(t, rpc_path, 'cell_item_insert', { parent_id: parent, child_id: hub, position: positions[i] }, h), CellItemInsertOutput);
|
|
255
256
|
expect_output(await cross_rpc_call(t, rpc_path, 'cell_field_set', { source_id: source, name: `link_${i}`, target_id: hub }, h), CellFieldSetOutput);
|
|
@@ -284,7 +285,7 @@ export const describe_cell_relations_cross_tests = (options) => {
|
|
|
284
285
|
const source = await make('public');
|
|
285
286
|
const parent = await make('public');
|
|
286
287
|
const padding = CELL_RELATION_LIST_LIMIT_DEFAULT + 1;
|
|
287
|
-
const positions = fractional_indices_between(null, null, padding + 1);
|
|
288
|
+
const positions = fractional_indices_between(null, null, padding + 1, { jitter: false });
|
|
288
289
|
for (let i = 0; i <= padding; i++) {
|
|
289
290
|
const end = await make(i < padding ? 'private' : 'public');
|
|
290
291
|
const name = `link_${String(i).padStart(3, '0')}`;
|
|
@@ -362,10 +363,10 @@ export const describe_cell_relations_cross_tests = (options) => {
|
|
|
362
363
|
const parent = await make();
|
|
363
364
|
const child_a = await make();
|
|
364
365
|
const child_b = await make();
|
|
365
|
-
const pos_a = fractional_index_between(null, null);
|
|
366
|
+
const pos_a = fractional_index_between(null, null, { jitter: false });
|
|
366
367
|
const ins_a = expect_output(await cross_rpc_call(t, rpc_path, 'cell_item_insert', { parent_id: parent, child_id: child_a, position: pos_a }, h), CellItemInsertOutput);
|
|
367
368
|
assert.strictEqual(ins_a.item.child_id, child_a);
|
|
368
|
-
const pos_b = fractional_index_between(pos_a, null);
|
|
369
|
+
const pos_b = fractional_index_between(pos_a, null, { jitter: false });
|
|
369
370
|
expect_output(await cross_rpc_call(t, rpc_path, 'cell_item_insert', { parent_id: parent, child_id: child_b, position: pos_b }, h), CellItemInsertOutput);
|
|
370
371
|
// Forward list is lex-ordered by position; child_a (pos_a < pos_b) first.
|
|
371
372
|
const forward = expect_output(await cross_rpc_call(t, rpc_path, 'cell_item_list', { parent_id: parent }, h), CellItemListOutput);
|
|
@@ -376,7 +377,7 @@ export const describe_cell_relations_cross_tests = (options) => {
|
|
|
376
377
|
const reverse = expect_output(await cross_rpc_call(t, rpc_path, 'cell_item_list', { child_id: child_a }, h), CellItemListOutput);
|
|
377
378
|
assert.ok(reverse.items.some((i) => i.parent_id === parent), 'reverse item_list missing the parent');
|
|
378
379
|
// Move child_b ahead of child_a.
|
|
379
|
-
const new_pos = fractional_index_between(null, pos_a);
|
|
380
|
+
const new_pos = fractional_index_between(null, pos_a, { jitter: false });
|
|
380
381
|
const moved = expect_output(await cross_rpc_call(t, rpc_path, 'cell_item_move', { parent_id: parent, position: pos_b, new_position: new_pos }, h), CellItemMoveOutput);
|
|
381
382
|
assert.strictEqual(moved.item.position, new_pos);
|
|
382
383
|
assert.strictEqual(moved.item.child_id, child_b);
|
|
@@ -396,8 +397,8 @@ export const describe_cell_relations_cross_tests = (options) => {
|
|
|
396
397
|
const child_a = await make();
|
|
397
398
|
const child_b = await make();
|
|
398
399
|
const child_c = await make();
|
|
399
|
-
const pos_a = fractional_index_between(null, null);
|
|
400
|
-
const pos_b = fractional_index_between(pos_a, null);
|
|
400
|
+
const pos_a = fractional_index_between(null, null, { jitter: false });
|
|
401
|
+
const pos_b = fractional_index_between(pos_a, null, { jitter: false });
|
|
401
402
|
for (const [child_id, position] of [
|
|
402
403
|
[child_a, pos_a],
|
|
403
404
|
[child_b, pos_b]
|
|
@@ -429,7 +430,7 @@ export const describe_cell_relations_cross_tests = (options) => {
|
|
|
429
430
|
const source = await make('orig');
|
|
430
431
|
const child = await make('child');
|
|
431
432
|
const field_target = await make('target');
|
|
432
|
-
const child_pos = fractional_index_between(null, null);
|
|
433
|
+
const child_pos = fractional_index_between(null, null, { jitter: false });
|
|
433
434
|
expect_output(await cross_rpc_call(t, rpc_path, 'cell_item_insert', { parent_id: source, child_id: child, position: child_pos }, h), CellItemInsertOutput);
|
|
434
435
|
expect_output(await cross_rpc_call(t, rpc_path, 'cell_field_set', { source_id: source, name: 'link', target_id: field_target }, h), CellFieldSetOutput);
|
|
435
436
|
// Shallow clone: new owned cell, path nulled, item edge shares the
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
import { type resolve_rpc_endpoints_for_setup } from '../rpc_helpers.js';
|
|
3
|
+
import type { FetchTransport } from '../transports/fetch_transport.js';
|
|
4
|
+
import { type ConformancePrincipal } from './conformance_case.js';
|
|
5
|
+
import type { TestFixture } from './setup.js';
|
|
6
|
+
/**
|
|
7
|
+
* Names a seeded `extra_accounts` username for the `role_holder` /
|
|
8
|
+
* `wrong_role` principals — the only two that aren't backed by an
|
|
9
|
+
* always-available fixture accessor. Suites exercising those principals
|
|
10
|
+
* declare the matching `extra_accounts` at setup and name them here.
|
|
11
|
+
*/
|
|
12
|
+
export interface ConformancePrincipalConfig {
|
|
13
|
+
/** `extra_accounts` username for the `role_holder` principal. */
|
|
14
|
+
readonly role_holder?: string;
|
|
15
|
+
/** `extra_accounts` username for the `wrong_role` principal. */
|
|
16
|
+
readonly wrong_role?: string;
|
|
17
|
+
}
|
|
18
|
+
/** A resolved principal: the transport + headers a case fires through. */
|
|
19
|
+
export interface ResolvedConformancePrincipal {
|
|
20
|
+
readonly transport: FetchTransport;
|
|
21
|
+
readonly headers: Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Suppress the default `Origin` header on the request. Required for
|
|
24
|
+
* non-browser credential probes (bearer / daemon) — `bearer_auth`
|
|
25
|
+
* discards the token when `Origin` / `Referer` is present.
|
|
26
|
+
*/
|
|
27
|
+
readonly suppress_default_origin?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The actor of the account the credential names — what the `principal`
|
|
30
|
+
* acting binding writes. Absent for principals that present no account.
|
|
31
|
+
*/
|
|
32
|
+
readonly actor_id?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Map a `ConformancePrincipal` onto the transport + headers it
|
|
36
|
+
* authenticates with, reading exclusively from the per-test `TestFixture`.
|
|
37
|
+
*
|
|
38
|
+
* The always-available principals resolve from fixture accessors (the dead
|
|
39
|
+
* credentials that need a server-side state — a revoked session or token, an
|
|
40
|
+
* expired token — from the fixture's `mint_*` seams); `role_holder` /
|
|
41
|
+
* `wrong_role` read a seeded `extra_accounts` entry named via
|
|
42
|
+
* `options.principals` (throws a clear setup error when unconfigured);
|
|
43
|
+
* `scoped_token` mints its narrowed credential over the production path.
|
|
44
|
+
* Also used outside the table by suites that send a principal's requests
|
|
45
|
+
* themselves (`describe_rpc_adversarial_cross_tests`).
|
|
46
|
+
*
|
|
47
|
+
* @param fixture - the per-test fixture
|
|
48
|
+
* @param as - the principal
|
|
49
|
+
* @param principals - usernames for `role_holder` / `wrong_role`
|
|
50
|
+
* @param resolved_rpc_endpoints - the endpoints `scoped_token` mints through
|
|
51
|
+
* @returns the transport and headers the principal sends with
|
|
52
|
+
*/
|
|
53
|
+
export declare const resolve_conformance_principal: (fixture: TestFixture, as: ConformancePrincipal, principals?: ConformancePrincipalConfig, resolved_rpc_endpoints?: ReturnType<typeof resolve_rpc_endpoints_for_setup>) => Promise<ResolvedConformancePrincipal>;
|
|
54
|
+
//# sourceMappingURL=conformance_principal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance_principal.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/conformance_principal.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAiB9B,OAAO,EAAmB,KAAK,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAgC,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IAC1C,iEAAiE;IACjE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,gEAAgE;IAChE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,0EAA0E;AAC1E,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAwFD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,GACzC,SAAS,WAAW,EACpB,IAAI,oBAAoB,EACxB,aAAa,0BAA0B,EACvC,yBAAwB,UAAU,CAAC,OAAO,+BAA+B,CAAM,KAC7E,OAAO,CAAC,4BAA4B,CA8KtC,CAAC"}
|