WireMock.Net: FormEncoded Request fails (404 Not Found) if key value pairs order in mapping is different from request body order
Describe the bug
When trying to use the ExactMatcher or RegexMatcher to match a form encoded request, it fails (404 Not Found) if they order of the form encoded request is different from that in the json mapping file.
Expected behavior:
Ordering of FormEncoded Body requests should not affect matching as it might not always be convenient to control the ordering.
If it is going to be a breaking change to fix this, a flag like IgnoreFormEncodedBodyOrder can be provided to override the default.
Test to reproduce
- 1 Clone Repo, and build.
- 2 Run the built demo. (Incase you get an error the first time you run the Demo, close it and run again.).
Other related info
Docker is needed to run the Demo as it uses WireMock.NET Test Container.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19
sure, on it.
@Xor-el Currently the
latestis always used. Would it be needed to add an option to manually specify the version when using the containerbuilder? Or is this not needed?@StefH my bad actually. I forgot to clear my Stale Docker Image Cache so my test container was using the old cached 1.5.60 instead of the latest 1.5.62 image.
Thanks for your time.
I’ve just updated the code so that wildcards are supported. See the FormUrlEncodedMatcherTest for details.
This does already work like it is because Or is used.
By default the
MatchOperatoris set to Or. So when the matcher is like:And the body only contains
grant_type=client_credentials, this matcher will match.A
FormUrlEncodedPartialMatchercould be used like this (I think)…I’ll check if I can change the implementation from the FormUrlEncodedMatcher to use internally the WildcardMatcher for string compare…
Hello @StefH thanks for your quick feedback. I agree with your suggestion that adding a new matcher would be overall a better approach to address this. Thanks for looking into this.