testing/cross_backend/request_header_conformance_wire.ts

The request header conformance table over raw sockets: each wire row's header lines sent to the live backend as they are written, and the real outcome asserted — which gate refused the request, with which code, or which credential authenticated it.

Where the unit legs read the lines with each spine's readers, this sends them: the runtime's HTTP parser, its view of repeated and empty lines (on @hono/node-server a WebSocket upgrade's Headers are rebuilt from Node's deduplicated view), and the whole middleware chain sit between the bytes and the answer. It is what proves the gates read the lines the client sent on every runtime and on every path, the upgrade included. It needs no backdoor.

Every wire row is sent:

  • as an RPC POST of account_verify — post: the refusal's status and code, or the credential the answering account names (null for a 401);
  • when the row carries a Content-Type line, also as a POST to the login route with a wrong password — the second site that checks a JSON body's content type: the same refusal, or the route's own 401;
  • as a WebSocket upgrade (capabilities.ws) — upgrade: the refusal's status (and its code where the runtime sends a refusal's body, capabilities.ws_refusal_body), a 401 for no credential, or a 101 whose socket answers account_verify as the credential named (capabilities.ws_account_actions; without it the 101 alone). A row naming an upgrade_runtime_refusal the backend declares (capabilities.ws_upgrade_runtime_refusals) instead expects that runtime's answer: a 400 before the app runs, never a 101.

The leg adds a Host naming the server to a row with no Host line, and Content-Type: application/json to the POSTs of a row with no Content-Type line. The accounts are credential_wire.ts's.

What it needs of a backend: what credential_conformance_wire.ts needs — account_verify on rpc_path and on the socket, the login route, the seeded accounts, no extra_actors — and an allowlist admitting origin (default the origin of base_url) and refusing REQUEST_HEADER_WIRE_FOREIGN_ORIGIN. The rows the table expects the host gate to refuse run where capabilities.host_gate says the gate is on, and the gate must refuse REQUEST_HEADER_WIRE_FOREIGN_HOST; a backend with the gate off declares false, and those rows show as skipped tests.

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

view source

Declarations
#

4 declarations

describe_request_header_conformance_wire_cross_tests
#

REQUEST_HEADER_WIRE_FOREIGN_HOST
#

REQUEST_HEADER_WIRE_FOREIGN_ORIGIN
#

RequestHeaderConformanceWireCrossTestOptions
#

testing/cross_backend/request_header_conformance_wire.ts view source

RequestHeaderConformanceWireCrossTestOptions import type {RequestHeaderConformanceWireCrossTestOptions} from '@fuzdev/fuz_app/testing/cross_backend/request_header_conformance_wire.js';

setup_test

Per-test fixture producer (cross-process), seeding the accounts of create_credential_wire_seed and no extra_actors.

type (): Promise<TestFixture>

readonly
returns Promise<TestFixture>

capabilities

ws gates the upgrade leg, ws_account_actions its account_verify frame on each accepted socket, ws_refusal_body whether a refused upgrade's code is read, ws_upgrade_runtime_refusals the rows that expect the runtime's own refusal, and host_gate the rows the host gate refuses.

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

daemon_token

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

type string

readonly

origin?

An origin the backend's allowlist admits. Default the origin of base_url.

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

Depends on
#

Imported by
#