mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
What's the intended behavior when combining recording proxy with watched mapping folder? #118
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 @DavidKorn on GitHub (Jul 4, 2018).
If I set up a proxy and also the ReadStaticFiles and WatchStaticFiles, and I make the same call twice, should I expect to hit the proxied endpoint the first time, record the mapping, and then use the mapping the second time? I was playing around with this a bit, and it seemed like sometimes this is what would happen, and other times it would continue to hit the real endpoint. I am probably doing something to on my side to exacerbate the issue, but I wanted to understand what I should be expecting.
@StefH commented on GitHub (Jul 4, 2018):
Did you follow this link? https://github.com/WireMock-Net/WireMock.Net/wiki/Proxying
Your issue is probably related that the proxy en the real mapping get the same priority. That would explain your behaviour.
However, if you apply the correct priority, it should work as intended.
@DavidKorn commented on GitHub (Jul 5, 2018):
Ah makes sense. I'm just using the ProxyAndRecordSettings of the FluentMockServerSettings to establish a proxy URL when I start the server. I'm not seeing how to establish a priority for the proxy use that way.
Maybe both the proxy and the generated mappings are getting defaulted to zero and thus contending?
My assumption was that the proxy would be used as a fallback behavior for when I don't have a mapping, but that any mapping would take precedence over that fallback.
@StefH commented on GitHub (Jul 5, 2018):
Priority is defaulted to 0 indeed. You can manually change this in the mapping file.
If you want a sort of fall back scenario, see the bottom example on that wiki link I copied in my previous comment.
@DavidKorn commented on GitHub (Jul 10, 2018):
Thanks, I'll play around some more as time allows. I think what I wanted is for the ProxyAndRecordSettings to allow me to set a lower priority when I establish the proxy there. But maybe I can do it with a fallback mapping like your example, as long as it still triggers the mapping recording.
@StefH commented on GitHub (Jul 10, 2018):
I just realised that I need to explain more on proxying functionality. Because there are 2 ways to proxy.
Full proxy mode : Wiremock will only record requests and responses. This is useful if you want to record all traffic from a web app to a backend. See this code example https://github.com/WireMock-Net/WireMock.Net/blob/master/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Program.cs
Proxy per defined mapping. This is described in the wiki. In this case you need to use priority to make a difference. I will think if defining an extra setting will automatically lower the prio from a proxied mapping.
Next week I will update the wiki with some details to make it more clear.
@DavidKorn commented on GitHub (Jul 10, 2018):
Thanks @StefH . The use case I was trying to support is this: Our QA thinks we have all the needed mappings in place to mock a 3rd party API so we can do reliable tests of our code without actually hitting the 3rd party API. But if our client code generates a request not covered by the existing mappings, we'd like to fallback to the proxy record behavior and pass through to the real 3rd party API so we can easily capture that request in a new mapping file. We'll then have to clean it up as usual and fix the response, but this seemed like a convenient workflow.
@StefH commented on GitHub (Apr 5, 2019):
Can I close this question?
@awcoats commented on GitHub (Mar 11, 2020):
I am having the same problem. I am able to 'record' without a problem. My problem is 'playing' back to the results.
For my example, I'm using http://example.mocklab.io/recordables/123
How do I configure to try and match with a recorded file and return that?
@StefH commented on GitHub (Mar 11, 2020):
When 'playing' back, you just need to start WireMock in a different way, like:
Also see this example project : https://github.com/richie676/wiremock
@awcoats commented on GitHub (Mar 11, 2020):
That example worked for me. Thank you for quick response.
@StefH commented on GitHub (Mar 11, 2020):
Closing...