Wiremock not matching regex

浪子不回头ぞ 提交于 2019-12-24 17:53:07

问题


I'm using wiremock to mock certain requests and their respective response, but I'm trying to add a regex. Unfortunately, this just throws an exception stating that the request was not matched.

{
  "request" : {
     "method": "GET",
     "urlPattern": "/my/service/url?^.*(specificParam.*(M[0-9]{9})).*$"
   },
 "response": {
   ...
   }
}

I also tried it with

"urlPattern": "/my/service/url\\?^.*(specificParam.*(M[0-9]{9})).*$"

The request I'm sending is /my/service/url?saml2=disabled&filter=specificParam%20eq%20%27M012345678%27

Does anyone have an idea why the request is not being matched to the mapping? Thanks in advance.


回答1:


Did you try this :

{
  "request" : {
     "method": "GET",
     "urlPattern": "^\/my\/service\/url\\?.*(specificParam.*(M[0-9]{9})).*$"
   },
   "response": {
   ...
   }
}

See this regex here : https://regex101.com/r/B3XACf/1



来源:https://stackoverflow.com/questions/51085155/wiremock-not-matching-regex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!