Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 18 19:30
    StefH closed #601
  • Apr 18 19:30
    StefH closed #604
  • Apr 18 19:15
    StefH edited #604
  • Apr 18 19:15
    StefH assigned #604
  • Apr 18 19:15
    StefH opened #604
  • Apr 16 19:42
    StefH assigned #601
  • Apr 15 17:42
    StefH closed #602
  • Apr 15 17:41
    StefH closed #603
  • Apr 15 17:30
    StefH labeled #603
  • Apr 15 17:30
    StefH assigned #603
  • Apr 15 17:30
    StefH opened #603
  • Apr 15 16:50
    StefH assigned #602
  • Apr 15 16:25
    StefH edited #602
  • Apr 15 12:07
    GrantGHub edited #602
  • Apr 15 12:07
    GrantGHub opened #602
  • Apr 15 12:07
    GrantGHub labeled #602
  • Apr 13 14:59
    StefH updated the wiki
  • Apr 13 14:58
    StefH updated the wiki
  • Apr 12 15:36
    Archomeda labeled #601
  • Apr 12 15:36
    Archomeda opened #601
Stef Heyenrath
@StefH
@sonthanh Can you please provide an example what you try to achieve?
Ayush Jain
@ayushjamsaria_twitter
Hi, We have one of the use case for contract testing in which mappings are generated by Spring Cloud Contract based on wiremock.org but there are some difference in the definition of mappings in wiremock.net and wiremock (java). Is there any way we can use those wiremock(java) mappings for wiremock.net?
Stef Heyenrath
@StefH
Hello @ayushjamsaria_twitter : currently it's not possible to use the JAVA mappings for WireMock.Net
The mappings are similar, however they differ. If you need specific help, just provide some mappings as an example.
acanha
@acanha
Hello everyone, is it possible to use the ProxyAndRecord functionality with a custom path for the saved files? For example if i wanted to save the recordings in myFolder/otherFolder instead of __admin/mappings is this possible through some configuration or do i have to implement a custom file handler?
Stef Heyenrath
@StefH

@acanha This is currently only possible using a custom file handler.
See https://github.com/WireMock-Net/WireMock.Net/blob/395be3c5832bae26a187994c7913e6d200677ebd/examples/WireMock.Net.Console.Net452.Classic/CustomFileSystemFileHandler.cs#L7

However, adding this as a config-setting does also make sense. I'll take a look.

Stef Heyenrath
@StefH
@acanha
You don't need to implement your own, just use the LocalFileSystemHandler and provide the foldername.
acanha
@acanha
Hi @StefH, thanks for the suggestion. The LocalFileSysteHandler still has the __admin/mappings path after the custom root path. I implemented a custom file system handler as you first suggested and it's working fine. Thank you.
Paulo Nobre
@pnobre
Hey guys, having a weird issue here, I'm pretty sure this isn't related to wiremock, but hopefully some of you has already bumped into this issue.... I'm playing around with wiremock.net for some integration tests. I can run them locally without any issues. However, they all seem to fail (clients all abort with HTTP 500) when running on CI server (appveyor).
Stef Heyenrath
@StefH

@pnobre I never did use AppVeyor to run unit tests using WireMock.net

Can you maybe provide some more details on the exact exception and create an issue ?

Ben Richards
@The-Running-Dev
Hello, I'm trying to use WireMock for the first time and I must be missing something small. I can't seem to get my tests to work when I use return await response.Content.ReadAsAsync<IssueResponse>()
And this works fine:
var s = await response.Content.ReadAsStringAsync();
var r = s.FromJson<IssueResponse>();
And my error sounds familiar but no idea how to fix it
System.Net.Http.UnsupportedMediaTypeException : No MediaTypeFormatter is available to read an object of type 'IssueResponse' from content with media type 'aplication/json'
Stef Heyenrath
@StefH
@The-Running-Dev Can you please provide the c# code on how you use WireMock? Or the json mapping?
Could it be that the mediatype is not set ?
Ben Richards
@The-Running-Dev
I figured it out. aplication/json is not the same as application/json, stupid "P"
Stef Heyenrath
@StefH
@The-Running-Dev Good catch ! ;-)
Stacku Stack
@stackustack_gitlab
Hey, everyone :) I encountered a problem and thought I'd ask for some help here :) I'm trying to start the server and redirect all traffic from mobile app <=> backend to mobile app <=> wiremock server - but Im wondering if thats possible without changing the code of the app. I know that's possible with changing the codebase, from targeting my BE endpoints to target localhost (for iOS), but I'm wondering if thats doable somehow without changing the targeted endpoint in the codebase (for example with some proxy + wiremock settings). Unfortunately it's not possible to change the codebase, so I need to take it more like a blackbox. Any help? :) (also worth noting I'm running on a iOS simulator)
Stef Heyenrath
@StefH
@stackustack_gitlab If you have control over your (test) environment, you could just update the hostfile so that the mobile app still connects to http://backend.com but backend.com resolves to the WireMock.Net ip-address.
SunmasterFourteen
@SunmasterFourteen
Hey did anyone actually run HTTPS wiremock using net framework 4.6.2?
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