1

I'm using java -jar wiremock-jre8-standalone-2.32.0.jar --verbose Here is my mapping

{
   "priority":1,
   "request":{
      "method":"GET",
      "urlPath":"/api/arsys/v1/entry/CHG:Infrastructure%20Change",
      "queryParameters" : {
        "q": {
            "matches": "^.*?(?:\b|_)Infrastructure Change ID(?:\b|_).*?(?:\b|_)CRQ000000030315(?:\b|_).*?$"
        }
      }
   },
   "response":{
      "status":200,
      "headers":{
         "Content-Type":"application/json"
      },
      "bodyFileName": "/api/arsys/v1/entry/chginfrastructurechange/CRQ000000030315.json"
    }
}

I'm trying to match a GET with params ('Infrastructure Change ID' IN ("CRQ000000030315", "CRQ000000030316"))

The regex matches example here: https://regex101.com/r/oswkUE/1

The verbose out is:

[0:0:0:0:0:0:0:1] - GET /api/arsys/v1/entry/CHG:Infrastructure%20Change?q=(%27Infrastructure%20Change%20ID%27%20IN%20(%22CRQ000000030315%22,%20%22CRQ000000030316%22))

Authorization: [AR-JWT]
Accept: [*/*]
User-Agent: [PostmanRuntime/7.29.0]
Connection: [keep-alive]
Postman-Token: [50954490-5a26-4be0-a526-c61a6e409399]
Host: [localhost:8080]
Accept-Encoding: [gzip, deflate, br]
Content-Type: [application/json]

  
Matched response definition:
(no response definition configured)

Response:
HTTP/1.1 404
(no headers)

I know the issue is the regex matches because if I change it to .*CRQ000000030315.* it returns the response, confirming everything else is good. However, I need to match on Infrastructure Change ID and then CRQ000000030315 anywhere in the param.

Cheers for your time.

DannyK
  • 267
  • 2
  • 12
  • Does your regex work if you replace all instances of a space (` `) with the encoded version (`%20`)? As well as the single quotes (`'` -> `%27`)? – agoff Mar 16 '22 at 13:37
  • Cheers @agoff I tried that and no. I also tried removing any space and just have one word in the first match. `"^.*?(?:\b|_)Infrastructure(?:\b|_).*?(?:\b|_)CRQ000000030315(?:\b|_).*?$"` – DannyK Mar 16 '22 at 13:40
  • I think it's some issue with whatever code within wiremock parsing the regex because even if I just have this, it still fails `^.*?(?:\b|_)Change(?:\b|_).*?(?:\b|_)CRQ000000030315(?:\b|_).*?$` – DannyK Mar 16 '22 at 13:43
  • It must be something to do with the wiremock parser because even a simpler, more expensive regex works outside wiremock `"\bInfrastructure\b.*\bCRQ000000030315\b"` – DannyK Mar 16 '22 at 13:55

0 Answers0