-
-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When respond with proxy requestMessage.Url is used, not AbsoluteUrl #459
Comments
I would expect that using this code: var server = WireMockServer.Start(_settings);
server
.Given(Request.Create().WithPath("/*"))
.AtPriority(100)
.RespondWith(Response.Create()
.WithProxy(new ProxyAndRecordSettings
{
Url = "https://wwwdev.company.com",
AllowAutoRedirect = true,
WebProxySettings = new WebProxySettings
{
Address = "http://127.0.0.1:8888",
UserName = "",
Password = ""
}
})); Any any request, like Would call the proxy as: |
Thank you for the quick response!
I believe it's because my WireMock service is hosted under '/account/api' and that part is omitted later from the Url. |
Just an analyze how the code currently works. The setup is like: server
.Given(Request.Create()
.UsingPost()
)
.RespondWith(Response.Create()
.WithProxy(new ProxyAndRecordSettings { Url = "http://postman-echo.com" })
); The current logic from WireMock is that only the baseUrl from the ProxyUrl is used, so specifying "http://postman-echo.com/post" or in your case "https://wwwdev.company.com/account/api" does not work. However I think you are right, and that there is actually wrong logic in WireMock. What do you think? |
Yep, this should solve my issue. |
Yes it should be backwards compatible. Proposal:
Correct? |
I agree. |
Can you try MyGet version : WireMock.Net.1.2.6-ci-13251.nupkg |
It works as agreed. |
I'll make a new official release tomorrow. |
Hello,
I have the following working local setup in IIS:
website - wwwdev.company.com
web application - wwwdev.company.com/account
API - wwwdev.company.com/account/api
The web application calls the API with relative URL "/api/...".
I want to add tests for the web app which should call a mocked API and return the responses I want. All unmatched requests should be proxied to the 'real' API.
So, I create a new website, web app and API in IIS:
website - wwwmock.company.com
web application - wwwmock.company.com/account
API - wwwmock.company.com/account/api
For the mocked API I host a WireMock service on .NET Core 2.1, similar to the example 'WireMock.Net.WebApplication.NETCore2'.
This is the part where I setup the server:
So, I want when I call GET https://wwwmock.company.com/account/api/ping to get the response from the mock API. This works.
I also want when I call GET https://wwwmock.company.com/account/api/v2/environments/current this to be redirected to https://wwwdev.company.com/account/api/v2/environments/current, but it gets redirected to https://wwwdev.company.com/v2/environments/current - without the '/account/api' part.
This is logged for the request:
"Url": "https://wwwmock.company.com/v2/environments/current",
"AbsoluteUrl": "https://wwwmock.company.com/account/api/v2/environments/current",
I think this is because of this part of the code in Response.cs
So the code gets the PathAndQuery from Url, which is "/v2/environments/current" and the baseUrl from ProxyUrl which is "https://wwwdev.company.com".
My question is can I do something, so without changing the IIS setup I get the desired result - https://wwwmock.company.com/account/api/v2/environments/current to be redirected to https://wwwdev.company.com/account/api/v2/environments/current?
Let me know if I can provide more info.
The text was updated successfully, but these errors were encountered: