testing/cross_backend/credential_conformance_wire.ts

The credential conformance table over raw sockets: each row's header lines sent to the live backend as they are written, and the real outcome asserted — which credential authenticated the request, and whether the response clears the session cookie.

Where credential_conformance.ts asks a backend how it *reads* the lines (through its credential-read backdoor), this sends them: the runtime's HTTP parser, its joining of repeated lines, and the whole middleware chain sit between the bytes and the answer. It is what proves a repeated Authorization line authenticates nothing on a WebSocket upgrade, that a non-ASCII byte in a sibling cookie hides nothing, and that the clear is on the wire with the exact string. It needs no backdoor of its own, so it runs on a backend that doesn't mount that backdoor.

Which credential authenticated is read from account_verify, which answers the calling account: the session cookie, the API token and the daemon token each belong to a different account (two seeded extra_accounts, and the keeper behind the daemon token), so the account in the answer names the credential, and a 401 names none.

Every row is sent twice:

  • as an RPC POST — status, the answering account, the session Set-Cookie lines (exactly the clearing string, or none), and exactly one response on the connection;
  • as a WebSocket upgrade (capabilities.ws) — 101 when a credential authenticates and 401 otherwise, the clear on a refusal and never on an accepted upgrade; and on the accepted socket an account_verify frame (capabilities.ws_account_actions), whose answering account names the credential the upgrade was admitted on.

A request carries no Origin, which the bearer and daemon-token legs would read as a browser context.

Beside the table, imperative cases for what a row can't say: the clear's scope (cleared on an unrouted path under the auth scope and on its bare prefix, not outside it), its order against a handler's own Set-Cookie (a login carrying a stale cookie answers the clear, then the new cookie), and the cookie a login mints being the raw signed value, which authenticates as sent.

What it needs of a backend, beyond the spine's auth stack:

  • account_verify on the RPC endpoint (rpc_path), admitting a session, an API token and the daemon token — the standard account actions. A backend answering method_not_found fails the suite naming it.
  • The POST login route at login_path.
  • A setup_test seeding the two extra_accounts credential_wire.ts names (create_credential_wire_seed), the session one with CREDENTIAL_SESSION_ACCOUNT_PASSWORD (the login case signs in as it — the suite creates no account of its own, so it needs neither signup nor invites), and no extra_actors: the upgrade leg sends no acting selector, which a multi-actor keeper's upgrade requires.
  • With capabilities.ws: the upgrade at ws_path admitting each of the three credentials with no Origin. Where the upgrade is role-gated, the two accounts and the keeper hold its roles (seeded — extra_accounts' roles and extra_keeper_roles).
  • With capabilities.ws_account_actions: account_verify on that socket. Without it the upgrade leg pins status and clear alone.

Raw-socket by necessity, so cross-process only.

view source

Declarations
#

2 declarations

CredentialConformanceWireCrossTestOptions
#

testing/cross_backend/credential_conformance_wire.ts view source

CredentialConformanceWireCrossTestOptions import type {CredentialConformanceWireCrossTestOptions} from '@fuzdev/fuz_app/testing/cross_backend/credential_conformance_wire.js';

setup_test

Per-test fixture producer (cross-process), seeding the CREDENTIAL_SESSION_ACCOUNT_USERNAME (with CREDENTIAL_SESSION_ACCOUNT_PASSWORD) and CREDENTIAL_BEARER_ACCOUNT_USERNAME extra_accounts, and no extra_actors. Where the backend's WebSocket upgrade is role-gated, both accounts and the keeper (extra_keeper_roles) hold its roles.

type (): Promise<TestFixture>

readonly
returns Promise<TestFixture>

capabilities

ws gates the upgrade leg, ws_account_actions its account_verify frame on each accepted socket.

type BackendCapabilities

readonly

base_url

Base URL the spawned backend is reachable at (e.g. http://localhost:1178).

type string

readonly

cookie_name

The spine's session cookie name (handle.config.cookie_name).

type string

readonly

cookie_keys

The backend's SECRET_FUZ_COOKIE_KEYS value (handle.config.env.SECRET_FUZ_COOKIE_KEYS) — the suite signs the cookie spellings the table names with its primary key.

type string

readonly

daemon_token

A valid daemon token (keeper) — handle.daemon_token.

type string

readonly

rpc_path?

JSON-RPC endpoint path. Default SPINE_RPC_PATH.

type string

readonly

ws_path?

WebSocket endpoint path. Default SPINE_WS_PATH.

type string

readonly

login_path?

REST login route path. Default SPINE_ACCOUNT_LOGIN_PATH.

type string

readonly

describe_credential_conformance_wire_cross_tests
#

Depends on
#

Imported by
#