Skip to content

mock/wait

Step Summary
mock/wait/http_request Wait for an inbound HTTP request on a previously-registered mock endpoint.

mock/wait/http_request

Wait for an inbound HTTP request on a previously-registered mock endpoint.

Checkpoint — inbound, via direct: your system calls the Test Suite, which answers. Every use of the step is one; a test switches it off with checkpoint: false.

This is the other half of mock/api: that step hands the system under test a callback URL, and this one blocks until the SUT calls it, then hands the request it made to the assertions. A call the mock turns away — no key, another run's key, the wrong method or path — fails the wait as soon as it arrives, saying which (MockCallRefusedError); only the call the mock answers ends it well. Pausing the run stops the wait where it is: the listener closes, the timeout stops counting (step_suspended says how much is left), and the run goes on hold (player.execution.hold). On resume the listener opens again and the wait carries on for the time it had left, announced by a fresh step_waiting. elapsed_ms counts only the time spent waiting. Raises: RuntimeError: If no CallbackManager is available or the wait times out. MockCallRefusedError: If the call the wait was for was refused.

Inputs

Parameter Type Required Default Also accepts Description
mock MockInstance yes — — The mock to wait on, as returned by the step that registered it.
timeout_s number no 30.0 — Seconds to wait before failing.
action WaitAction no None — The action the system under test has to take while the run waits: 'label', 'description', 'recommendation' (the steps, in order) and 'fields' (labelled values to copy). Shown in place of what a viewer would derive from the listener.

Output — the value assertions and returns: read

The inbound request a mock endpoint received.

Field Type Description
request_method string HTTP method of the inbound request.
request_path string Path the request arrived on.
request_headers object Headers of the inbound request.
request_query_params object Query string parameters of the inbound request.
request_body any Body of the inbound request.
elapsed_ms integer Milliseconds spent waiting before the request arrived.

Nested objects

ActionField

One labelled value the person driving the system under test copies.

Field Type Required Default Also accepts Description
label string yes — — What the value is, e.g. header.receiverBpn.
value string | integer | number | boolean yes — — The value to copy.

MockInstance

A registered mock, as the steps that use it later need to see it.

Field Type Required Default Also accepts Description
endpoint_id string no '' — Identifier the mock was registered under, when it was given one.
path string yes — — Path the mock listens on.
method string yes — — HTTP method the mock answers.
base_mock_url string yes — — Root URL of the testlab mock server.
full_mock_url string yes — — Address the system under test calls — root plus path.

WaitAction

The action the system under test has to take while a step waits — written by the test author on the wait step (with.action) and shown in place of what a viewer would otherwise derive from the listener.

Field Type Required Default Also accepts Description
label string no None — The action's name, e.g. 'Send a certificate push'.
description string no None — What is being asked of the system under test, and why.
recommendation list of string no [] — How to do it: the steps to take, in order. A single string is one step.
fields list of ActionField no [] — Values to copy, shown beside the steps, in order.