https://linen.dev logo
#general
Title
# general
r

Roger Parkinson

02/27/2023, 4:20 AM
Hi Guys. I'm trying to get standalone wiremock to match a different route depending on a header in the request and it isn't working. Here is my routes.json (relevant snippet)
Copy code
{
      "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'm running this. I run Wiremock as a standalone image, one of several started by docker-compose. It works fine in most cases but in this one case the matching is not working how I had hoped. (version of Wiremock: 2.32.0) Have I got a mistake in the routes file or does this just not work? Thanks
t

Tom

02/27/2023, 10:21 AM
Hi @Roger Parkinson this looks to me like it should work exactly as you require. Is there any chance you’ve created another stub that matches that doesn’t have the header matcher? If you hit
/__admin/mappings
on the server you can see all the stubs you have loaded.
r

Roger Parkinson

02/27/2023, 8:01 PM
Thanks. I will try the admin mappings trick.
6 Views