Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
SunmasterFourteen
@SunmasterFourteen
I'm following this https://github.com/WireMock-Net/WireMock.Net/wiki/Using-HTTPS-%28SSL%29 to add cert but still get an error. Unfortunately I have to use https.
image.png
image.png
Stef Heyenrath
@StefH
@SunmasterFourteen can you please create an issue on the GitHub project?
narendrachava
@narendrachava
Hi,
I'm trying to use WireMock.Net for the first time. I'm using StandAlone app (as a Console application in .NET core) and I'm able to successfully record the mappings and replay them on my local machine (windows) during test execution.
But when I try to execute the tests in CI/CD pipeline, I get a connection refused error, although wiremock server is up and running (from the log).
Any idea what is going on here ?
8/20/2020 1:37:54 AM [Info] : WireMock.Net server listening at http://localhost:8700
 $ echo "$(curl -H 'Accept:*/*' http://localhost:8700)"
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to localhost port 8700: Connection refused
Stef Heyenrath
@StefH
@narendrachava This is difficult to see what's the cause.
Is the standalone still running when you execute the CURL command?
And maybe it's better not to use a fixed port, but a dynamic one. Unless you are certain the port is free is can be used by WireMock.Net
narendrachava
@narendrachava
@StefH Thanks for the response, Yeah, you're right, turns out that the server isn't running when CURL command is executed. I had a "Console.Read" statement at the end, to keep the server running. But, looks like in Linux , that statement doesn't keep the process alive.
Now I'm running the server as a background service wrapping the implementation as"IHostedService". But now the problem is, CI/CD runner is stuck after the CURL command is executed.. doesn't exit successfully.. trying to figure that out..
Cezary Piątek
@cezarypiatekGC
Hi, I would like to use WireMock.Net in my project but I need to handle the following scenario. When we run tests locally (in VisualStudio) then we want to run WireMock in memory using WireMockServer.Start. When we run tests in CI then we want to use docker container with WireMock and connect to it from the test code and from the tested application. Besides that difference, we would like to have a consistent API to define mocking rules. However, it doesn't seem to be possible right now because WireMock client uses different models to define mappings (MappingModel) and the MappingConverter which could convert IMapping to MappingModel has internal modifier. Is it possible to expose the method which could perform that conversion? Or am I doing something wrong and there's an option to define Mappings once and use it with WireMockServer and with standalone (docker) app?
Cezary Piątek
@cezarypiatekGC
Ofc, WireMockServer has WithMapping method which accepts MappingModel but creating MappingModel manually seems to be a very tedious task. I Would prefer to use that fluent interface with Request.Create() and Response.Create()
genesispvtltd
@genesispvtltd
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 Below is my code also please understand I am ussing 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............................................................................................................................................... class Program
{
static void Main(string[] args)
{
var hostFile = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
IConfiguration appSettings = new ConfigurationBuilder()
.AddJsonFile(Path.Combine(hostFile, "appsettings.json"), true, true)
.Build();
// Proxying,Play, Record
appSettings["mode"] = "Proxying";
appSettings["url"] = "http://localhost:7777";
appSettings["proxyUrl"] = "https://mySecurityApi.com";
        WireMockServerSettings settings = null;

                 settings = new WireMockServerSettings
                {
                    Urls = new[] { appSettings["url"] },
                    StartAdminInterface = true,

                    AllowPartialMapping =true,
                    Logger = new WireMockConsoleLogger(),
                     ProxyAndRecordSettings = new ProxyAndRecordSettings
                     {
                         Url = appSettings["proxyUrl"],                          
                     }
                 };



        var wiremockServer = StandAloneApp.Start(settings);

        wiremockServer            
          .Given(              
          Request.Create().WithPath("/Accounts/api/securityhelper/getauthtoken")
          .UsingGet()                          
          .WithCookie("paycorAuth", new RegexMatcher(".*"))

          )
          //.AtPriority(100)
          .RespondWith(
            Response.Create()
             .WithProxy(appSettings["proxyUrl"])
             .WithBody("12345")
          );

        wiremockServer.SaveStaticMappings();


        Console.WriteLine("Press any key to stop the server");
        Console.ReadKey();

    }
}
msutar021
@msutar021
I am new to wiremock.net. I need to create stub for https soap service. Can someone please share a sample or let me know if we can achieve this using wiremock.net
Stef Heyenrath
@StefH
@msutar021 If you have some example requests and responses, just create mappings for these, just like other mocks. Else you could use the proxy and record fnctionality to get example requests/responses.

