testing/cross_backend/origin_conformance.ts

The origin allowlist conformance table, and the cross-backend suite that runs it against each backend over the wire.

origin_conformance.json (beside this module) is the one statement of the allowlist grammar and matcher both spines implement. It holds two tables:

  • parse rows — {raw, ok: true} or {raw, errors: [{index?, kind}]}: an allowlist value (as FUZ_ALLOWED_ORIGINS would carry it) and whether it parses, or every refusal with its 1-based entry position (absent for a list-level refusal) and its AllowedOriginsErrorKind.
  • match rows — {patterns, origin, allowed}: a valid allowlist, one Origin value (null for none), and the request-level answer.

A row may carry a note for the reader. The TS unit test reads the table directly; describe_origin_conformance_cross_tests sends every row to a backend's _testing_origin_check action and compares the answer, so the Rust spine is held to the same rows without reading this file.

view source

Declarations
#

11 declarations

assert_origin_conformance
#

testing/cross_backend/origin_conformance.ts view source

(checks: readonly OriginConformanceCheck[], answer: readonly unknown[], backend: string): void import {assert_origin_conformance} from '@fuzdev/fuz_app/testing/cross_backend/origin_conformance.js';

Compare each check's answer with its expectation and fail once, listing every row that disagrees.

checks

the table's checks

type readonly OriginConformanceCheck[]

answer

the answer each check got, in order

type readonly unknown[]

backend

the name the failure message gives the answerer

type string

returns

void

describe_origin_conformance_cross_tests
#

testing/cross_backend/origin_conformance.ts view source

(options: RpcPathCrossSuiteOptions): void import {describe_origin_conformance_cross_tests} from '@fuzdev/fuz_app/testing/cross_backend/origin_conformance.js';

Register the origin conformance suite: every row of the committed table, sent to the backend's _testing_origin_check action over the keeper's daemon-token channel, must get the answer the table names. The action is on every spine test binary, so the suite is ungated.

options

returns

void

load_origin_conformance
#

testing/cross_backend/origin_conformance.ts view source

(): { parse: ({ raw: string; ok: true; note?: string | undefined; } | { raw: string; errors: { kind: "empty_entry" | "not_printable_ascii" | "missing_scheme" | "unsupported_scheme" | "has_path" | ... 11 more ... | "no_origins"; index?: number | undefined; }[]; note?: string | undefined; })[]; match: { ...; }[]; } import {load_origin_conformance} from '@fuzdev/fuz_app/testing/cross_backend/origin_conformance.js';

Read and validate the committed conformance table.

returns

OriginConformance

the parsed table

throws

  • Error - when the file doesn't match `OriginConformance`

ORIGIN_CONFORMANCE_URL
#

OriginConformance
#

testing/cross_backend/origin_conformance.ts view source

value + type

{ parse: ({ raw: string; ok: true; note?: string | undefined; } | { raw: string; errors: { kind: "empty_entry" | "not_printable_ascii" | "missing_scheme" | "unsupported_scheme" | "has_path" | ... 11 more ... | "no_origins"; index?: number | undefined; }[]; note?: string | undefined; })[]; match: { ...; }[]; } import {OriginConformance} from '@fuzdev/fuz_app/testing/cross_backend/origin_conformance.js';

The conformance table.

parse

type OriginConformanceParseRow[]

match

type OriginConformanceMatchRow[]

OriginConformanceCheck
#

OriginConformanceCrossTestOptions
#

OriginConformanceError
#

testing/cross_backend/origin_conformance.ts view source

value + type

{ kind: "empty_entry" | "not_printable_ascii" | "missing_scheme" | "unsupported_scheme" | "has_path" | "has_userinfo" | "missing_host" | "invalid_host_char" | "unbracketed_ipv6" | ... 7 more ... | "no_origins"; index?: number | undefined; } import {OriginConformanceError} from '@fuzdev/fuz_app/testing/cross_backend/origin_conformance.js';

One expected refusal of a parse row.

kind

type "empty_entry" | "not_printable_ascii" | "missing_scheme" | "unsupported_scheme" | "has_path" | "has_userinfo" | "missing_host" | "invalid_host_char" | "unbracketed_ipv6" | "partial_wildcard" | "non_canonical_ipv4" | "unclosed_ipv6" | "invalid_ipv6" | "invalid_after_ipv6" | "invalid_port" | "default_port" | "no_origins"

index?

type number

OriginConformanceMatchRow
#

testing/cross_backend/origin_conformance.ts view source

value + type

{ patterns: string; origin: string | null; allowed: boolean; note?: string | undefined; } import {OriginConformanceMatchRow} from '@fuzdev/fuz_app/testing/cross_backend/origin_conformance.js';

A match row: a valid allowlist, one Origin value or null, and the answer.

patterns

type string

origin

type string | null

allowed

type boolean

note?

type string

OriginConformanceParseRow
#

testing/cross_backend/origin_conformance.ts view source

value + type

{ raw: string; ok: true; note?: string | undefined; } | { raw: string; errors: { kind: "empty_entry" | "not_printable_ascii" | "missing_scheme" | "unsupported_scheme" | "has_path" | "has_userinfo" | ... 10 more ... | "no_origins"; index?: number | undefined; }[]; note?: string | undefined; }

type { raw: string; ok: true; note?: string | undefined; } | { raw: string; errors: { kind: "empty_entry" | "not_printable_ascii" | "missing_scheme" | "unsupported_scheme" | "has_path" | "has_userinfo" | "missing_host" | "invalid_host_char" | "unbracketed_ipv6" | "partial_wildcard" | "non_canonical_ipv4" | "unclosed_ipv6" | "invalid_ipv6" | "invalid_after_ipv6" | "invalid_port" | "default_port" | "no_origins"; index?: number | undefined; }[]; note?: string | undefined; }

import {OriginConformanceParseRow} from '@fuzdev/fuz_app/testing/cross_backend/origin_conformance.js';

A parse row: the value parses (ok: true), or is refused with errors.

to_origin_conformance_checks
#

testing/cross_backend/origin_conformance.ts view source

(table: { parse: ({ raw: string; ok: true; note?: string | undefined; } | { raw: string; errors: { kind: "empty_entry" | "not_printable_ascii" | "missing_scheme" | "unsupported_scheme" | "has_path" | ... 11 more ... | "no_origins"; index?: number | undefined; }[]; note?: string | undefined; })[]; match: { ...; }[]; }): OriginConformanceCheck[] import {to_origin_conformance_checks} from '@fuzdev/fuz_app/testing/cross_backend/origin_conformance.js';

Flatten the table into action inputs and the answers they must get. A parse row sends a null origin, so a value that parses answers {ok: true, allowed: true}.

table

the conformance table

returns

OriginConformanceCheck[]

one check per row, parse rows first

Depends on
#