1

I run Wiremock as a standalone image, one of several started by docker-compose. It works fine in most cases but in one case the matching is not working how I had hoped. I define my routes in a routes.json file. This is the relevant snippet:

...
    {
      "request": {
        "method": "POST",
        "url": "/middleware-nz-sandbox/v2.0/domestic-payment-consents",
        "headers": {
            "x-fapi-interaction-id": {
                "equalTo": "okay"
            }
        }
      },
      "response": {
        "status": 201,
        "bodyFileName": "payment-consents.json"
      }
    },
    {
      "request": {
        "method": "POST",
        "url": "/middleware-nz-sandbox/v2.0/domestic-payment-consents",
        "headers": {
            "x-fapi-interaction-id": {
                "equalTo": "error"
            }
        }
      },
      "response": {
        "status": 500,
        "bodyFileName": "payment-consents-error.json"
      }
    },
...

So I want the requests that match the URL and which have a header of 'okay' to match the first, and if they match the same url but have a header of 'error' I want to match the second. However they always match the first route. I ran it with --verbose turned on and this is what I see:

2022-11-24 01:58:10.931 Request received:
192.168.192.4 - POST /middleware-nz-sandbox/v2.0/domestic-payment-consents

client-type: [async httpclient]
Content-Type: [application/json]
x-idempotency-key: [KNIFETHR.DF658F3.184A75B4C76.08000]
x-fapi-interaction-id: [error]
x-fapi-auth-date: [Thu, 24 Nov 2022 01:58:10 UTC]
Accept: [application/json]
Authorization: [Bearer XYZ]
Content-Length: [742]
Host: [wiremock:7070]
User-Agent: [Dispatch/1.1.3]
{"Risk":{"PaymentContextCode":"BillPayment","MerchantCustomerIdentification":"c76b1402-d5d2-41fe-8376-c761a7505e0b","DeliveryAddress":{"AddressLine":["100 West Street","Knifethrower City"],"AddressType":"DeliveryTo","Country":"NZ"}},"Data":{"Consent":{"EndToEndIdentification":"KNIFETHR.DF658F3.184A75B4C76.08000","InstructedAmount":{"Amount":"100.00","Currency":"NZD"},"CreditorAccount":{"SchemeName":"BECSElectronicCredit","Identification":"12-1234-1234567-12","SecondaryIdentification":"0002","Name":"Knifethrower Enterprises Ltd"},"RemittanceInformation":{"Reference":{"CreditorName":"Knifethrower Enterpr","CreditorReference":{"Particulars":"CreditorPart","Code":"CreditorCode","Reference":"1"}}},"InstructionIdentification":"ACME412"}}}


Matched response definition:
{
  "status" : 201,
  "bodyFileName" : "status.json"
}

You can see by the status that it is returning 201 from the first route rather than 500 from the second. Can anyone tell me where I went wrong here? Thanks

(version of Wiremock: 2.32.0)

RogerParkinson
  • 499
  • 6
  • 18

0 Answers0