testing/cross_backend/credential_wire.ts

What the raw-socket conformance suites share: the accounts that name a credential, the raw account_verify request and upgrade they send, and how they read which credential an answer is for.

Each of the three credentials belongs to a different account — the session cookie and the API token to two seeded extra_accounts, the daemon token to the keeper — so the account account_verify answers as names the credential that authenticated, and a 401 names none. credential_conformance_wire.ts and request_header_conformance_wire.ts read their rows' outcomes this way.

view source

Declarations
#

17 declarations

AuthenticatedCredential
#

create_credential_wire_seed
#

testing/cross_backend/credential_wire.ts view source

(ws_required_roles?: readonly string[]): CrossProcessSetupOptions import {create_credential_wire_seed} from '@fuzdev/fuz_app/testing/cross_backend/credential_wire.js';

The seeding the credential suites need: the two accounts, each holding ws_required_roles so it can open a socket where the upgrade is role-gated, and the keeper behind the daemon token holding them too.

ws_required_roles?

the roles the backend's WebSocket upgrade requires

type readonly string[]
optional default []

returns

CrossProcessSetupOptions

CREDENTIAL_BEARER_ACCOUNT_USERNAME
#

testing/cross_backend/credential_wire.ts view source

"credential_bearer" import {CREDENTIAL_BEARER_ACCOUNT_USERNAME} from '@fuzdev/fuz_app/testing/cross_backend/credential_wire.js';

The extra_accounts username whose API token the suites send. Their setup_test must seed it.

credential_of_verify_envelope
#

testing/cross_backend/credential_wire.ts view source

(envelope: unknown, accounts: CredentialWireAccounts, where: string, suite: string): AuthenticatedCredential import {credential_of_verify_envelope} from '@fuzdev/fuz_app/testing/cross_backend/credential_wire.js';

The credential an account_verify envelope names, by the account it answers as.

envelope

type unknown

accounts

where

type string

suite

the calling suite, named in the throw

type string

returns

AuthenticatedCredential

throws

  • Error - when the backend has no `account_verify` there — a missing requirement, not a row's failure

credential_of_verify_response
#

testing/cross_backend/credential_wire.ts view source

(response: RawHttpResponse, accounts: CredentialWireAccounts, rpc_path: string, suite: string): AuthenticatedCredential | null import {credential_of_verify_response} from '@fuzdev/fuz_app/testing/cross_backend/credential_wire.js';

The credential an RPC account_verify response names; null for a 401.

response

accounts

rpc_path

type string

suite

the calling suite, named in a throw

type string

returns

AuthenticatedCredential | null

CREDENTIAL_SESSION_ACCOUNT_PASSWORD
#

CREDENTIAL_SESSION_ACCOUNT_USERNAME
#

CREDENTIAL_WIRE_VERIFY_BODY
#

CREDENTIAL_WIRE_VERIFY_ID
#

CredentialWireAccounts
#

testing/cross_backend/credential_wire.ts view source

CredentialWireAccounts import type {CredentialWireAccounts} from '@fuzdev/fuz_app/testing/cross_backend/credential_wire.js';

The accounts behind the three credentials of one fixture.

session

type TestAccount

readonly

bearer

type TestAccount

readonly

keeper_id

The keeper's account id — who the daemon token authenticates as.

type string

readonly

CredentialWireRequest
#

testing/cross_backend/credential_wire.ts view source

CredentialWireRequest import type {CredentialWireRequest} from '@fuzdev/fuz_app/testing/cross_backend/credential_wire.js';

One raw request a suite sends.

base_url

Base URL the backend is reachable at; only its host and port are used.

type string

readonly

host

The Host to write, or null when header_lines carry the request's Host lines.

type string | null

readonly

header_lines

The header lines, written in order and as given.

type readonly string[]

readonly

format_authenticated_credential
#

read_credential_wire_accounts
#

testing/cross_backend/credential_wire.ts view source

(fixture: TestFixture): CredentialWireAccounts import {read_credential_wire_accounts} from '@fuzdev/fuz_app/testing/cross_backend/credential_wire.js';

The fixture's three credential accounts.

fixture

returns

CredentialWireAccounts

throws

  • AssertionError - when the fixture lacks the seeded accounts, or two credentials share one

send_raw_upgrade
#

testing/cross_backend/credential_wire.ts view source

(request: CredentialWireRequest & { readonly ws_path: string; }): Promise<{ received: string; response: RawHttpResponse | null; }> import {send_raw_upgrade} from '@fuzdev/fuz_app/testing/cross_backend/credential_wire.js';

Send a WebSocket upgrade to ws_path carrying header_lines after the upgrade's own lines, and read the first response — for an upgrade the caller expects refused.

request

type CredentialWireRequest & { readonly ws_path: string; }

returns

Promise<{ received: string; response: RawHttpResponse | null; }>

send_raw_verify
#

testing/cross_backend/credential_wire.ts view source

(request: CredentialWireRequest & { readonly rpc_path: string; }): Promise<{ received: string; response: RawHttpResponse | null; }> import {send_raw_verify} from '@fuzdev/fuz_app/testing/cross_backend/credential_wire.js';

POST account_verify to rpc_path carrying header_lines (and Connection: close), read until the server closes.

request

type CredentialWireRequest & { readonly rpc_path: string; }

returns

Promise<{ received: string; response: RawHttpResponse | null; }>

verify_socket_credential
#

testing/cross_backend/credential_wire.ts view source

(client: RawWsClient, accounts: CredentialWireAccounts, ws_path: string, suite: string): Promise<{ credential: AuthenticatedCredential; } | { ...; }> import {verify_socket_credential} from '@fuzdev/fuz_app/testing/cross_backend/credential_wire.js';

Ask an accepted socket who it is: send account_verify and read the credential its answer names.

client

accounts

ws_path

type string

suite

the calling suite, named in a throw

type string

returns

Promise<{ credential: AuthenticatedCredential; } | { failure: string; }>

the credential, or why none could be read

WS_UPGRADE_HEADER_LINES
#

Depends on
#

Imported by
#