Skip to content

labs/validate

Step Summary
labs/validate/api_errors Judge the error answers of a test's API calls together.
labs/validate/api_response Check an answer against what its operation documents in the API file.

labs/validate/api_errors

Judge the error answers of a test's API calls together.

Three checks over every answer with status 400 or more — those the test's labs/http/api_request, labs/connector/dataplane/api_request and labs/http/api_sweep steps received, or the responses given: * format — every error body has the one error format: schema, RFC 9457 problem details (format: problem+json), or the schema its operation documents for its status (the default); * leaks — no body gives away a stack trace, an exception class, SQL, a file path, a private address or an internal host name; * client_errors — no request the test sent wrong on purpose (expect 4xx, 4XX or error) was answered with a 5xx. The step fails when a check does, and keeps every problem as its output.

Inputs

Parameter Type Required Default Also accepts Description
responses list of object no None — Answers to judge, each as an API call step returns it (status_code, response_body, response_headers, operation) plus an optional 'expect'; omitted, every answer the test's labs API call steps received so far.
steps list of string no None — Only the answers of these steps (their ids) of the test; omitted, every labs API call step's. Ignored when 'responses' is given.
format declared | problem+json no 'declared' — 'declared': each error body matches the schema its operation documents for its status; 'problem+json': each is RFC 9457 problem details. Ignored when 'schema' is given.
schema object no None — One JSON Schema every error body must match, e.g. '${{ env.schemas.error }}'.
leaks boolean no True — Look for stack traces, exception names, SQL, file paths and internal addresses in error bodies.

Output — the value assertions and returns: read

Output contract of labs/validate/api_errors.

Field Type Description
passed boolean Whether every check held for every error answer.
checked integer Answers looked at.
errors integer Of those, error answers (status 400 and up).
problems list of object Each problem: check, operation, status, message.

labs/validate/api_response

Check an answer against what its operation documents in the API file.

In order: the status is documented (exactly, as 4XX or as default); it is the expect-ed one, if given; the Content-Type is a documented media type for it; the body validates against that schema (OpenAPI 3.0 schemas read with their 3.0 meaning — nullable, boolean exclusiveMinimum); every required response header is there. Every problem is reported with where it is in the body, the schema keyword and where that keyword is in the document. The step fails when any check does, and keeps the verdict as its output.

Inputs

Parameter Type Required Default Also accepts Description
input object no None — The answer to check, as an API call step returns it; omitted, the one the last API call step published.
api any no None — API file, '${{ env.apis. }}'; omitted, the answer's own.
operation string no None — Operation; omitted, the answer's own.
expect integer | string no None — Expected status, class ('4XX'), 'success' or 'error'.
data_plane boolean no False — The answer came through a data plane: a 401/403 (EDR refused) or 502/504 (API unreachable) is reported as the data plane's, not checked against the document.

Output — the value assertions and returns: read

Output contract of labs/validate/api_response.

Field Type Description
passed boolean Whether every check held.
status_code integer Status of the answer checked.
operation string The operation it was checked against.
problems list of object Each problem: check, message, and for a body the pointer, keyword, schema_location, received.