1

I am using wiremock to mock my requests. However, I am not able to mock the URLs for which query values have equality sign. For ex: /my/relative/path?param1=updated>-10d AND projectId=10001

As you can see the param1 value i.e updated>-10d AND projectId=10001 contains = sign within the value. And I have to mock the responses based on the projectId. So if I do something like this:

MockServer
.Given('/my/relative/path')
.WithParam("param1", new RegexMatcher("*10001*"))
.RespondWith(Response
    .Create()
    .WithStatusCode(200)
    .WithHeader("content-type", "application/json;charset=UTF-8")
    .WithBody("some body value"));

it doesn't work in this case. I have tried multiple combinations and I have observed that if the query value doesn't have = sign, then it works perfectly. But, how do I match it with my constraints i.e with the query value having = sign? Am I missing something really basic here? Any help would be highly appreciated.

2
  • Is the actual URL something more like /my/relative/path?param1=123&param2=321? Commented Sep 22, 2021 at 14:42
  • No. The actual url accepts a query param which has a SQL like syntax (not exactly but yeah something of that sort) /my/relative/path?sql=condition1 AND condition 2 OR condition3. Here any of the condition could be of the form of something like id >= 2 or id = 2 etc.. Commented Sep 22, 2021 at 16:00

1 Answer 1

1

It seems the Wiremock version which I am using (1.0.17) has a bug which doesn't work correctly when the query has = sign as per this reported bug: https://github.com/WireMock-Net/WireMock.Net/issues/283

It got fixed in the version 1.0.19. So, I will switch to that version.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.