testing/cross_backend/credential_deadline.ts

Cross-process credential deadline suite — a long-lived connection closes when the credential it was opened with expires.

A WebSocket or an audit stream is authorized once, at open, and closed on revocation by identity — but expiry writes nothing a revocation listener could hear. So each spine carries the credential's deadline onto the connection (ResolvedAuth.credential_deadline: the earlier of a session's cookie and row expiry, an API token's row expiry) and closes it there: a socket with WS_CLOSE_SESSION_REVOKED and WS_CLOSE_CREDENTIAL_EXPIRED_REASON, a stream by ending it as a revoked one ends.

Each case pulls a fresh account's credential expiries in to expiry_seconds from now with the daemon-token _testing_shorten_credential_expiry seam, before opening the connection (the deadline is read when the credential resolves), then checks the connection is open short of the deadline and closed at it:

  1. WebSocket × session — 4001, "Credential expired".
  2. WebSocket × API token — the same.
  3. Audit stream × session — the stream ends.
  4. The seam only shortens: a second call asking for a later expiry moves nothing, and the socket still closes at the first deadline.

The fourth reachable combination, API token × audit stream, is not here: the stock audit stream admits sessions only on both spines. Each spine covers it below the wire — the Rust stream route on a widened credential gate, the TS deadline wait shared by both transports.

Gated on capabilities.ws (cases 1, 2, 4) and capabilities.sse (case 3); cross-process only — the seam is mounted on the spine test binaries.

view source

Declarations
#

2 declarations

CredentialDeadlineCrossTestOptions
#

testing/cross_backend/credential_deadline.ts view source

CredentialDeadlineCrossTestOptions import type {CredentialDeadlineCrossTestOptions} from '@fuzdev/fuz_app/testing/cross_backend/credential_deadline.js';

setup_test

Per-test fixture producer (default_cross_process_setup(handle)).

type (): Promise<TestFixtureBase>

readonly
returns Promise<TestFixtureBase>

capabilities

Backend capability flags — the WebSocket cases gate on ws, the stream case on sse.

type BackendCapabilities

readonly

base_url

Base URL the backend is reachable at.

type string

readonly

ws_path

The WebSocket endpoint path (e.g. /api/ws).

type string

readonly

sse_path?

The audit-log stream path. Default /api/admin/audit/stream.

type string

readonly

rpc_path?

JSON-RPC endpoint path. Default SPINE_RPC_PATH.

type string

readonly

describe_credential_deadline_cross_tests
#

testing/cross_backend/credential_deadline.ts view source

(options: CredentialDeadlineCrossTestOptions): void import {describe_credential_deadline_cross_tests} from '@fuzdev/fuz_app/testing/cross_backend/credential_deadline.js';

Register the credential-deadline suite: a WebSocket on a session or an API token closes with 4001 "Credential expired" at its credential's expiry, an audit stream on a session ends there, and the expiry seam never extends.

options

returns

void

Depends on
#