testing/cross_backend/session_cap.ts view source
(options: SessionCapCrossTestOptions): void import {describe_session_cap_cross_tests} from '@fuzdev/fuz_app/testing/cross_backend/session_cap.js'; options
returns
void Cross-backend parity suite for the per-account concurrent-session cap over real HTTP.
Both spines cap concurrent sessions per account (the TS
query_session_enforce_limit / DEFAULT_MAX_SESSIONS, the Rust
create_capped_session). Each spine's own tests pin its half in-process;
nothing in them crosses the wire, so a spine that lost the cap would fail
no shared test. This suite is the pin that runs on *both*. It pins:
max_sessions + 1 times succeeds every time (a login is never denied for
being the one over the line), and the newest cookie resolves afterward.is_current — each
login's account_session_list marks exactly one row, its own, over HTTP
and (when ws mounts the account actions) over a socket the login
opened, and a bearer or daemon-token caller's list marks none (no session
authenticated it), even when a session cookie rides beside the daemon
token. Computed per request, so two logins see different current rows.ws is supplied) — the cap
deletes the session row, and a WebSocket never re-reads its session, so
the login that evicts it must close the socket it opened
(WS_CLOSE_SESSION_REVOKED), once the eviction has committed. A spine
that only deletes the row leaves the socket running on a dead session.Why max_sessions + 1 logins and not max_sessions. The starting session
count isn't zero and isn't guaranteed equal across impls — create_account
seeds its own session on the Rust cradle. Overshooting by one guarantees at
least one eviction whatever the baseline is, and the *oldest* login is the
first to go either way. Asserting on the first and last sessions rather than
on a row count keeps the case wire-observable (no DB channel) and
baseline-independent.
Both surfaces are flat REST (POST /api/account/login, GET /api/account/status)
on every spine, so this is an imperative suite (not a conformance_table row)
— the sibling of cookie_attributes.ts / origin.ts / login_security.ts.
Cross-process only, and load-bearingly so: each login is held on its own
fresh_transport and identified by that transport's cookie jar, which
in-process is a jar-less passthrough. That also keeps the suite free of a
fourth Set-Cookie parser — reading the raw header is cookie_attributes.ts's
job, and this case only needs "does this login still authenticate".
What it does not pin: concurrent creators. Two simultaneous logins can each evict against a stale count under Read Committed and both commit above the cap — see query_session_enforce_limit's race note. That needs a barrier-based test against one backend, not a parity case.
2 declarations
testing/cross_backend/session_cap.ts view source
(options: SessionCapCrossTestOptions): void import {describe_session_cap_cross_tests} from '@fuzdev/fuz_app/testing/cross_backend/session_cap.js'; optionsvoid testing/cross_backend/session_cap.ts view source
SessionCapCrossTestOptions import type {SessionCapCrossTestOptions} from '@fuzdev/fuz_app/testing/cross_backend/session_cap.js'; Options for the session-cap parity suite.
setup_testPer-test fixture producer (cross-process only — see the module doc).
type (): Promise<TestFixture>
Promise<TestFixture>max_sessions?The cap both spines enforce. Defaults to DEFAULT_MAX_SESSIONS — the TS
route default and the Rust const. A consumer that overrides
max_sessions on the TS side passes its value here.
type number
login_path?REST login route path. Default /api/account/login.
type string
status_path?REST account-status route path. Default /api/account/status.
type string
rpc_path?JSON-RPC endpoint path, for the session-list case. Default SPINE_RPC_PATH.
type string
ws?Where the backend's WebSocket endpoint is, for the case that an evicted
session's socket is closed. Pass it when the backend has a WS transport
(capabilities.ws); omitted, that case is skipped.
type WsEndpointTarget
ws_account_actions?Whether the ws endpoint mounts the self-service account actions
(capabilities.ws_account_actions), so the session-list case also lists
over a socket. Default false.
type boolean
ws_account_roles?The roles the account whose socket the ws case watches is created with, for a
backend whose WS upgrade requires a role (an admin-gated /api/ws
refuses a roleless account's upgrade). Each must be admin-grantable — the
fixture offers it. Default none.
type readonly string[]