mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
[Question] What is the correct configuration for wiremock running in proxy mode #331
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 @genesispvtltd on GitHub (Feb 5, 2021).
Hi I am new to wiremock but I need to know the answers to the following questions. I have a automation test suite running against an api. Sometimes this api is not available then I need automation test to be run against wiremock server and this should happen automatically I mean wiremock should be intelligent enough to understand the live url is down and it will call the stubs allready created. I tried wiremock standalone version and this is not happening. I started the wiremock on proxy mode and the live url is up and running I sent a request and it does hit live url, and then next I block the live url using the windows host file. I restareted wiremock and I again sent the request to wiremock server running in proxy mode but it fails and send me "No connection could be made because the target machine actively refused it." please help me to understand why I am facing this issue.Basically when the live url is down then i need 12345 to be return. Also the live url endpoint is nothing but it will create a new random number and will return that number. Below is my code also please understand I am using csharp code to write my stubs and i want them to be added as static mappings as well so I am doing it in the code like below
@genesispvtltd commented on GitHub (Feb 6, 2021):
Basically i need to know the setting for .net can you please tell me the correct setting for the below in .net version. This serves my purpose because when the live url is down wiremock knows to call its mappings and return them. Plus when live url is up it will call the live url automatically
@StefH commented on GitHub (Feb 6, 2021):
What you mean is that you actually want a "smart" proxy mode:
Scenario 1
In case the real endpoint is up (we need to determine the criteria for up), proxy the request + response to the real endpoint.
Scenario 2
In case the real endpoint is down, try to find a configured mapping:
If the mapping is found, return that mapping.
If the mapping is not found, just return default 404 'mapping not found'.
About the Record-Mode for proxy : I'm not sure yet if this fits in this solution....
@genesispvtltd commented on GitHub (Feb 6, 2021):
@StefH
Reason I am asking that most of the developers want their automation test suite to always hit the live url , but when the live url is down it is ok to return the wiremock stubs already created maching the request. But we don't need the automation test always running and returning the stubs which we have created in wiremock when the live url is up. So I am simply asking do you have a solution which serve my purpose in wiremock.net Thanks. Appreciate for your time on this matter.
@StefH commented on GitHub (Feb 6, 2021):
Hello @genesispvtltd,
Short answer: WireMock.Net does not yet support a "Smart Proxy" functionality as you describe.
Long answer: This can probably be implemented as defined here:
Scenario 1
In case the real endpoint is up (we need to determine the criteria for up, like != 200 OK), proxy the request + response to the real endpoint.
Scenario 2
In case the real endpoint is down, try to find a configured mapping:
If the mapping is found, return that mapping.
If the mapping is not found, just return default 404 'mapping not found'.
@genesispvtltd commented on GitHub (Feb 6, 2021):
@StefH thanks for the response I am good.cool
@StefH commented on GitHub (Feb 6, 2021):
Can this question be closed for now?
@genesispvtltd commented on GitHub (Feb 6, 2021):
yeah sure