mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-20 01:07:41 +01:00
Compare commits
16 Commits
stef-928-T
...
stef-Ignor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dabe3a2a10 | ||
|
|
1f1bc05f00 | ||
|
|
c107e38e3b | ||
|
|
b609191095 | ||
|
|
b1ae9aaf46 | ||
|
|
a77c4fe1ac | ||
|
|
ad3ef83c5e | ||
|
|
35ffbbc7d9 | ||
|
|
c1e71707c5 | ||
|
|
69499afe43 | ||
|
|
aadac78577 | ||
|
|
71393204cc | ||
|
|
e5cc6f570c | ||
|
|
7c3a0c815d | ||
|
|
e61f08fe48 | ||
|
|
11f4c47851 |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,3 +1,16 @@
|
||||
# 1.5.27 (03 June 2023)
|
||||
- [#946](https://github.com/WireMock-Net/WireMock.Net/pull/946) - Add warning logging when sending a request to a Webhook does not return status 200 [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#949](https://github.com/WireMock-Net/WireMock.Net/pull/949) - Add ".NET Framework 4.7" to WireMock.Net.FluentAssertions [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#928](https://github.com/WireMock-Net/WireMock.Net/issues/928) - TypeLoadException when using WithHeader method. [bug]
|
||||
- [#945](https://github.com/WireMock-Net/WireMock.Net/issues/945) - Webhook logging [feature]
|
||||
|
||||
# 1.5.26 (25 May 2023)
|
||||
- [#938](https://github.com/WireMock-Net/WireMock.Net/pull/938) - Add more unitests for CSharpFormatter utils [test] contributed by [StefH](https://github.com/StefH)
|
||||
- [#939](https://github.com/WireMock-Net/WireMock.Net/pull/939) - WireMockMiddleware should use HandleRequestsSynchronously correctly [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#940](https://github.com/WireMock-Net/WireMock.Net/pull/940) - Code generator improvements contributed by [cezarypiatek](https://github.com/cezarypiatek)
|
||||
- [#942](https://github.com/WireMock-Net/WireMock.Net/pull/942) - Add GetParameter method to IRequestMessage [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#941](https://github.com/WireMock-Net/WireMock.Net/issues/941) - RequestMessage.GetParameter method missing from IRequestMessage interface [feature]
|
||||
|
||||
# 1.5.25 (13 May 2023)
|
||||
- [#934](https://github.com/WireMock-Net/WireMock.Net/pull/934) - Code generator improvements [feature] contributed by [cezarypiatek](https://github.com/cezarypiatek)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.5.25</VersionPrefix>
|
||||
<VersionPrefix>1.5.27</VersionPrefix>
|
||||
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
|
||||
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
|
||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
rem https://github.com/StefH/GitHubReleaseNotes
|
||||
|
||||
SET version=1.5.25
|
||||
SET version=1.5.27
|
||||
|
||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate --version %version% --token %GH_TOKEN%
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
# 1.5.25 (13 May 2023)
|
||||
- #934 Code generator improvements [feature]
|
||||
# 1.5.27 (03 June 2023)
|
||||
- #946 Add warning logging when sending a request to a Webhook does not return status 200 [feature]
|
||||
- #949 Add ".NET Framework 4.7" to WireMock.Net.FluentAssertions [feature]
|
||||
- #928 TypeLoadException when using WithHeader method. [bug]
|
||||
- #945 Webhook logging [feature]
|
||||
|
||||
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md
|
||||
@@ -22,7 +22,7 @@ For more info, see also this WIKI page: [What is WireMock.Net](https://github.co
|
||||
| | |
|
||||
| --- | --- |
|
||||
| ***Project*** | |
|
||||
| **Chat** | [](https://gitter.im/wiremock_dotnet/Lobby) |
|
||||
| **Chat** | [](https://slack.wiremock.org/) [](https://gitter.im/wiremock_dotnet/Lobby) |
|
||||
| **Issues** | [](https://github.com/WireMock-Net/WireMock.Net/issues) |
|
||||
| | |
|
||||
| ***Quality*** | |
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace WireMock.Net.ConsoleApplication
|
||||
|
||||
var todos = new Dictionary<int, Todo>();
|
||||
|
||||
var server = WireMockServer.StartWithAdminInterface();
|
||||
var server = WireMockServer.Start();
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
@@ -709,25 +709,6 @@ namespace WireMock.Net.ConsoleApplication
|
||||
.WithWebhookFireAndForget(true)
|
||||
.RespondWith(Response.Create().WithBody("a-response"));
|
||||
|
||||
server
|
||||
.Given(Request.Create().WithPath("/todo/items").UsingGet())
|
||||
.InScenario("To do list")
|
||||
.WillSetStateTo("TodoList State Started")
|
||||
.RespondWith(Response.Create().WithBody("Buy milk"));
|
||||
|
||||
server
|
||||
.Given(Request.Create().WithPath("/todo/items").UsingPost())
|
||||
.InScenario("To do list")
|
||||
.WhenStateIs("TodoList State Started")
|
||||
.WillSetStateTo("Cancel newspaper item added")
|
||||
.RespondWith(Response.Create().WithStatusCode(201));
|
||||
|
||||
server
|
||||
.Given(Request.Create().WithPath("/todo/items").UsingGet())
|
||||
.InScenario("To do list")
|
||||
.WhenStateIs("Cancel newspaper item added")
|
||||
.RespondWith(Response.Create().WithBody("Buy milk;Cancel newspaper subscription"));
|
||||
|
||||
System.Console.WriteLine(JsonConvert.SerializeObject(server.MappingModels, Formatting.Indented));
|
||||
|
||||
System.Console.WriteLine("Press any key to stop the server");
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System.IO;
|
||||
using log4net.Config;
|
||||
using WireMock.FluentAssertions;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Server;
|
||||
|
||||
namespace WireMock.Net.ConsoleApplication;
|
||||
|
||||
@@ -13,25 +9,6 @@ static class Program
|
||||
{
|
||||
XmlConfigurator.Configure(new FileInfo("log4net.config"));
|
||||
|
||||
var server = WireMockServer.Start();
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.WithPath("todos")
|
||||
.UsingGet()
|
||||
)
|
||||
.RespondWith(Response.Create()
|
||||
.WithBody("test")
|
||||
);
|
||||
|
||||
server
|
||||
.Should()
|
||||
.HaveReceivedACall()
|
||||
.AtAbsoluteUrl("some-url").And
|
||||
.WithHeader("header-name", "header-value");
|
||||
|
||||
server.Stop();
|
||||
|
||||
// MainApp.Run();
|
||||
MainApp.Run();
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="HandlebarsDotNet.Helpers.Core" publicKeyToken="00d131fae0c250bc" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.3.16.0" newVersion="2.3.16.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.3.10.0" newVersion="2.3.10.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="XPath2" publicKeyToken="463c6d7fb740c7e5" culture="neutral" />
|
||||
@@ -67,7 +67,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Handlebars.Net.Helpers" publicKeyToken="00d131fae0c250bc" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.3.16.0" newVersion="2.3.16.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.3.10.0" newVersion="2.3.10.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Linq.Dynamic.Core" publicKeyToken="0f07ec44de6ac832" culture="neutral" />
|
||||
@@ -101,10 +101,6 @@
|
||||
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.25.0.0" newVersion="6.25.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NJsonSchema" publicKeyToken="c2f9c3bdfae56102" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-10.7.2.0" newVersion="10.7.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
||||
@@ -46,35 +46,32 @@
|
||||
<Reference Include="Fare, Version=2.2.0.0, Culture=neutral, PublicKeyToken=ea68d375bf33a7c8, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Fare.2.2.1\lib\net35\Fare.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentAssertions, Version=5.10.3.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\FluentAssertions.5.10.3\lib\net47\FluentAssertions.dll</HintPath>
|
||||
<Reference Include="Handlebars, Version=2.1.2.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.2.1.2\lib\net46\Handlebars.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Handlebars, Version=2.1.4.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.2.1.4\lib\net46\Handlebars.dll</HintPath>
|
||||
<Reference Include="Handlebars.Net.Helpers, Version=2.3.12.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.3.12\lib\net46\Handlebars.Net.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Handlebars.Net.Helpers, Version=2.3.16.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.3.16\lib\net46\Handlebars.Net.Helpers.dll</HintPath>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.3.12.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.3.12\lib\net46\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.3.16.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.3.16\lib\net46\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.DynamicLinq, Version=2.3.12.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.DynamicLinq.2.3.12\lib\net46\HandlebarsDotNet.Helpers.DynamicLinq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.DynamicLinq, Version=2.3.16.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.DynamicLinq.2.3.16\lib\net46\HandlebarsDotNet.Helpers.DynamicLinq.dll</HintPath>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.Humanizer, Version=2.3.12.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Humanizer.2.3.12\lib\net46\HandlebarsDotNet.Helpers.Humanizer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.Humanizer, Version=2.3.16.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Humanizer.2.3.16\lib\net46\HandlebarsDotNet.Helpers.Humanizer.dll</HintPath>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.Json, Version=2.3.12.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Json.2.3.12\lib\net46\HandlebarsDotNet.Helpers.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.Json, Version=2.3.16.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Json.2.3.16\lib\net46\HandlebarsDotNet.Helpers.Json.dll</HintPath>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.Random, Version=2.3.12.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Random.2.3.12\lib\net46\HandlebarsDotNet.Helpers.Random.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.Random, Version=2.3.16.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Random.2.3.16\lib\net46\HandlebarsDotNet.Helpers.Random.dll</HintPath>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.Xeger, Version=2.3.12.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Xeger.2.3.12\lib\net46\HandlebarsDotNet.Helpers.Xeger.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.Xeger, Version=2.3.16.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.Xeger.2.3.16\lib\net46\HandlebarsDotNet.Helpers.Xeger.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.XPath, Version=2.3.16.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.XPath.2.3.16\lib\net46\HandlebarsDotNet.Helpers.XPath.dll</HintPath>
|
||||
<Reference Include="HandlebarsDotNet.Helpers.XPath, Version=2.3.12.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Handlebars.Net.Helpers.XPath.2.3.12\lib\net46\HandlebarsDotNet.Helpers.XPath.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Humanizer, Version=2.14.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Humanizer.Core.2.14.1\lib\netstandard2.0\Humanizer.dll</HintPath>
|
||||
@@ -82,9 +79,6 @@
|
||||
<Reference Include="JmesPath.Net, Version=1.0.125.0, Culture=neutral, PublicKeyToken=b29d616b7f4faff0, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\JmesPath.Net.1.0.125\lib\net45\JmesPath.Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="JsonConverter.Abstractions, Version=0.4.0.0, Culture=neutral, PublicKeyToken=7ba85365b500f2e2, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\JsonConverter.Abstractions.0.4.0\lib\net461\JsonConverter.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -259,29 +253,20 @@
|
||||
<Reference Include="Microsoft.Net.Http.Headers, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.OpenApi, Version=1.2.3.0, Culture=neutral, PublicKeyToken=3f5743946376f042, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.OpenApi.1.2.3\lib\net46\Microsoft.OpenApi.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.OpenApi.Readers, Version=1.2.3.0, Culture=neutral, PublicKeyToken=3f5743946376f042, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.OpenApi.Readers.1.2.3\lib\net46\Microsoft.OpenApi.Readers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Namotion.Reflection, Version=2.0.10.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Namotion.Reflection.2.0.10\lib\net45\Namotion.Reflection.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NJsonSchema, Version=10.7.2.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NJsonSchema.10.7.2\lib\net45\NJsonSchema.dll</HintPath>
|
||||
<Reference Include="NJsonSchema, Version=10.6.10.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NJsonSchema.10.6.10\lib\net45\NJsonSchema.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NJsonSchema.Extensions, Version=0.1.0.0, Culture=neutral, PublicKeyToken=e52fadf300daf456, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NJsonSchema.Extensions.0.1.0\lib\net45\NJsonSchema.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NSwag.Core, Version=13.16.1.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NSwag.Core.13.16.1\lib\net45\NSwag.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RamlToOpenApiConverter, Version=0.6.1.0, Culture=neutral, PublicKeyToken=f82a9044f86aaeda, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\RamlToOpenApiConverter.0.6.1\lib\net46\RamlToOpenApiConverter.dll</HintPath>
|
||||
<Reference Include="NSwag.Core, Version=13.15.10.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NSwag.Core.13.15.10\lib\net45\NSwag.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RandomDataGenerator, Version=1.0.16.0, Culture=neutral, PublicKeyToken=ae5c571d29a3b8d9, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\RandomDataGenerator.Net.1.0.17\lib\net45\RandomDataGenerator.dll</HintPath>
|
||||
@@ -289,9 +274,6 @@
|
||||
<Reference Include="Scriban.Signed, Version=2.1.4.0, Culture=neutral, PublicKeyToken=5675fb69b15f2433, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Scriban.Signed.2.1.4\lib\net45\Scriban.Signed.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpYaml, Version=1.6.5.0, Culture=neutral, PublicKeyToken=1ced8108e942bc02, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\SharpYaml.1.6.5\lib\net45\SharpYaml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SimMetrics.Net, Version=1.0.5.0, Culture=neutral, PublicKeyToken=c58dc06d59f3391b, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -320,8 +302,8 @@
|
||||
<Reference Include="System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Linq.Dynamic.Core, Version=1.3.1.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Linq.Dynamic.Core.1.3.1\lib\net46\System.Linq.Dynamic.Core.dll</HintPath>
|
||||
<Reference Include="System.Linq.Dynamic.Core, Version=1.2.23.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Linq.Dynamic.Core.1.2.23\lib\net46\System.Linq.Dynamic.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||
@@ -370,30 +352,12 @@
|
||||
<Reference Include="TinyMapper, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\TinyMapper.3.0.3\lib\net40\TinyMapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WireMock.Net, Version=1.5.24.0, Culture=neutral, PublicKeyToken=c8d65537854e1f03, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\WireMock.Net.1.5.24\lib\net461\WireMock.Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WireMock.Net.Abstractions, Version=1.5.24.0, Culture=neutral, PublicKeyToken=c8d65537854e1f03, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\WireMock.Net.Abstractions.1.5.24\lib\net461\WireMock.Net.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WireMock.Net.FluentAssertions, Version=1.5.24.0, Culture=neutral, PublicKeyToken=c8d65537854e1f03, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\WireMock.Net.FluentAssertions.1.5.24\lib\net451\WireMock.Net.FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WireMock.Net.OpenApiParser, Version=1.5.24.0, Culture=neutral, PublicKeyToken=c8d65537854e1f03, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\WireMock.Net.OpenApiParser.1.5.24\lib\net46\WireMock.Net.OpenApiParser.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WireMock.Org.Abstractions, Version=1.5.24.0, Culture=neutral, PublicKeyToken=c8d65537854e1f03, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\WireMock.Org.Abstractions.1.5.24\lib\net45\WireMock.Org.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="XPath2, Version=1.1.3.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\XPath2.1.1.3\lib\net452\XPath2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="XPath2.Extensions, Version=1.1.3.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\XPath2.Extensions.1.1.3\lib\net452\XPath2.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="YamlDotNet, Version=8.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\YamlDotNet.8.1.0\lib\net45\YamlDotNet.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\WireMock.Net.Console.Net452.Classic\CustomFileSystemFileHandler.cs">
|
||||
@@ -425,6 +389,16 @@
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj">
|
||||
<Project>{b6269aac-170a-4346-8b9a-579ded3d9a94}</Project>
|
||||
<Name>WireMock.Net.Abstractions</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj">
|
||||
<Project>{d3804228-91f4-4502-9595-39584e5a01ad}</Project>
|
||||
<Name>WireMock.Net</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
<packages>
|
||||
<package id="AnyOf" version="0.3.0" targetFramework="net472" />
|
||||
<package id="Fare" version="2.2.1" targetFramework="net472" />
|
||||
<package id="FluentAssertions" version="5.10.3" targetFramework="net472" />
|
||||
<package id="Handlebars.Net" version="2.1.4" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers" version="2.3.16" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.Core" version="2.3.16" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.DynamicLinq" version="2.3.16" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.Humanizer" version="2.3.16" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.Json" version="2.3.16" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.Random" version="2.3.16" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.Xeger" version="2.3.16" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.XPath" version="2.3.16" targetFramework="net472" />
|
||||
<package id="Handlebars.Net" version="2.1.2" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers" version="2.3.12" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.Core" version="2.3.12" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.DynamicLinq" version="2.3.12" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.Humanizer" version="2.3.12" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.Json" version="2.3.12" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.Random" version="2.3.12" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.Xeger" version="2.3.12" targetFramework="net472" />
|
||||
<package id="Handlebars.Net.Helpers.XPath" version="2.3.12" targetFramework="net472" />
|
||||
<package id="Humanizer" version="2.14.1" targetFramework="net472" />
|
||||
<package id="Humanizer.Core" version="2.14.1" targetFramework="net472" />
|
||||
<package id="Humanizer.Core.af" version="2.14.1" targetFramework="net472" />
|
||||
@@ -63,7 +62,6 @@
|
||||
<package id="Humanizer.Core.zh-Hans" version="2.14.1" targetFramework="net472" />
|
||||
<package id="Humanizer.Core.zh-Hant" version="2.14.1" targetFramework="net472" />
|
||||
<package id="JmesPath.Net" version="1.0.125" targetFramework="net472" />
|
||||
<package id="JsonConverter.Abstractions" version="0.4.0" targetFramework="net472" />
|
||||
<package id="log4net" version="2.0.15" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.8" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNetCore" version="2.2.0" targetFramework="net472" />
|
||||
@@ -124,18 +122,14 @@
|
||||
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="6.12.2" targetFramework="net472" />
|
||||
<package id="Microsoft.IdentityModel.Tokens" version="6.25.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Net.Http.Headers" version="2.2.0" targetFramework="net472" />
|
||||
<package id="Microsoft.OpenApi" version="1.2.3" targetFramework="net472" />
|
||||
<package id="Microsoft.OpenApi.Readers" version="1.2.3" targetFramework="net472" />
|
||||
<package id="Namotion.Reflection" version="2.0.10" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
|
||||
<package id="NJsonSchema" version="10.7.2" targetFramework="net472" />
|
||||
<package id="NJsonSchema" version="10.6.10" targetFramework="net472" />
|
||||
<package id="NJsonSchema.Extensions" version="0.1.0" targetFramework="net472" />
|
||||
<package id="NSwag.Core" version="13.16.1" targetFramework="net472" />
|
||||
<package id="NSwag.Core" version="13.15.10" targetFramework="net472" />
|
||||
<package id="Nullable" version="1.3.1" targetFramework="net472" developmentDependency="true" />
|
||||
<package id="RamlToOpenApiConverter" version="0.6.1" targetFramework="net472" />
|
||||
<package id="RandomDataGenerator.Net" version="1.0.17" targetFramework="net472" />
|
||||
<package id="Scriban.Signed" version="2.1.4" targetFramework="net472" />
|
||||
<package id="SharpYaml" version="1.6.5" targetFramework="net472" />
|
||||
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net461" />
|
||||
<package id="Stef.Validation" version="0.1.1" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
@@ -144,7 +138,7 @@
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.IdentityModel.Tokens.Jwt" version="6.25.0" targetFramework="net472" />
|
||||
<package id="System.IO.Pipelines" version="4.5.3" targetFramework="net472" />
|
||||
<package id="System.Linq.Dynamic.Core" version="1.3.1" targetFramework="net472" />
|
||||
<package id="System.Linq.Dynamic.Core" version="1.2.23" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net472" />
|
||||
@@ -157,12 +151,6 @@
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||
<package id="TinyMapper" version="3.0.3" targetFramework="net472" />
|
||||
<package id="WireMock.Net" version="1.5.24" targetFramework="net472" />
|
||||
<package id="WireMock.Net.Abstractions" version="1.5.24" targetFramework="net472" />
|
||||
<package id="WireMock.Net.FluentAssertions" version="1.5.24" targetFramework="net472" />
|
||||
<package id="WireMock.Net.OpenApiParser" version="1.5.24" targetFramework="net472" />
|
||||
<package id="WireMock.Org.Abstractions" version="1.5.24" targetFramework="net472" />
|
||||
<package id="XPath2" version="1.1.3" targetFramework="net472" />
|
||||
<package id="XPath2.Extensions" version="1.1.3" targetFramework="net472" />
|
||||
<package id="YamlDotNet" version="8.1.0" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using WireMock.Net.OpenApiParser.Types;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
|
||||
@@ -18,7 +19,7 @@ class Program
|
||||
private static void RunMockServerWithDynamicExampleGeneration()
|
||||
{
|
||||
// Run your mocking framework specifying your Example Values generator class.
|
||||
var serverCustomer_V2_json = Run.RunServer(Path.Combine(Folder, "Swagger_Customer_V2.0.json"), "http://localhost:8090/", true, new DynamicDataGeneration(), Types.ExampleValueType.Value, Types.ExampleValueType.Value);
|
||||
var serverCustomer_V2_json = Run.RunServer(Path.Combine(Folder, "Swagger_Customer_V2.0.json"), "http://localhost:8090/", true, new DynamicDataGeneration(), ExampleValueType.Value, ExampleValueType.Value);
|
||||
Console.WriteLine("Press any key to stop the servers");
|
||||
|
||||
Console.ReadKey();
|
||||
|
||||
@@ -143,6 +143,14 @@ public interface IRequestMessage
|
||||
/// </summary>
|
||||
string Origin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get a query parameter.
|
||||
/// </summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="ignoreCase">Defines if the key should be matched using case-ignore.</param>
|
||||
/// <returns>The query parameter value as WireMockList or null when not found.</returns>
|
||||
WireMockList<string>? GetParameter(string key, bool ignoreCase = false);
|
||||
|
||||
#if NETSTANDARD1_3_OR_GREATER || NET461
|
||||
/// <summary>
|
||||
/// Gets the connection's client certificate
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>FluentAssertions extensions for WireMock.Net</Description>
|
||||
<AssemblyTitle>WireMock.Net.FluentAssertions</AssemblyTitle>
|
||||
<Authors>Mahmoud Ali;Stef Heyenrath</Authors>
|
||||
<TargetFrameworks>net451;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<AssemblyName>WireMock.Net.FluentAssertions</AssemblyName>
|
||||
<PackageId>WireMock.Net.FluentAssertions</PackageId>
|
||||
<PackageTags>wiremock;FluentAssertions;UnitTest;Assert;Assertions</PackageTags>
|
||||
<RootNamespace>WireMock.FluentAssertions</RootNamespace>
|
||||
<ProjectGuid>{B6269AAC-170A-4346-8B9A-579DED3D9A95}</ProjectGuid>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
||||
<CodeAnalysisRuleSet>../WireMock.Net/WireMock.Net.ruleset</CodeAnalysisRuleSet>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>../WireMock.Net/WireMock.Net.snk</AssemblyOriginatorKeyFile>
|
||||
<!--<DelaySign>true</DelaySign>-->
|
||||
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<LangVersion>10</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<Description>FluentAssertions extensions for WireMock.Net</Description>
|
||||
<AssemblyTitle>WireMock.Net.FluentAssertions</AssemblyTitle>
|
||||
<Authors>Mahmoud Ali;Stef Heyenrath</Authors>
|
||||
<TargetFrameworks>net451;net47;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<AssemblyName>WireMock.Net.FluentAssertions</AssemblyName>
|
||||
<PackageId>WireMock.Net.FluentAssertions</PackageId>
|
||||
<PackageTags>wiremock;FluentAssertions;UnitTest;Assert;Assertions</PackageTags>
|
||||
<RootNamespace>WireMock.FluentAssertions</RootNamespace>
|
||||
<ProjectGuid>{B6269AAC-170A-4346-8B9A-579DED3D9A95}</ProjectGuid>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
||||
<CodeAnalysisRuleSet>../WireMock.Net/WireMock.Net.ruleset</CodeAnalysisRuleSet>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>../WireMock.Net/WireMock.Net.snk</AssemblyOriginatorKeyFile>
|
||||
<!--<DelaySign>true</DelaySign>-->
|
||||
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<LangVersion>10</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'netstandard1.3'">
|
||||
<PackageReference Include="FluentAssertions" Version="5.10.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'netstandard1.3'">
|
||||
<PackageReference Include="FluentAssertions" Version="5.10.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net451' and '$(TargetFramework)' != 'netstandard1.3'">
|
||||
<PackageReference Include="FluentAssertions" Version="6.5.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net451' and '$(TargetFramework)' != 'netstandard1.3'">
|
||||
<PackageReference Include="FluentAssertions" Version="6.5.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -23,12 +23,14 @@ internal class OpenApiPathsMapper
|
||||
private const string HeaderContentType = "Content-Type";
|
||||
|
||||
private readonly WireMockOpenApiParserSettings _settings;
|
||||
private readonly ExampleValueGenerator _exampleValueGenerator;
|
||||
private readonly IExampleValueGenerator _exampleValueGenerator;
|
||||
private readonly IExampleValueGenerator _regexExampleValueGenerator;
|
||||
|
||||
public OpenApiPathsMapper(WireMockOpenApiParserSettings settings)
|
||||
{
|
||||
_settings = Guard.NotNull(settings);
|
||||
_exampleValueGenerator = new ExampleValueGenerator(settings);
|
||||
_regexExampleValueGenerator = new RegexExampleValueGenerator(settings);
|
||||
}
|
||||
|
||||
public IReadOnlyList<MappingModel> ToMappingModels(OpenApiPaths? paths, IList<OpenApiServer> servers)
|
||||
@@ -37,18 +39,7 @@ internal class OpenApiPathsMapper
|
||||
.OrderBy(p => p.Key)
|
||||
.Select(p => MapPath(p.Key, p.Value, servers))
|
||||
.SelectMany(x => x)
|
||||
.ToArray() ??
|
||||
Array.Empty<MappingModel>();
|
||||
}
|
||||
|
||||
private IReadOnlyList<MappingModel> MapPaths(OpenApiPaths? paths, IList<OpenApiServer> servers)
|
||||
{
|
||||
return paths?
|
||||
.OrderBy(p => p.Key)
|
||||
.Select(p => MapPath(p.Key, p.Value, servers))
|
||||
.SelectMany(x => x)
|
||||
.ToArray() ??
|
||||
Array.Empty<MappingModel>();
|
||||
.ToArray() ?? Array.Empty<MappingModel>();
|
||||
}
|
||||
|
||||
private IReadOnlyList<MappingModel> MapPath(string path, OpenApiPathItem pathItem, IList<OpenApiServer> servers)
|
||||
@@ -280,41 +271,6 @@ internal class OpenApiPathsMapper
|
||||
return newPath;
|
||||
}
|
||||
|
||||
private string MapBasePath(IList<OpenApiServer>? servers)
|
||||
{
|
||||
if (servers == null || servers.Count == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
OpenApiServer server = servers.First();
|
||||
if (Uri.TryCreate(server.Url, UriKind.RelativeOrAbsolute, out Uri uriResult))
|
||||
{
|
||||
return uriResult.IsAbsoluteUri ? uriResult.AbsolutePath : uriResult.ToString();
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private JToken? MapOpenApiAnyToJToken(IOpenApiAny? any)
|
||||
{
|
||||
if (any == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var outputString = new StringWriter();
|
||||
var writer = new OpenApiJsonWriter(outputString);
|
||||
any.Write(writer, OpenApiSpecVersion.OpenApi3_0);
|
||||
|
||||
if (any.AnyType == AnyType.Array)
|
||||
{
|
||||
return JArray.Parse(outputString.ToString());
|
||||
}
|
||||
|
||||
return JObject.Parse(outputString.ToString());
|
||||
}
|
||||
|
||||
private IDictionary<string, object>? MapHeaders(string? responseContentType, IDictionary<string, OpenApiHeader>? headers)
|
||||
{
|
||||
var mappedHeaders = headers?.ToDictionary(
|
||||
@@ -366,28 +322,38 @@ internal class OpenApiPathsMapper
|
||||
return list.Any() ? list : null;
|
||||
}
|
||||
|
||||
private MatcherModel GetExampleMatcherModel(OpenApiSchema? schema, ExampleValueType type)
|
||||
private MatcherModel GetExampleMatcherModel(OpenApiSchema? schema, ExampleValueType exampleValueType)
|
||||
{
|
||||
return type switch
|
||||
return exampleValueType switch
|
||||
{
|
||||
ExampleValueType.Value => new MatcherModel
|
||||
{
|
||||
Name = "ExactMatcher",
|
||||
Pattern = GetExampleValueAsStringForSchemaType(schema),
|
||||
Pattern = GetExampleValueAsStringForSchemaType(schema, exampleValueType),
|
||||
IgnoreCase = _settings.IgnoreCaseExampleValues
|
||||
},
|
||||
|
||||
ExampleValueType.Regex => new MatcherModel
|
||||
{
|
||||
Name = "RegexMatcher",
|
||||
Pattern = GetExampleValueAsStringForSchemaType(schema, exampleValueType),
|
||||
IgnoreCase = _settings.IgnoreCaseExampleValues
|
||||
},
|
||||
|
||||
_ => new MatcherModel
|
||||
{
|
||||
Name = "WildcardMatcher",
|
||||
Pattern = "*"
|
||||
Pattern = "*",
|
||||
IgnoreCase = _settings.IgnoreCaseExampleValues
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private string GetExampleValueAsStringForSchemaType(OpenApiSchema? schema)
|
||||
private string GetExampleValueAsStringForSchemaType(OpenApiSchema? schema, ExampleValueType exampleValueType)
|
||||
{
|
||||
var value = _exampleValueGenerator.GetExampleValue(schema);
|
||||
var value = exampleValueType == ExampleValueType.Regex ?
|
||||
_regexExampleValueGenerator.GetExampleValue(schema) :
|
||||
_exampleValueGenerator.GetExampleValue(schema);
|
||||
|
||||
return value switch
|
||||
{
|
||||
@@ -396,4 +362,39 @@ internal class OpenApiPathsMapper
|
||||
_ => value.ToString(),
|
||||
};
|
||||
}
|
||||
|
||||
private static string MapBasePath(IList<OpenApiServer>? servers)
|
||||
{
|
||||
if (servers == null || servers.Count == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var server = servers.First();
|
||||
if (Uri.TryCreate(server.Url, UriKind.RelativeOrAbsolute, out Uri uriResult))
|
||||
{
|
||||
return uriResult.IsAbsoluteUri ? uriResult.AbsolutePath : uriResult.ToString();
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static JToken? MapOpenApiAnyToJToken(IOpenApiAny? any)
|
||||
{
|
||||
if (any == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var outputString = new StringWriter();
|
||||
var writer = new OpenApiJsonWriter(outputString);
|
||||
any.Write(writer, OpenApiSpecVersion.OpenApi3_0);
|
||||
|
||||
if (any.AnyType == AnyType.Array)
|
||||
{
|
||||
return JArray.Parse(outputString.ToString());
|
||||
}
|
||||
|
||||
return JObject.Parse(outputString.ToString());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace WireMock.Net.OpenApiParser.Types;
|
||||
|
||||
/// <summary>
|
||||
/// The example value to use
|
||||
/// The (example) value pattern to use.
|
||||
/// </summary>
|
||||
public enum ExampleValueType
|
||||
{
|
||||
@@ -12,6 +12,11 @@ public enum ExampleValueType
|
||||
/// </summary>
|
||||
Value,
|
||||
|
||||
/// <summary>
|
||||
/// Build a Regex based on the SchemaType.
|
||||
/// </summary>
|
||||
Regex,
|
||||
|
||||
/// <summary>
|
||||
/// Just use a Wildcard (*) character.
|
||||
/// </summary>
|
||||
|
||||
@@ -8,7 +8,7 @@ using WireMock.Net.OpenApiParser.Types;
|
||||
|
||||
namespace WireMock.Net.OpenApiParser.Utils;
|
||||
|
||||
internal class ExampleValueGenerator
|
||||
internal class ExampleValueGenerator : IExampleValueGenerator
|
||||
{
|
||||
private readonly IWireMockOpenApiParserExampleValues _exampleValues;
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
namespace WireMock.Net.OpenApiParser.Utils;
|
||||
|
||||
internal interface IExampleValueGenerator
|
||||
{
|
||||
object GetExampleValue(OpenApiSchema? schema);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Stef.Validation;
|
||||
using WireMock.Net.OpenApiParser.Extensions;
|
||||
using WireMock.Net.OpenApiParser.Settings;
|
||||
using WireMock.Net.OpenApiParser.Types;
|
||||
|
||||
namespace WireMock.Net.OpenApiParser.Utils;
|
||||
|
||||
internal class RegexExampleValueGenerator : IExampleValueGenerator
|
||||
{
|
||||
public RegexExampleValueGenerator(WireMockOpenApiParserSettings settings)
|
||||
{
|
||||
Guard.NotNull(settings);
|
||||
}
|
||||
|
||||
public object GetExampleValue(OpenApiSchema? schema)
|
||||
{
|
||||
switch (schema?.GetSchemaType())
|
||||
{
|
||||
case SchemaType.Boolean:
|
||||
return @"(true|false)";
|
||||
|
||||
case SchemaType.Integer:
|
||||
return @"-?\d+";
|
||||
|
||||
case SchemaType.Number:
|
||||
return @"[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?";
|
||||
|
||||
default:
|
||||
return schema?.GetSchemaFormat() switch
|
||||
{
|
||||
SchemaFormat.Date => @"(\d{4})-([01]\d)-([0-3]\d)",
|
||||
SchemaFormat.DateTime => @"(\d{4})-([01]\d)-([0-3]\d)T([0-2]\d):([0-5]\d):([0-5]\d)(\.\d+)?(Z|[+-][0-2]\d:[0-5]\d)",
|
||||
SchemaFormat.Byte => @"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
|
||||
SchemaFormat.Binary => @"[a-zA-Z0-9\+/]*={0,3}",
|
||||
_ => ".*"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ using RamlToOpenApiConverter;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Net.OpenApiParser.Mappers;
|
||||
using WireMock.Net.OpenApiParser.Settings;
|
||||
using WireMock.Net.OpenApiParser.Types;
|
||||
|
||||
namespace WireMock.Net.OpenApiParser;
|
||||
|
||||
@@ -17,13 +18,20 @@ namespace WireMock.Net.OpenApiParser;
|
||||
/// </summary>
|
||||
public class WireMockOpenApiParser : IWireMockOpenApiParser
|
||||
{
|
||||
private readonly WireMockOpenApiParserSettings _wireMockOpenApiParserSettings = new WireMockOpenApiParserSettings
|
||||
{
|
||||
HeaderPatternToUse = ExampleValueType.Regex,
|
||||
QueryParameterPatternToUse = ExampleValueType.Regex,
|
||||
PathPatternToUse = ExampleValueType.Regex
|
||||
};
|
||||
|
||||
private readonly OpenApiStreamReader _reader = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
[PublicAPI]
|
||||
public IReadOnlyList<MappingModel> FromFile(string path, out OpenApiDiagnostic diagnostic)
|
||||
{
|
||||
return FromFile(path, new WireMockOpenApiParserSettings(), out diagnostic);
|
||||
return FromFile(path, _wireMockOpenApiParserSettings, out diagnostic);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -49,7 +57,7 @@ public class WireMockOpenApiParser : IWireMockOpenApiParser
|
||||
[PublicAPI]
|
||||
public IReadOnlyList<MappingModel> FromDocument(OpenApiDocument openApiDocument, WireMockOpenApiParserSettings? settings = null)
|
||||
{
|
||||
return new OpenApiPathsMapper(settings ?? new WireMockOpenApiParserSettings()).ToMappingModels(openApiDocument.Paths, openApiDocument.Servers);
|
||||
return new OpenApiPathsMapper(settings ?? _wireMockOpenApiParserSettings).ToMappingModels(openApiDocument.Paths, openApiDocument.Servers);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
17
src/WireMock.Net/.filenesting.json
Normal file
17
src/WireMock.Net/.filenesting.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"help": "https://go.microsoft.com/fwlink/?linkid=866610",
|
||||
"root": true,
|
||||
|
||||
"dependentFileProviders": {
|
||||
"add": {
|
||||
"addedExtension": {},
|
||||
"pathSegment": {
|
||||
"add": {
|
||||
".*": [
|
||||
".cs"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace WireMock.Owin
|
||||
public Task Invoke(IContext ctx)
|
||||
#endif
|
||||
{
|
||||
if (_options.HandleRequestsSynchronously.GetValueOrDefault(true))
|
||||
if (_options.HandleRequestsSynchronously.GetValueOrDefault(false))
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
@@ -216,7 +216,12 @@ namespace WireMock.Owin
|
||||
{
|
||||
try
|
||||
{
|
||||
await webhookSender.SendAsync(httpClientForWebhook, mapping, webhookRequest, request, response).ConfigureAwait(false);
|
||||
var result = await webhookSender.SendAsync(httpClientForWebhook, mapping, webhookRequest, request, response).ConfigureAwait(false);
|
||||
if (!result.IsSuccessStatusCode)
|
||||
{
|
||||
var content = await result.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
_options.Logger.Warn($"Sending message to Webhook [{webHookIndex}] from Mapping '{mapping.Guid}' failed. HttpStatusCode: {result.StatusCode} Content: {content}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -180,12 +180,7 @@ public class RequestMessage : IRequestMessage
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a query parameter.
|
||||
/// </summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="ignoreCase">Defines if the key should be matched using case-ignore.</param>
|
||||
/// <returns>The query parameter.</returns>
|
||||
/// <inheritdoc />
|
||||
public WireMockList<string>? GetParameter(string key, bool ignoreCase = false)
|
||||
{
|
||||
if (Query == null)
|
||||
|
||||
@@ -107,11 +107,28 @@ internal class MappingConverter
|
||||
|
||||
if (bodyMatcher is { Matchers: { } })
|
||||
{
|
||||
var wildcardMatcher = bodyMatcher.Matchers.OfType<WildcardMatcher>().FirstOrDefault();
|
||||
if (wildcardMatcher is { } && wildcardMatcher.GetPatterns().Any())
|
||||
if (bodyMatcher.Matchers.OfType<WildcardMatcher>().FirstOrDefault() is { } wildcardMatcher && wildcardMatcher.GetPatterns().Any())
|
||||
{
|
||||
sb.AppendLine($" .WithBody({GetString(wildcardMatcher)})");
|
||||
}
|
||||
else if (bodyMatcher.Matchers.OfType<JsonPartialMatcher>().FirstOrDefault() is { Value: { } } jsonPartialMatcher)
|
||||
{
|
||||
sb.AppendLine(@$" .WithBody(new JsonPartialMatcher(
|
||||
value: {ToCSharpStringLiteral(jsonPartialMatcher.Value.ToString())},
|
||||
ignoreCase: {ToCSharpBooleanLiteral(jsonPartialMatcher.IgnoreCase)},
|
||||
throwException: {ToCSharpBooleanLiteral(jsonPartialMatcher.ThrowException)},
|
||||
regex: {ToCSharpBooleanLiteral(jsonPartialMatcher.Regex)}
|
||||
))");
|
||||
}
|
||||
else if (bodyMatcher.Matchers.OfType<JsonPartialWildcardMatcher>().FirstOrDefault() is { Value: { } } jsonPartialWildcardMatcher)
|
||||
{
|
||||
sb.AppendLine(@$" .WithBody(new JsonPartialWildcardMatcher(
|
||||
value: {ToCSharpStringLiteral(jsonPartialWildcardMatcher.Value.ToString())},
|
||||
ignoreCase: {ToCSharpBooleanLiteral(jsonPartialWildcardMatcher.IgnoreCase)},
|
||||
throwException: {ToCSharpBooleanLiteral(jsonPartialWildcardMatcher.ThrowException)},
|
||||
regex: {ToCSharpBooleanLiteral(jsonPartialWildcardMatcher.Regex)}
|
||||
))");
|
||||
}
|
||||
}
|
||||
|
||||
sb.AppendLine(@" )");
|
||||
|
||||
@@ -2,20 +2,39 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Newtonsoft.Json;
|
||||
using WireMock.Net.OpenApiParser;
|
||||
using WireMock.Net.OpenApiParser.Settings;
|
||||
using WireMock.Net.OpenApiParser.Types;
|
||||
using WireMock.Serialization;
|
||||
#endif
|
||||
|
||||
namespace WireMock.Server;
|
||||
|
||||
public partial class WireMockServer
|
||||
{
|
||||
#if OPENAPIPARSER
|
||||
private readonly WireMockOpenApiParserSettings _openApiParserSettings = new WireMockOpenApiParserSettings
|
||||
{
|
||||
PathPatternToUse = ExampleValueType.Regex,
|
||||
HeaderPatternToUse = ExampleValueType.Regex,
|
||||
QueryParameterPatternToUse = ExampleValueType.Regex
|
||||
};
|
||||
#endif
|
||||
|
||||
private IResponseMessage OpenApiConvertToMappings(IRequestMessage requestMessage)
|
||||
{
|
||||
#if OPENAPIPARSER
|
||||
try
|
||||
{
|
||||
var mappingModels = new WireMockOpenApiParser().FromText(requestMessage.Body, out var diagnostic);
|
||||
return diagnostic.Errors.Any() ? ToJson(diagnostic, false, HttpStatusCode.BadRequest) : ToJson(mappingModels);
|
||||
if (diagnostic.Errors.Any())
|
||||
{
|
||||
var diagnosticAsJson = JsonConvert.SerializeObject(diagnostic, JsonSerializationConstants.JsonSerializerSettingsDefault);
|
||||
_settings.Logger.Warn("OpenApiError(s) while converting OpenAPI specification to MappingModel(s) : {0}", diagnosticAsJson);
|
||||
}
|
||||
|
||||
return ToJson(mappingModels);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -35,7 +54,8 @@ public partial class WireMockServer
|
||||
var mappingModels = new WireMockOpenApiParser().FromText(requestMessage.Body, out var diagnostic);
|
||||
if (diagnostic.Errors.Any())
|
||||
{
|
||||
return ToJson(diagnostic, false, HttpStatusCode.BadRequest);
|
||||
var diagnosticAsJson = JsonConvert.SerializeObject(diagnostic, JsonSerializationConstants.JsonSerializerSettingsDefault);
|
||||
_settings.Logger.Warn("OpenApiError(s) while converting OpenAPI specification to MappingModel(s) : {0}", diagnosticAsJson);
|
||||
}
|
||||
|
||||
ConvertMappingsAndRegisterAsRespondProvider(mappingModels);
|
||||
|
||||
@@ -92,6 +92,7 @@ internal static class CSharpFormatter
|
||||
"while"
|
||||
});
|
||||
#endregion
|
||||
|
||||
private const string Null = "null";
|
||||
|
||||
public static object ConvertToAnonymousObjectDefinition(object jsonBody)
|
||||
@@ -104,7 +105,7 @@ internal static class CSharpFormatter
|
||||
return ConvertJsonToAnonymousObjectDefinition(deserializedBody, 2);
|
||||
}
|
||||
|
||||
private static string ConvertJsonToAnonymousObjectDefinition(JToken token, int ind = 0)
|
||||
public static string ConvertJsonToAnonymousObjectDefinition(JToken token, int ind = 0)
|
||||
{
|
||||
return token switch
|
||||
{
|
||||
@@ -127,19 +128,29 @@ internal static class CSharpFormatter
|
||||
_ => $"UNHANDLED_CASE: {token}"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static string ToCSharpBooleanLiteral(bool value) => value ? "true" : "false";
|
||||
|
||||
public static string ToCSharpStringLiteral(string? value)
|
||||
{
|
||||
var escapedValue = value?.Replace("\"", "\\\"") ?? string.Empty;
|
||||
if (escapedValue.Contains("\n"))
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return $"@\"{escapedValue}\"";
|
||||
return "\"\"";
|
||||
}
|
||||
|
||||
return $"\"{escapedValue}\"";
|
||||
if (value.Contains("\n"))
|
||||
{
|
||||
var escapedValue = value?.Replace("\"", "\"\"") ?? string.Empty;
|
||||
return $"@\"{escapedValue}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
var escapedValue = value?.Replace("\"", "\\\"") ?? string.Empty;
|
||||
return $"\"{escapedValue}\"";
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatPropertyName(string propertyName)
|
||||
public static string FormatPropertyName(string propertyName)
|
||||
{
|
||||
return CSharpReservedKeywords.Contains(propertyName) ? "@" + propertyName : propertyName;
|
||||
}
|
||||
|
||||
@@ -10,17 +10,17 @@ public class BytesEncodingUtilsTests
|
||||
[Fact]
|
||||
public void TryGetEncoding_UTF32()
|
||||
{
|
||||
var result = BytesEncodingUtils.TryGetEncoding(new byte[] { 0xff, 0xfe, 0x00, 0x00 }, out Encoding encoding);
|
||||
var result = BytesEncodingUtils.TryGetEncoding(new byte[] { 0xff, 0xfe, 0x00, 0x00 }, out var encoding);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
encoding.CodePage.Should().Be(Encoding.UTF32.CodePage);
|
||||
encoding?.CodePage.Should().Be(Encoding.UTF32.CodePage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryGetEncoding_Invalid()
|
||||
{
|
||||
var result = BytesEncodingUtils.TryGetEncoding(new byte[] { 0xff }, out Encoding encoding);
|
||||
var result = BytesEncodingUtils.TryGetEncoding(new byte[] { 0xff }, out var encoding);
|
||||
|
||||
// Assert
|
||||
result.Should().BeFalse();
|
||||
|
||||
105
test/WireMock.Net.Tests/Util/CSharpFormatterTests.cs
Normal file
105
test/WireMock.Net.Tests/Util/CSharpFormatterTests.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using FluentAssertions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using WireMock.Util;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Util;
|
||||
|
||||
public class CSharpFormatterTests
|
||||
{
|
||||
[Fact]
|
||||
public void ConvertToAnonymousObjectDefinition_ShouldReturn_ValidValue_WhenJsonBodyIsValidJsonString()
|
||||
{
|
||||
// Arrange
|
||||
var jsonBody = new { Key1 = "value1", Key2 = 42, F = 1.2 };
|
||||
var expectedOutput = "new\r\n {\r\n Key1 = \"value1\",\r\n Key2 = 42,\r\n F = 1.2\r\n }";
|
||||
|
||||
// Act
|
||||
var result = CSharpFormatter.ConvertToAnonymousObjectDefinition(jsonBody);
|
||||
|
||||
// Assert
|
||||
result.Should().Be(expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToCSharpStringLiteral_ShouldReturn_ValidValue_WhenStringIsNotNull()
|
||||
{
|
||||
// Arrange
|
||||
var inputString = "test string";
|
||||
var expectedOutput = "\"test string\"";
|
||||
|
||||
// Act
|
||||
var result = CSharpFormatter.ToCSharpStringLiteral(inputString);
|
||||
|
||||
// Assert
|
||||
result.Should().Be(expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToCSharpStringLiteral_ShouldReturn_ValidValue_WhenStringContainsNewLineCharacters()
|
||||
{
|
||||
// Arrange
|
||||
var inputString = "line1\nline2\nline3";
|
||||
var expectedOutput = "@\"line1\nline2\nline3\"";
|
||||
|
||||
// Action
|
||||
var result = CSharpFormatter.ToCSharpStringLiteral(inputString);
|
||||
|
||||
// Assert
|
||||
result.Should().Be(expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FormatPropertyName_ShouldReturn_ValidPropertyName_WhenPropertyNameIsNotReserved()
|
||||
{
|
||||
// Arrange
|
||||
var propertyName = "propertyname";
|
||||
var expectedOutput = "propertyname";
|
||||
|
||||
// Action
|
||||
var result = CSharpFormatter.FormatPropertyName(propertyName);
|
||||
|
||||
// Assert
|
||||
result.Should().Be(expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FormatPropertyName_ShouldReturn_ValidPropertyName_WhenPropertyNameIsReserved()
|
||||
{
|
||||
// Arrange
|
||||
var propertyName = "class";
|
||||
var expectedOutput = "@class";
|
||||
|
||||
// Action
|
||||
var result = CSharpFormatter.FormatPropertyName(propertyName);
|
||||
|
||||
// Assert
|
||||
result.Should().Be(expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertJsonToAnonymousObjectDefinition_ShouldReturn_ValidObject_WhenJsonInputIsValid()
|
||||
{
|
||||
// Arrange
|
||||
var jObject = new JObject
|
||||
(
|
||||
new JProperty("Name", "John Smith"),
|
||||
new JProperty("Age", 25.1f),
|
||||
new JProperty("Gender", "Male"),
|
||||
new JProperty("address", new JObject
|
||||
(
|
||||
new JProperty("Street", "123 Main St"),
|
||||
new JProperty("City", "Anytown"),
|
||||
new JProperty("State", "CA"),
|
||||
new JProperty("Zip", "90001")
|
||||
)
|
||||
));
|
||||
var expectedOutput = "new\r\n{\r\n Name = \"John Smith\",\r\n Age = 25.1,\r\n Gender = \"Male\",\r\n address = new\r\n {\r\n Street = \"123 Main St\",\r\n City = \"Anytown\",\r\n State = \"CA\",\r\n Zip = \"90001\"\r\n }\r\n}";
|
||||
|
||||
// Action
|
||||
var result = CSharpFormatter.ConvertJsonToAnonymousObjectDefinition(jObject);
|
||||
|
||||
// Assert
|
||||
result.Should().Be(expectedOutput);
|
||||
}
|
||||
}
|
||||
@@ -70,3 +70,21 @@ text
|
||||
})
|
||||
);
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.UsingMethod("POST")
|
||||
.WithPath("/foo3")
|
||||
.WithBody(new JsonPartialMatcher(
|
||||
value: "{ a = 1, b = 2 }",
|
||||
ignoreCase: false,
|
||||
throwException: false,
|
||||
regex: false
|
||||
))
|
||||
)
|
||||
.WithGuid("4126dec8-470b-4eff-93bb-c24f83b8b1fd")
|
||||
.RespondWith(Response.Create()
|
||||
.WithStatusCode(200)
|
||||
.WithBody(@"Line1
|
||||
Some ""value"" in Line2")
|
||||
);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ using WireMock.Admin.Settings;
|
||||
using WireMock.Client;
|
||||
using WireMock.Handlers;
|
||||
using WireMock.Logging;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Models;
|
||||
using WireMock.Net.Tests.VerifyExtensions;
|
||||
using WireMock.RequestBuilders;
|
||||
@@ -719,6 +720,7 @@ public class WireMockAdminApiTests
|
||||
var guid1 = Guid.Parse("90356dba-b36c-469a-a17e-669cd84f1f05");
|
||||
var guid2 = Guid.Parse("1b731398-4a5b-457f-a6e3-d65e541c428f");
|
||||
var guid3 = Guid.Parse("f74fd144-df53-404f-8e35-da22a640bd5f");
|
||||
var guid4 = Guid.Parse("4126DEC8-470B-4EFF-93BB-C24F83B8B1FD");
|
||||
var server = WireMockServer.StartWithAdminInterface();
|
||||
|
||||
server
|
||||
@@ -769,11 +771,25 @@ text
|
||||
" })
|
||||
);
|
||||
|
||||
server
|
||||
.Given(
|
||||
Request.Create()
|
||||
.WithPath("/foo3")
|
||||
.WithBody(new JsonPartialMatcher(new { a=1, b=2}))
|
||||
.UsingPost()
|
||||
)
|
||||
.WithGuid(guid4)
|
||||
.RespondWith(
|
||||
Response.Create()
|
||||
.WithStatusCode(200)
|
||||
.WithBody("Line1\r\nSome \"value\" in Line2")
|
||||
);
|
||||
|
||||
// Act
|
||||
var api = RestClient.For<IWireMockAdminApi>(server.Url);
|
||||
|
||||
var mappings = await api.GetMappingsAsync().ConfigureAwait(false);
|
||||
mappings.Should().HaveCount(3);
|
||||
mappings.Should().HaveCount(4);
|
||||
|
||||
var code = await api.GetMappingsCodeAsync().ConfigureAwait(false);
|
||||
|
||||
|
||||
@@ -4,10 +4,13 @@ using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using WireMock.Logging;
|
||||
using WireMock.Models;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Server;
|
||||
using WireMock.Settings;
|
||||
using WireMock.Types;
|
||||
using WireMock.Util;
|
||||
using Xunit;
|
||||
@@ -71,7 +74,7 @@ public class WireMockServerWebhookTests
|
||||
|
||||
// Assert
|
||||
var response = await new HttpClient().SendAsync(request).ConfigureAwait(false);
|
||||
string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
content.Should().Be("a-response");
|
||||
@@ -120,7 +123,7 @@ public class WireMockServerWebhookTests
|
||||
|
||||
// Assert
|
||||
var response = await new HttpClient().SendAsync(request).ConfigureAwait(false);
|
||||
string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
content.Should().Be("a-response");
|
||||
@@ -132,6 +135,115 @@ public class WireMockServerWebhookTests
|
||||
serverReceivingTheWebhook.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithWebhook_When_WebhookEndPointReturnsError_Should_LogWarning()
|
||||
{
|
||||
// Arrange
|
||||
var serverReceivingTheWebhook = WireMockServer.Start();
|
||||
serverReceivingTheWebhook.Given(Request.Create().WithPath("/x").UsingPost()).RespondWith(Response.Create().WithBody("!Server Error!").WithStatusCode(500));
|
||||
|
||||
var loggerMock = new Mock<IWireMockLogger>();
|
||||
var settings = new WireMockServerSettings
|
||||
{
|
||||
Logger = loggerMock.Object
|
||||
};
|
||||
|
||||
// Act
|
||||
var guid = "942cb963-c9a3-4e9c-8e71-c1b26d2a4a05";
|
||||
var server = WireMockServer.Start(settings);
|
||||
server.Given(Request.Create().UsingPost())
|
||||
.WithWebhook(new Webhook
|
||||
{
|
||||
Request = new WebhookRequest
|
||||
{
|
||||
Url = serverReceivingTheWebhook.Url! + "/{{request.Query.q}}",
|
||||
Method = "post",
|
||||
BodyData = new BodyData
|
||||
{
|
||||
BodyAsString = "abc",
|
||||
DetectedBodyType = BodyType.String,
|
||||
DetectedBodyTypeFromContentType = BodyType.String
|
||||
},
|
||||
UseTransformer = true
|
||||
}
|
||||
})
|
||||
.WithGuid(guid)
|
||||
.RespondWith(Response.Create().WithBody("a-response"));
|
||||
|
||||
var request = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri($"{server.Urls[0]}/TST?q=x"),
|
||||
Content = new StringContent("test")
|
||||
};
|
||||
|
||||
// Assert
|
||||
var response = await new HttpClient().SendAsync(request).ConfigureAwait(false);
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
content.Should().Be("a-response");
|
||||
|
||||
loggerMock.Verify(l => l.Warn("Sending message to Webhook [0] from Mapping '942cb963-c9a3-4e9c-8e71-c1b26d2a4a05' failed. HttpStatusCode: InternalServerError Content: !Server Error!"));
|
||||
|
||||
serverReceivingTheWebhook.LogEntries.Should().HaveCount(1);
|
||||
serverReceivingTheWebhook.LogEntries.First().MappingGuid.Should().NotBeNull();
|
||||
|
||||
server.Dispose();
|
||||
serverReceivingTheWebhook.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithWebhook_When_WebhookEndPointDoesNotExists_Should_LogError()
|
||||
{
|
||||
// Arrange
|
||||
var loggerMock = new Mock<IWireMockLogger>();
|
||||
var settings = new WireMockServerSettings
|
||||
{
|
||||
Logger = loggerMock.Object
|
||||
};
|
||||
|
||||
// Act
|
||||
var guid = "942cb963-c9a3-4e9c-8e71-c1b26d2a4a05";
|
||||
var server = WireMockServer.Start(settings);
|
||||
server.Given(Request.Create().UsingPost())
|
||||
.WithWebhook(new Webhook
|
||||
{
|
||||
Request = new WebhookRequest
|
||||
{
|
||||
Url = "http://error-not-does-exist-" + Guid.NewGuid(),
|
||||
Method = "post",
|
||||
BodyData = new BodyData
|
||||
{
|
||||
BodyAsString = "abc",
|
||||
DetectedBodyType = BodyType.String,
|
||||
DetectedBodyTypeFromContentType = BodyType.String
|
||||
},
|
||||
UseTransformer = true
|
||||
}
|
||||
})
|
||||
.WithGuid(guid)
|
||||
.RespondWith(Response.Create().WithBody("a-response"));
|
||||
|
||||
var request = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri(server.Urls[0]),
|
||||
Content = new StringContent("test")
|
||||
};
|
||||
|
||||
// Assert
|
||||
var response = await new HttpClient().SendAsync(request).ConfigureAwait(false);
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
content.Should().Be("a-response");
|
||||
|
||||
loggerMock.Verify(l => l.Error(It.Is<string>(formatString => formatString.Contains("Sending message to Webhook [0] from Mapping '942cb963-c9a3-4e9c-8e71-c1b26d2a4a05' failed. Exception"))));
|
||||
|
||||
server.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithWebhookArgs_Should_Send_StringMessage_To_Webhook()
|
||||
{
|
||||
@@ -142,7 +254,7 @@ public class WireMockServerWebhookTests
|
||||
// Act
|
||||
var server = WireMockServer.Start();
|
||||
server.Given(Request.Create().UsingPost())
|
||||
.WithWebhook(serverReceivingTheWebhook.Urls[0], "post", null, "OK !", true, TransformerType.Handlebars)
|
||||
.WithWebhook(serverReceivingTheWebhook.Urls[0], "post", null, "OK !")
|
||||
.RespondWith(Response.Create().WithBody("a-response"));
|
||||
|
||||
var request = new HttpRequestMessage
|
||||
@@ -154,7 +266,7 @@ public class WireMockServerWebhookTests
|
||||
|
||||
// Assert
|
||||
var response = await new HttpClient().SendAsync(request).ConfigureAwait(false);
|
||||
string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
content.Should().Be("a-response");
|
||||
@@ -176,7 +288,7 @@ public class WireMockServerWebhookTests
|
||||
// Act
|
||||
var server = WireMockServer.Start();
|
||||
server.Given(Request.Create().UsingPost())
|
||||
.WithWebhook(serverReceivingTheWebhook.Urls[0], "post", null, new { Status = "OK" }, true, TransformerType.Handlebars)
|
||||
.WithWebhook(serverReceivingTheWebhook.Urls[0], "post", null, new { Status = "OK" })
|
||||
.RespondWith(Response.Create().WithBody("a-response"));
|
||||
|
||||
var request = new HttpRequestMessage
|
||||
@@ -188,7 +300,7 @@ public class WireMockServerWebhookTests
|
||||
|
||||
// Assert
|
||||
var response = await new HttpClient().SendAsync(request).ConfigureAwait(false);
|
||||
string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
content.Should().Be("a-response");
|
||||
|
||||
Reference in New Issue
Block a user