Wiremock: Question : is it possible to do bodyPatterns matching on just a regex ?

Created on 17 Jan 2017  路  2Comments  路  Source: tomakehurst/wiremock

I want to match a POST request with application/x-www-form-urlencoded data like:

grant_type=password&username=test&password=pwd

I tried:

"response": {
    "status": 200,
    "bodyPatterns": [ {
            "matches": ".username=(test)&."
        }
],
. . .

But I get a 500 error?

Is it possible to just match on plain text ? (So no JSON and no XML) matching?

See also this http://stackoverflow.com/questions/41279540/request-body-matching-in-wiremock-not-json-xml

Most helpful comment

Sorry my bad, I need to put the bodyPatterns in the request:

{
  "request": {
  "method": "POST",
    "url": "/authorize/oauth2/token",
    "bodyPatterns": [ {
          "matches": ".username=(test)&."
      }
    ]
  },
  "response": {
    "status": 200,
    . . .

All 2 comments

Sorry my bad, I need to put the bodyPatterns in the request:

{
  "request": {
  "method": "POST",
    "url": "/authorize/oauth2/token",
    "bodyPatterns": [ {
          "matches": ".username=(test)&."
      }
    ]
  },
  "response": {
    "status": 200,
    . . .

Closing

Was this page helpful?
0 / 5 - 0 ratings