I have a simple POST request sending params using application/x-www-form-urlencoded encoding.  
Looking in the wiremock docs I can't find a way to match the request by the params values, something like the querystring match I mean.
Furthermore it seems also impossible to contains for the body, nor to match the entire body in clear (just as base64).  
Is there a way to match this kind of requests?
Another option that I found was to use contains for Stubbing Content-Type: application/x-www-form-urlencoded
{
  "request": {
    "method": "POST",
    "url": "/oauth/token",
    "basicAuthCredentials": {
      ...
    },
    "bodyPatterns": [
      {
        "contains": "username=someuser"
      }
    ]
  },
  "response": {
    ....
  }
}
With classic wiremock you can use bodyPatterns' matchers and regular expressions:
for example:
...
"request": {
   "method": "POST",
   "url": "/api/v1/auth/login",
   "bodyPatterns": [
     {
       "matches": "(.*&|^)username=test($|&.*)"
     },
     {
       "matches": "(.*&|^)password=123($|&.*)"
     }
   ]
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With