mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
ExactMatcher doesn't respect special characters #206
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @PkAIR on GitHub (Aug 27, 2019).
For a pattern with regex special character (e.g. brackets) ExactMather works unexpectedly.
I'm having this simple mapping:
And with simple post request http://localhost:9999/Transactions(123)/ChangePortfolio having 'No matching mapping found' message.
When I try to escape '(' symbol using \ preceding symbol I receive this mapping:
Same for
and http://localhost:9999/Transactions
123/ChangePortfolioHow should I escape symbols like brackets, !, ~ etc?
@StefH commented on GitHub (Aug 27, 2019):
No need to escape these characters.
I see you are using Path and Url matchers, it's best to just use one. And make sure the http://localhost:9999 is the location where WireMock.Net is running.
If you want more details, you can call
http://{{wm_hostname}}/__admin/requeststo see all requests + the RequestMatchResult which shows you which items do match. Maybe in your case the body is not matched correctly?@PkAIR commented on GitHub (Aug 27, 2019):
Well, I got it that I don't need to escape character.
Not sure what the issue using both of them. I know that it's sort of overkill but nevertheless. And yeah, http://localhost:9999 is the hostname for my wiremock.
I'll check but in my case body matcher is a wildcaard one with * as value. Additionally when I use url without brackets smth like http://localhost:9999/Transactions123/ChangePortfolio it works.
@StefH commented on GitHub (Aug 27, 2019):
And which application do you use to post the request ? (I did test using Postman)
And the match result is like:
It seems that only the PathMatcher is used, this could be business logic from WireMock...
@PkAIR commented on GitHub (Aug 27, 2019):
Well,
Firstly I tried /__admin/requests for url without brackets (and yes, I've use Postman also for tests):
After that tried with brackets and result of /__admin/requests is:
@StefH commented on GitHub (Aug 28, 2019):
Which .NET version do you use? Because on .NET Core 2.x, I see another detail in the request:
"Url": "http://localhost:9091/Transactions(123)/ChangePortfolio", (no
%28and%29)?What you also can do is allow-partial mapping, then the best match will be returned, so when looking at the requests you can maybe see more why a mapping doe snot match 100%
@PkAIR commented on GitHub (Aug 28, 2019):
Ah, my bad. I was using 4.5.2.
Sounds fair for partial mapping to be used. Will try.
Thank you @StefH for your input btw.
@StefH commented on GitHub (Aug 28, 2019):
I need to debug some more, but if .net 4.5.2 and .net core behave different on the
Urlproperty, I have to fix this.@StefH commented on GitHub (Dec 7, 2019):
@PkAIR
Maybe fixed, can you please test version
WireMock.Net.1.0.38-ci-12272.nupkgfrom MyGet?