-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
WithProxy(...) does not save the mappings to file #549
Comments
Hello @martinkra, now I see that you are defining proxy settings in two places. Try like this example: https://github.com/WireMock-Net/WireMock.Net/blob/master/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Program.cs |
Your hint 'defining proxy settings in two places' helped, example too, thank you. I figured that the problem was with defining proxy settings for a specific request. Recording settings seem to work only when configured during server start and should not be touched later. The code that works: var server = WireMock.Server.WireMockServer.Start(new WireMockServerSettings
{
Port = 1234,
StartAdminInterface = true,
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
Url = "http://postman-echo.com/post",
SaveMapping = true,
SaveMappingToFile = true
}
});
Console.WriteLine("Press any key to stop the server");
Console.ReadLine();
server.Stop(); API makes appear that it is possible to configure recording for a specific request but that does not work: // does not work, should work or not be possible to configure
server
.Given(Request.Create().UsingGet())
.RespondWith(Response.Create()
.WithProxy(new ProxyAndRecordSettings
{
Url = "https://github.com/",
SaveMapping = true,
SaveMappingToFile = true
})); |
@martinkra I see you point. I'll check if I can change the code to save the mapping in all scenarios. |
I couldn't find 1.3.8-ci-14324 on MyGet/stefh...
[cid:9ce639bc-24ce-4f15-8bd7-00b973d03bc4]
…________________________________
From: Stef Heyenrath <notifications@github.com>
Sent: Sunday, December 6, 2020 12:13 PM
To: WireMock-Net/WireMock.Net <WireMock.Net@noreply.github.com>
Cc: martinkra <martinkra@gmail.com>; Mention <mention@noreply.github.com>
Subject: Re: [WireMock-Net/WireMock.Net] How to setup proxy and recording properly (#549)
Can you try NuGet version 1.3.8-ci-14324 from MyGet?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#549 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABKCZXC42A6CHL67JXUECYDSTNYNRANCNFSM4UORQK5A>.
|
@martinkra |
No such version on nuget.org, MyGet feed https://www.myget.org/F/stefh does no longer work for me. |
I've found the feed and the version. In build 1.3.8-ci-14327 recording settings on request level do not break the recording: var server = WireMock.Server.WireMockServer.Start(new WireMockServerSettings
{
Port = 1234,
StartAdminInterface = true,
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
Url = "http://postman-echo.com/post",
SaveMapping = true,
SaveMappingToFile = true
}
});
server
.Given(Request.Create().UsingGet())
.RespondWith(Response.Create()
.WithProxy(new ProxyAndRecordSettings
{
Url = "http://postman-echo.com/post",
SaveMapping = true,
SaveMappingToFile = true
}));
Console.WriteLine("Press any key to stop the server");
Console.ReadLine();
server.Stop(); However, it is still a bit confusing that one could configure request level recording whithout setting up global recording, it would not work in that scenario. var server = WireMock.Server.WireMockServer.Start(new WireMockServerSettings
{
Port = 1234,
StartAdminInterface = true //,
//ProxyAndRecordSettings = new ProxyAndRecordSettings
//{
// Url = "http://postman-echo.com/post",
// SaveMapping = true,
// SaveMappingToFile = true
//}
});
server
.Given(Request.Create().UsingGet())
.RespondWith(Response.Create()
.WithProxy(new ProxyAndRecordSettings
{
Url = "http://postman-echo.com/post",
SaveMapping = true,
SaveMappingToFile = true
})); |
My intention was to fix the code so that your last code example would work fine. If this code example does not work correctly, I need to check the code again. |
Code where recording is set twice works in 1.3.8-ci-14327, that did not work before so the original issue is fixed. Code where recording is not set during server start and is set on request level (second snippet in my previous comment) does not work. I can manage without that feature but thought it is worth noting that it appears as an inconsistency or a bug. |
New (
I think this is the full solution. |
I agree that the proposed is the full solution. However, 1.3.8-ci-14337 does not work as described. The following code does not record mappings: var server = WireMock.Server.WireMockServer.Start(new WireMockServerSettings
{
Port = 1234,
StartAdminInterface = true
});
server
.Given(Request.Create().UsingGet())
.RespondWith(Response.Create()
.WithProxy(new ProxyAndRecordSettings
{
Url = "http://postman-echo.com/post",
SaveMapping = true,
SaveMappingToFile = true
})); |
@martinkra Thank you for your testing. I hope this version |
@StefH Thank you for your help and fixes. Version 1.3.8-ci-14339 works as defined. |
New official version will be released today. |
I've created a console app that runs the server trying to record/capture mappings:
The server works fine, e.g. when accessing localhost:1234/test1 I get the data from https://github.com/test1. The problem is that I am unable to find the way to get the recorded mapping... No files are created. What am I missing?
The text was updated successfully, but these errors were encountered: