Skip to main content

Module cases

Module cases 

Source
Expand description

Case — the input fixture every rule consumes.

A case is a snapshot of one customer-visible API failure: the request bytes (method, URL, headers, body), an optional response (status, headers, body), an optional sibling server.log, an optional sibling secret.txt for HMAC checks, and a free-form Context block carrying anything the rules need that isn’t part of the wire protocol (auth-required flag, expected base URL, webhook envelope shape, idempotency hash, client deadline, pinned now_unix).

Cases are laid out on disk one-directory-per-case under fixtures/cases/<name>/. Each directory is self-contained: case.json is the structured data, server.log is the bundled log (text or JSON-lines), secret.txt is the HMAC secret. This shape is deliberate: a real support engineer can drop a customer’s captured artefacts into a directory of the same shape and run the diagnostic against it via Case::load or api-debug-lab corpus.

§Schema

Every case.json is validated against fixtures/cases.schema.json (JSON Schema Draft 2020-12) by tests/schema.rs. The schema is the wire-level contract; this module is the deserialised mirror of it.

Structs§

Case
One bundled (or user-supplied) failure case.
Context
Free-form context the rules consume in addition to the wire request/response.
IdempotencyCtx
Idempotency context for a case where an Idempotency-Key is in play.
Request
HTTP request as captured by the customer or the proxy.
Response
HTTP response as observed by the customer.
WebhookCtx
Webhook context for a case that involves HMAC signing.

Enums§

CaseLoadError
Errors returned by Case::load.
EnvelopeFormat
Selector for how a webhook signature header should be parsed, and the resulting HMAC signing-input shape.
Severity
Customer-visible severity tag for a case.

Functions§

header
Case-insensitive header lookup.
list_cases
Enumerate the bundled positive fixtures.