mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Request matching logic is not practical #71
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 @davidshen84 on GitHub (Feb 28, 2018).
I did not read the code. I did some testing, and I think current request matching logic is:
AllowPartialMapping = false, all the properties in the received request must be tested positive by the matching rules, which means unspecified properties will be automatically tested negative. This is rather restrictive and is hard to satisfy.
AllowPartialMapping = true, *at least one of the matching rules must satisfy at least one of the properties in the received request. This is rather lose and useless.
I suggest we change the matching logic to the following:
With the new logic, when partial matching is enabled, the engine will test the properties of requests that matters to the application, and ignore the other ones.
@StefH commented on GitHub (Feb 28, 2018):
AllowPartialMapping = false; your description is correctAllowPartialMapping = true; the best matching request is matched (the request with the highest score)When you do a GET call to
__admin/requestsyou get details about the matching:@davidshen84 commented on GitHub (Feb 28, 2018):
Suppose I have a simple service endpoint that
/getdataGETonlyAppId: app-1234If I create a mock server with the following code:
This configuration all accept any GET request. If the client code missed some HTTP request property, this will still allow the client getting the expected response. This can hide some potential bugs that can only be found at production environment.
@StefH commented on GitHub (Feb 28, 2018):
This could indeed be a problem for production environment, I can add some more details on the WIKI to explain how
AllowPartialMapping = trueworks ?@davidshen84 commented on GitHub (Mar 3, 2018):
By my past experience with other rule matching framework, if the user specified a matching rule, only the matching result of the rule affect the final result. Users normally do not concern about the conditions they did not specify. That's just my opinion.
@alastairtree commented on GitHub (Mar 3, 2018):
In my experience having the mock server be quite forgiving is good as it allows you to have general rules that return a 200 say, and then a particular payload on a certain path. This makes generating the mock fast. However in the assertion parts of my tests I call the admin API to get the request I have made and then assert that my desired behaviours, such as sending headers, have be actioned appropriately.
@alastairtree commented on GitHub (May 17, 2018):
The recent release also includes MatchBehaviour.RejectOnMatch which also make crafting complex matching rules easier to exclude certain requests from matching.
@StefH commented on GitHub (May 19, 2018):
@davidshen84 Do you gave more questions? Else I'll close this issue.