如何在Wiremock映射文件中添加URL匹配的正则表达式模式

时间:2019-07-03 10:02:08

标签: regex url wiremock

我需要为access_token和clientId添加正则表达式,如下面的请求所示,这是Wiremock生成的映射文件。当我尝试此映射文件时,它将其视为字符串而不是与输入请求匹配的正则表达式。

{
  "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 个答案:

答案 0 :(得分:0)

似乎您需要使用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" }