How to add url matching regex pattern in Wiremock mapping files

Viewed 1042

I need to add regex for access_token and clientId as shown in below request which is a mapping file generated by Wiremock. When I try this mapping file it considers it as a string and not regex to match with the input request.

{
  "id" : "fa7b4992-3527-3a3e-ae01-6f06bae3d35d",
  "request" : {
    "url" : "mock/ws/check?access_token=(a-z)*",
    "method" : "POST",
    "bodyPatterns" : [ {
      "equalToJson" : "{\"priority\":\"HIGH\",\"clientId\":\"(a-z)*\"}",
      "ignoreArrayOrder" : true,
      "ignoreExtraElements" : true
    } ]
  },
  "response" : {

  },
  "uuid" : "fa7b4992-3527-3a3e-ae01-6f06bae3d35d"
}
1 Answers

It seems that you need to use urlPathPattern

{   "id" : "fa7b4992-3527-3a3e-ae01-6f06bae3d35d",   "request" : {
    "url" : "mock/ws/check?access_token=(a-z)*",
    "method" : "POST",
    "bodyPatterns" : [ {
      "equalToJson" : "{\"priority\":\"HIGH\",\"clientId\":\"(a-z)*\"}",
      "ignoreArrayOrder" : true,
      "ignoreExtraElements" : true
    } ]   },   "response" : {

  },   "uuid" : "fa7b4992-3527-3a3e-ae01-6f06bae3d35d" }
Related