Skip to main content

Module sandbox

Module sandbox 

Source
Expand description

The plugin sandbox: run plugins against a synthetic Context.

Two modes, both producing the same Trace shape a live request produces — so the UI viewer, the diff, and the redaction tests are written once and serve both:

  • ad-hoc nodes — a list of plugin nodes run in order, for testing one plugin (or a handful) in isolation;
  • named policy — a configured policy replayed against a synthetic request, for testing a whole pipeline.

Ad-hoc mode does not get its own executor. It synthesises a PolicyConfig — prepending a listener and appending a client, which validate_policy requires — and reuses compile_policy. One executor means a sandbox run can never diverge from what the gateway really does.

Structs§

ResponseInput
Optional seed for Context.response, so response-phase plugins (response-rewrite, the loggers) have something to act on.
SandboxContextInput
A synthetic context. Every field is optional: posting {} yields a valid GET / run.
SandboxRequest
A sandbox request: exactly one of nodes or policy.

Enums§

OnError
What to do when an ad-hoc node fails.
StringOrList
A header/query value given as either a bare string or a list.

Functions§

body_text 🔒
Extracts replayable body text: a plain string, or a snapshot body object’s text field. None for a binary or uncaptured body.
materialize_context
Turns a sandbox context value — flat or the nested trace-snapshot shape — into a Context.
normalize_context 🔒
Flattens the nested trace-snapshot shape into the flat input shape. A value that is already flat passes through essentially unchanged.
synthesize_policy
Synthesises a runnable policy from an ad-hoc node list.