picadoh / mockserver-client-net Goto Github PK
View Code? Open in Web Editor NEW.NET Core / C# Fluent API for interacting with Mock-Server
License: MIT License
.NET Core / C# Fluent API for interacting with Mock-Server
License: MIT License
Support using templates when forwarding
https://www.mock-server.com/mock_server/creating_expectations.html#forward_action
Is there a way to specify that a particular header key/value pair is required?
This library cannot setup/verify xPath expressions.
I extended the code to handle this. See attachment. Feel free to use it.
mockserver-client-net.zip
I need to be able to support dynamically generating the response based on certain properties of the request and other environment properties.
This is possible with the use of the HttpResponseTemplate - https://www.mock-server.com/mock_server/creating_expectations.html#button_javascript_templated_response
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.
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.
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:
Should you find the idea useful, I am willing to make the code changes.
Regards
Michal Cernik
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.