@genesispvtltd I did already comment on your issue (WireMock-Net/WireMock.Net#580) and I'll copy-paste the info also here as a reference:

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
@genesispvtltd

@StefH need some information regarding NTLM authentication some of our endpoints are using NTLM authentication so i need to use proxying there so the code looks like below Cookie AuthCookie = null;
try
{

            var authRequest = WebRequest.Create("https://localhost:7777/Accounts/Auth") as HttpWebRequest;
            authRequest.CookieContainer = new CookieContainer();
            authRequest.AllowAutoRedirect = false;
            authRequest.ContentType = "application/x-www-form-urlencoded";
            authRequest.KeepAlive = true;
            CredentialCache userCredentials = new CredentialCache();
            userCredentials.Add(
                new Uri("https://live.com/"),
                "NTLM",
                new NetworkCredential("username", "Password", ""));
            authRequest.Credentials = userCredentials;


            using (var authResponse = authRequest.GetResponse() as HttpWebResponse)
            {
                AuthCookie = authResponse.Cookies["payment"];


            }
        }
        catch (Exception ex)
        {


        }

And I have created a stub as well wireMockServer
.Given(
Request.Create().WithPath("/Accounts/Auth")
.UsingGet()

    )
    .RespondWith(
      Response.Create()
       .WithProxy(proxyUrl)
    );

But when I proxy I am getting the underlying connection is closed message any example how I can use NTLM authentication I would appreciate thanks

sumit1112
@sumit1112
Hi,
I am trying to use wire-mock docker with static mapping files. How can I do that? Is including mapping files is possible at run time? If not can you please provide me a docker file which I can use to use static files/folders to be included while running.
Stef Heyenrath
@StefH
hvariant
@hvariant
Hi there, I'm wondering if it's possible to use states without scenario? or somehow make a default scenario?
we have a lot of stubs and I need to use state but don't want to change every single one just to make this one thing work
hvariant
@hvariant
actually, will scenarios from different instances of WireMockServer interfere with each other?
hvariant
@hvariant
can you mix stubs with scenario and stubs without scenario?
I think I'm misunderstanding how it works
hvariant
@hvariant
I think I found a bug but I don't have time to create an example at the moment
Stef Heyenrath
@StefH
@hvariant : you can define "normal mappings" besides "special mappings" which needs a scenario. This should just work fine.
Or do you mean something else?
lukasT1010
@lukasT1010

Hello!
I try to install the WireMock.Net NuGet package (https://www.nuget.org/packages/WireMock.Net/) with the command line: "Install-Package WireMock.Net"

After a while, the command line tells me: "Install-Package: Unable to find dependent package(s) (Handlebars.Net)"? Handlebars.Net is a dependency of WireMock, however, I thought, NuGet resolves the dependencies automatically.

Stef Heyenrath
@StefH
@lukasT1010 - Handlebars.Net is referenced via Handlebars.Net.Helpers, this is used by WireMock.Net
David Kennedy Souza Araújo
@DavidUser
Hello! I am having a problem using the Logger configuration
I need to just log to console when a test with the mock request fails
Commonly I use or forward the ITestOutputHelper to the application
That way I know what is happening on failure otherwise the console keep clean.
The problem is that using the FluentMockServer I had no option
            _serviceMock = FluentMockServer.Start(new FluentMockServerSettings {
                    Logger = new WireMockConsoleLogger()
                });
I get console log to everything or nothing
The Logger is a IWireMockLogger instead a ILogger
David Kennedy Souza Araújo
@DavidUser
Does someone know how to turn around?
Stef Heyenrath
@StefH