Coder Social home page Coder Social logo

picadoh / mockserver-client-net Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 14.0 118 KB

.NET Core / C# Fluent API for interacting with Mock-Server

License: MIT License

C# 100.00%
csharp dotnet dotnetcore lib mock mock-server mocking mockserverclient mockserverclientnet testing

mockserver-client-net's People

Contributors

brunosantosfarfetch avatar picadoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mockserver-client-net's Issues

Target Machine actively refuses connection

So I was pretty excited to find a MockServer port for .NET that was in .NET standard. This should be a great tool for .NET Core Integrative and Compliance testing. But when I run this on my local machine I am getting

Message: System.AggregateException : One or more errors occurred. (No connection could be made because the target machine actively refused it)
---- System.Net.Http.HttpRequestException : No connection could be made because the target machine actively refused it
-------- System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it

My code is pretty straight forward. I don't think I"ve gone off the reservation here at all.

  public class JwtTokenServerHelper
    {
        public static MockServerClient CreateMockJwtTokenServer(string rsaPublicKey)
        {
            JObject jsonPublicTokenKey = new JObject();
            jsonPublicTokenKey.Add("alg", "sha256WithRSA");
            jsonPublicTokenKey.Add("value", rsaPublicKey);

            MockServerClient msc = new MockServerClient("127.0.0.1", 1080);
            msc
                .When(
                Request()
                .WithMethod("GET")
                .WithPath("/oauth/token_key"),
                Times.Exactly(1))
                .Respond(
                Response()
                .WithStatusCode(200)
                .WithHeaders(
                    new Header("Content-Type", "application/json; charset=utf-8"))
                    .WithBody(jsonPublicTokenKey.ToString())
                    .WithDelay(TimeSpan.FromMilliseconds(20))
                    );

            return msc;
        }
    }

It instantiaties the MockServerClient but when it goes to use the object, it fails with that error. Any thoughts on why I might be getting this? I've tried multiple machines. Same problem.

RetrieveRecordedRequests failed to deserialize HttpRequest array

I get the following error when trying to get recorded requests from the mock server using docker container latest version (5.11.2)

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: {. Path '[0].body.json', line 7, position 14

My assumption is a problem with the HttpRequest object "body" JsonProperty definition.

Support for mockserver.tlsMutualAuthenticationRequired=true

Hi,
to: [email protected].
I would like to use this package for scenarios when MockServer requires mutual certificate authentication. According to the code, it neither supports using the MockServer API over https, nor can it use a client certificate for authentication.
Changes required:

  • extend AbstractClient and MockServerClient with few properties (bool useTls, X509Certificate2 clientCertificate - or friendly name, store name and location), also their constructors with arguments
  • extend WithPath extension method to enable https protocol when required
  • extend AbstractClient.SendRequestAsync so that httpClient uses the certificate when required

Should you find the idea useful, I am willing to make the code changes.

Regards

Michal Cernik

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.