Skip to main content

Request Variations

Production traffic is mostly good requests, so a recording rarely tests how your service refuses a bad one. proxymock variations writes bad-input copies of your recorded requests. Each changes one thing your service must refuse, and the rest of the request stays as real as the recording.

Write variations​

proxymock variations --in proxymock/recorded

The variations land in proxymock/variations as a recording. One recorded request per endpoint is the base. Each kind of variation is written where it applies:

KindWhat it changesNeeds
no-authRemoves the request's credential: Authorization, Cookie and API key headersA request that carries one
other-userSends the request with another recorded user's credential, on a resource named by an id in the pathRequests from two users, told apart by their credentials
typeSends a body field with the wrong JSON typeA JSON body
missing-fieldLeaves out a field the spec requiresAn OpenAPI spec
boundarySends a value just outside the spec's length or rangeAn OpenAPI spec
enumSends a value the spec's enum does not allowAn OpenAPI spec

An other-user variation tests object-level authorization: whether your service checks that the resource belongs to the caller, not only that the caller is signed in.

FlagUse it to
--inName the recordings to make the variations from
--outName the directory to write them to. The default is proxymock/variations
--specName the OpenAPI spec. The default is the workload's spec in proxymock/applications/ when there is one
--kindsWrite only some kinds, such as --kinds no-auth,other-user
--jsonWrite the result as JSON

Each variation records the status the spec documents for the refusal, or the usual one: 401 for no-auth, 403 for other-user, and 400 for bad input. A variation counts toward a test plan case with that status.

Replay variations​

Run the app against proxymock mock and replay the variations as their own run:

proxymock replay --in proxymock/variations --test-against localhost:8080 \
--fail-if 'requests.response-match-pct < 100'

A variation is judged on being refused, not on matching its recorded status, because services answer the same mistake with 400, 401, 403, 404 or 422:

OutcomeMeaningPasses
RefusedThe service answered with a 4xxYes
AcceptedThe service answered with a 2xx or 3xxNo
FailedThe service answered with a 5xx, so the bad input reached code that did not expect itNo
Refused after writingThe service answered with a 4xx, but called a dependency with POST, PUT, PATCH or DELETE while handling the requestNo
No responseNothing came backNo

The write check reads the calls the mock server recorded while the request was in flight. Without proxymock mock running, a variation is judged on its status alone. Name the mock server's output with --mocks-out when it is outside the workspace.

The replay summary counts the variations by outcome, and each failed one gets a failure bundle with the likely cause and a next step, such as checking that the resource belongs to the caller.

Do not pass --test-config when you replay variations. A test config's status assertions compare with the recorded status exactly, so a service that answers 422 where the variation recorded 400 would fail them.

Loading search...