Introduce a flag to strictly enforce the http method #302

Open
opened 2025-12-29 15:20:14 +01:00 by adam · 8 comments
Owner

Originally created by @StefH on GitHub (Oct 12, 2020).

https://github.com/WireMock-Net/WireMock.Net/issues/504

I did notice something else about partial match scores that seemed off. (probably requires a little redesign). For our team to continue using wiremock.net we need to trust that the Http VERB is ALWAYS respected. I've been noticing that, even when a post call is fired, Get matches are being favored (given higher scores) over POST calls (in this case because of the bug mentioned above, the POST call has a lower score because it is failing to match on the body matcher). This seems off. It should match on the highest score, for only a single verb type. I can't imagine a scenario where someone is okay with a get request/response being returned for a post call in an integration test??? That would be a broken integration test to me. Can we introduce a flag to strictly enforce just the verb?

Originally created by @StefH on GitHub (Oct 12, 2020). https://github.com/WireMock-Net/WireMock.Net/issues/504 > I did notice something else about partial match scores that seemed off. (probably requires a little redesign). For our team to continue using wiremock.net we need to trust that the Http VERB is ALWAYS respected. I've been noticing that, even when a post call is fired, Get matches are being favored (given higher scores) over POST calls (in this case because of the bug mentioned above, the POST call has a lower score because it is failing to match on the body matcher). This seems off. It should match on the highest score, for only a single verb type. I can't imagine a scenario where someone is okay with a get request/response being returned for a post call in an integration test??? That would be a broken integration test to me. Can we introduce a flag to strictly enforce just the verb?
adam added the feature label 2025-12-29 15:20:14 +01:00
Author
Owner

@StefH commented on GitHub (Oct 12, 2020):

@RiccoFerraro in this scenario ; do you use "AllowPartialMapping"?
https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#allowpartialmapping

@StefH commented on GitHub (Oct 12, 2020): @RiccoFerraro in this scenario ; do you use "AllowPartialMapping"? https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#allowpartialmapping
Author
Owner

@RiccoFerraro commented on GitHub (Oct 12, 2020):

Hi @StefH. Yes that is the case.

@RiccoFerraro commented on GitHub (Oct 12, 2020): Hi @StefH. Yes that is the case.
Author
Owner

@RiccoFerraro commented on GitHub (Oct 12, 2020):

Partial mapping is very useful, but I need to have partial mapping, only for the correct verb type

@RiccoFerraro commented on GitHub (Oct 12, 2020): Partial mapping is very useful, but I need to have partial mapping, only for the correct verb type
Author
Owner

@RiccoFerraro commented on GitHub (Oct 12, 2020):

Also @StefH would AllowPartialMapping = false ever work for a POST request with a json body given https://github.com/WireMock-Net/WireMock.Net/issues/504? It seems to return a 0 or the body matcher and reject all strict mapping when I try that

@RiccoFerraro commented on GitHub (Oct 12, 2020): Also @StefH would `AllowPartialMapping = false` ever work for a POST request with a json body given https://github.com/WireMock-Net/WireMock.Net/issues/504? It seems to return a `0` or the body matcher and reject all strict mapping when I try that
Author
Owner

@StefH commented on GitHub (Oct 12, 2020):

Normally you would not use AllowPartialMapping (set it to false), only use AllowPartialMapping in special cases/scenarios.

If you have troubles matching a POST request with a JSON body --> please provide a full example project, so that I can investigate it because it should work as designed.

@StefH commented on GitHub (Oct 12, 2020): Normally you would not use AllowPartialMapping (set it to false), only use AllowPartialMapping in special cases/scenarios. If you have troubles matching a POST request with a JSON body --> please provide a full example project, so that I can investigate it because it should work as designed.
Author
Owner

@StefH commented on GitHub (Oct 26, 2020):

Hello @RiccoFerraro ,

Maybe as a work-around, you can define the Priority?
See https://github.com/WireMock-Net/WireMock.Net/wiki/Stubbing#stub-priority

And https://app.swaggerhub.com/apis/StefHeyenrath/WireMock/1.0.13.0#/MappingModel

@StefH commented on GitHub (Oct 26, 2020): Hello @RiccoFerraro , Maybe as a work-around, you can define the Priority? See https://github.com/WireMock-Net/WireMock.Net/wiki/Stubbing#stub-priority And https://app.swaggerhub.com/apis/StefHeyenrath/WireMock/1.0.13.0#/MappingModel
Author
Owner

@RiccoFerraro commented on GitHub (Oct 27, 2020):

Hi @StefH , thanks for the response and for the idea. That is really cool. However, I'm not sure it works with my use case. I'm really trying to use record playback functionality as much as possible. In our case, Record/Playback is preferable because it allows us to mitigate unstable dependencies (api's). Stubbing out the endpoints becomes a maintenance nightmare with api's that change frequently. Is priority something that could be set for record playback as a flag somehow? I think the (probably) better solution that you already alluded to is going to be to refactor our integration tests which use wiremock's partial mapping to instead use strict mapping. That is dependent on post body request properties being correctly matched though. Is the fix for that published to nuget.org yet?

@RiccoFerraro commented on GitHub (Oct 27, 2020): Hi @StefH , thanks for the response and for the idea. That is really cool. However, I'm not sure it works with my use case. I'm really trying to use record playback functionality as much as possible. In our case, Record/Playback is preferable because it allows us to mitigate unstable dependencies (api's). Stubbing out the endpoints becomes a maintenance nightmare with api's that change frequently. Is priority something that could be set for record playback as a flag somehow? I think the (probably) better solution that you already alluded to is going to be to refactor our integration tests which use wiremock's partial mapping to instead use strict mapping. That is dependent on post body request properties being correctly matched though. Is the fix for that published to nuget.org yet?
Author
Owner

@StefH commented on GitHub (Oct 27, 2020):

About your last question : check the https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md for that.

@StefH commented on GitHub (Oct 27, 2020): About your last question : check the https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md for that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#302