Compare commits

..

12 Commits

Author SHA1 Message Date
Stef Heyenrath
44be24a129 ... 2024-02-09 10:19:40 +01:00
Stef Heyenrath
0185b116ca fix 2024-01-30 20:22:20 +01:00
Stef Heyenrath
237cd227d9 Add startup option for WireMockNoNewLinesConsoleLogger 2024-01-30 13:25:06 +01:00
Stef Heyenrath
801546fae7 1.5.47 2024-01-25 10:13:54 +01:00
Stef Heyenrath
57c42492bc Pin the version from Testcontainers to 3.7.0 in WireMock.Net.Testcontainers (#1057)
* TestcontainersTests

* WireMockContainer_Build_and_StartAsync_and_StopAsync

* --

* [3.7.0]
2024-01-25 09:54:25 +01:00
dependabot[bot]
057cd6c963 Bump System.IdentityModel.Tokens.Jwt (#1055)
Bumps [System.IdentityModel.Tokens.Jwt](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet) from 6.25.0 to 6.34.0.
- [Release notes](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/releases)
- [Changelog](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/compare/6.25.0...6.34.0)

---
updated-dependencies:
- dependency-name: System.IdentityModel.Tokens.Jwt
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-23 21:48:41 +01:00
Stef Heyenrath
b2b7172043 fix: src/WireMock.Net/WireMock.Net.csproj to reduce vulnerabilities (#1053)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-DOTNET-MICROSOFTIDENTITYMODELJSONWEBTOKENS-6148656
- https://snyk.io/vuln/SNYK-DOTNET-SYSTEMIDENTITYMODELTOKENSJWT-6148655

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
2024-01-23 21:32:55 +01:00
Stef Heyenrath
13a3dfa9fe Update README.md 2024-01-08 08:12:38 +01:00
Stef Heyenrath
4020a178a6 Add WithoutHeader to WireMock.FluentAssertions (#1049)
* Add WithoutHeader to WireMock.FluentAssertions

* .

* .
2023-12-27 08:18:56 +01:00
Stef Heyenrath
30ee768430 1.5.46 2023-12-23 09:44:59 +01:00
Thomas Levesque
5299ced000 Change FindRequestByMappingGuidAsync to return a collection of entries (#1046) 2023-12-23 09:40:35 +01:00
Stef Heyenrath
e4df6cc93d WireMockServerSettingsParser (#1044)
* WireMockServerSettingsParser

* nameof
2023-12-22 14:36:42 +01:00
21 changed files with 279 additions and 121 deletions

View File

@@ -1,3 +1,15 @@
# 1.5.47 (25 January 2024)
- [#1049](https://github.com/WireMock-Net/WireMock.Net/pull/1049) - Add WithoutHeader to WireMock.FluentAssertions [feature] contributed by [StefH](https://github.com/StefH)
- [#1053](https://github.com/WireMock-Net/WireMock.Net/pull/1053) - [Snyk] Security upgrade Microsoft.IdentityModel.Protocols.OpenIdConnect from 6.12.2 to 6.34.0 [security] contributed by [StefH](https://github.com/StefH)
- [#1057](https://github.com/WireMock-Net/WireMock.Net/pull/1057) - Pin the version from Testcontainers to 3.7.0 in WireMock.Net.Testcontainers [bug] contributed by [StefH](https://github.com/StefH)
- [#1048](https://github.com/WireMock-Net/WireMock.Net/issues/1048) - WithoutHeader fluent assertion [feature]
- [#1054](https://github.com/WireMock-Net/WireMock.Net/issues/1054) - WireMock.Net 1.5.46 is incompatible with TestContainers 3.7.0 (issue 1) [bug]
- [#1059](https://github.com/WireMock-Net/WireMock.Net/issues/1059) - WireMock.Net 1.5.46 is incompatible with TestContainers 3.7.0 (issue 2) [bug]
# 1.5.46 (23 December 2023)
- [#1044](https://github.com/WireMock-Net/WireMock.Net/pull/1044) - WireMockServerSettingsParser [refactor] contributed by [StefH](https://github.com/StefH)
- [#1046](https://github.com/WireMock-Net/WireMock.Net/pull/1046) - Change FindRequestByMappingGuidAsync to return a collection of entries contributed by [tlevesque-ueat](https://github.com/tlevesque-ueat)
# 1.5.45 (21 December 2023)
- [#1036](https://github.com/WireMock-Net/WireMock.Net/pull/1036) - Update Handlebars Transformer logic (ReplaceNodeOptions) [feature] contributed by [StefH](https://github.com/StefH)
- [#1043](https://github.com/WireMock-Net/WireMock.Net/pull/1043) - FindRequestByMappingGuidAsync [feature] contributed by [StefH](https://github.com/StefH)
@@ -174,7 +186,6 @@
# 1.5.13 (11 December 2022)
- [#858](https://github.com/WireMock-Net/WireMock.Net/pull/858) - Update Transformer functionality to return value instead of string [feature] contributed by [StefH](https://github.com/StefH)
- [#859](https://github.com/WireMock-Net/WireMock.Net/pull/859) - Add UpdatedAt property to Mapping [feature] contributed by [StefH](https://github.com/StefH)
- [#861](https://github.com/WireMock-Net/WireMock.Net/pull/861) - Add extra functionality for issue 55 contributed by [StefH](https://github.com/StefH)
- [#862](https://github.com/WireMock-Net/WireMock.Net/pull/862) - Add client certificate support [feature] contributed by [billybraga](https://github.com/billybraga)
- [#863](https://github.com/WireMock-Net/WireMock.Net/pull/863) - Update WireMockServer.CreateClient/CreateClients to include handlers [feature] contributed by [StefH](https://github.com/StefH)
- [#856](https://github.com/WireMock-Net/WireMock.Net/issues/856) - Inconsistent result with overlapping (duplicate) request [bug]
@@ -218,8 +229,6 @@
# 1.5.6 (12 September 2022)
- [#803](https://github.com/WireMock-Net/WireMock.Net/pull/803) - WebHook : UseFireAndForget + Delay [feature] contributed by [StefH](https://github.com/StefH)
- [#804](https://github.com/WireMock-Net/WireMock.Net/pull/804) - Change nuget to package reference for WireMock.Net.Console.Net472.Cla&#8230; [feature] contributed by [mattisking](https://github.com/mattisking)
- [#806](https://github.com/WireMock-Net/WireMock.Net/pull/806) - Tweak middleware and fix bug in example [feature] contributed by [mattisking](https://github.com/mattisking)
- [#801](https://github.com/WireMock-Net/WireMock.Net/issues/801) - Webhook Delays [feature]
# 1.5.5 (03 September 2022)
@@ -791,7 +800,6 @@
# 1.0.15.0 (04 May 2019)
- [#271](https://github.com/WireMock-Net/WireMock.Net/pull/271) - Support Dynamic response files using Handlebars templating [bug, feature] contributed by [StefH](https://github.com/StefH)
- [#272](https://github.com/WireMock-Net/WireMock.Net/pull/272) - Add unit test for JsonPath and BodyAsFile mapping contributed by [denstorti](https://github.com/denstorti)
- [#273](https://github.com/WireMock-Net/WireMock.Net/pull/273) - Dynamic response handlebars templating (2) [bug, feature] contributed by [StefH](https://github.com/StefH)
# 1.0.14.0 (20 April 2019)
@@ -862,7 +870,6 @@
- [#208](https://github.com/WireMock-Net/WireMock.Net/pull/208) - Refactor contributed by [StefH](https://github.com/StefH)
- [#209](https://github.com/WireMock-Net/WireMock.Net/pull/209) - NET Core 2.1 + support for Service Fabric commandline parameters contributed by [StefH](https://github.com/StefH)
- [#212](https://github.com/WireMock-Net/WireMock.Net/pull/212) - Update BodyParser logic contributed by [StefH](https://github.com/StefH)
- [#216](https://github.com/WireMock-Net/WireMock.Net/pull/216) - ResponseBodyData contributed by [StefH](https://github.com/StefH)
- [#217](https://github.com/WireMock-Net/WireMock.Net/pull/217) - Enable Source Link contributed by [kashifsoofi](https://github.com/kashifsoofi)
- [#218](https://github.com/WireMock-Net/WireMock.Net/pull/218) - remove appveyor contributed by [StefH](https://github.com/StefH)
- [#107](https://github.com/WireMock-Net/WireMock.Net/issues/107) - Feature: increase code coverage [feature]
@@ -980,7 +987,6 @@
# 1.0.3.17 (16 May 2018)
- [#134](https://github.com/WireMock-Net/WireMock.Net/pull/134) - Stef negate matcher contributed by [alastairtree](https://github.com/alastairtree)
- [#135](https://github.com/WireMock-Net/WireMock.Net/pull/135) - Merge into the stef_negate_matcher branch (solves issue #133) contributed by [StefH](https://github.com/StefH)
- [#138](https://github.com/WireMock-Net/WireMock.Net/pull/138) - Added Negate matcher logic contributed by [StefH](https://github.com/StefH)
- [#130](https://github.com/WireMock-Net/WireMock.Net/issues/130) - ...

View File

@@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>1.5.45</VersionPrefix>
<VersionPrefix>1.5.47</VersionPrefix>
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>

View File

@@ -1,7 +1,7 @@
rem https://github.com/StefH/GitHubReleaseNotes
SET version=1.5.45
SET version=1.5.47
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate --version %version% --token %GH_TOKEN%
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate example --version %version% --token %GH_TOKEN%
GitHubReleaseNotes --output PackageReleaseNotes.txt --skip-empty-releases --exclude-labels question invalid doc duplicate --template PackageReleaseNotes.template --version %version% --token %GH_TOKEN%

View File

@@ -1,6 +1,10 @@
# 1.5.45 (21 December 2023)
- #1036 Update Handlebars Transformer logic (ReplaceNodeOptions) [feature]
- #1043 FindRequestByMappingGuidAsync [feature]
- #1039 [Admin API] Find a request that matched a given mapping [feature]
# 1.5.47 (25 January 2024)
- #1049 Add WithoutHeader to WireMock.FluentAssertions [feature]
- #1053 [Snyk] Security upgrade Microsoft.IdentityModel.Protocols.OpenIdConnect from 6.12.2 to 6.34.0 [security]
- #1055 Bump System.IdentityModel.Tokens.Jwt from 6.25.0 to 6.34.0 in /examples/WireMock.Net.Console.Net472.Classic [example]
- #1057 Pin the version from Testcontainers to 3.7.0 in WireMock.Net.Testcontainers [bug]
- #1048 WithoutHeader fluent assertion [feature]
- #1054 WireMock.Net 1.5.46 is incompatible with TestContainers 3.7.0 (issue 1) [bug]
- #1059 WireMock.Net 1.5.46 is incompatible with TestContainers 3.7.0 (issue 2) [bug]
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md

View File

@@ -15,7 +15,8 @@ For more info, see also this WIKI page: [What is WireMock.Net](https://github.co
* Can be used locally or in CI/CD scenarios
## :memo: Blogs
- [mStack.nl : Generate C# Code from Mapping(s)](https://mstack.nl/blog/20230201-wiremock.net-tocode/)
- [mstack.nl : Generate C# Code from Mapping(s)](https://mstack.nl/blog/20230201-wiremock.net-tocode/)
- [mstack.nl : Chaos Engineering with Fault Injections](https://mstack.nl/blogs/wiremock-net-chaos-engineering-with-fault-injections/)
## :computer: Project Info
@@ -90,3 +91,4 @@ For more details see also [Docker](https://github.com/WireMock-Net/WireMock.Net-
#### HTTPS / SSL
More details on using HTTPS (SSL) can be found here [Wiki : HTTPS](https://github.com/WireMock-Net/WireMock.Net/wiki/Using-HTTPS-(SSL))

View File

@@ -232,14 +232,17 @@
<Reference Include="Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Primitives.5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Abstractions, Version=6.25.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.IdentityModel.Abstractions.6.25.0\lib\net472\Microsoft.IdentityModel.Abstractions.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Abstractions, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<HintPath>..\..\packages/Microsoft.IdentityModel.Abstractions.7.2.0/lib/net472/Microsoft.IdentityModel.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=6.25.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.IdentityModel.JsonWebTokens.6.25.0\lib\net472\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<HintPath>..\..\packages/Microsoft.IdentityModel.JsonWebTokens.7.2.0/lib/net472/Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Logging, Version=6.25.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.IdentityModel.Logging.6.25.0\lib\net472\Microsoft.IdentityModel.Logging.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Logging, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<HintPath>..\..\packages/Microsoft.IdentityModel.Logging.7.2.0/lib/net472/Microsoft.IdentityModel.Logging.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Protocols, Version=6.12.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.IdentityModel.Protocols.6.12.2\lib\net472\Microsoft.IdentityModel.Protocols.dll</HintPath>
@@ -247,8 +250,9 @@
<Reference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect, Version=6.12.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.IdentityModel.Protocols.OpenIdConnect.6.12.2\lib\net472\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=6.25.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.IdentityModel.Tokens.6.25.0\lib\net472\Microsoft.IdentityModel.Tokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<HintPath>..\..\packages/Microsoft.IdentityModel.Tokens.7.2.0/lib/net472/Microsoft.IdentityModel.Tokens.dll</HintPath>
<Private>True</Private>
</Reference>
<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>
@@ -296,8 +300,9 @@
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=6.25.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.IdentityModel.Tokens.Jwt.6.25.0\lib\net472\System.IdentityModel.Tokens.Jwt.dll</HintPath>
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=6.34.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<HintPath>..\..\packages/System.IdentityModel.Tokens.Jwt.6.34.0/lib/net472/System.IdentityModel.Tokens.Jwt.dll</HintPath>
<Private>True</Private>
</Reference>
<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>
@@ -305,8 +310,9 @@
<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>
<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>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>..\..\packages/System.Memory.4.5.5/lib/net461/System.Memory.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

View File

@@ -115,12 +115,12 @@
<package id="Microsoft.Extensions.Options" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Options.ConfigurationExtensions" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Primitives" version="5.0.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Abstractions" version="6.25.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="6.25.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Logging" version="6.25.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Abstractions" version="7.2.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="7.2.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Logging" version="7.2.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Protocols" version="6.12.2" targetFramework="net472" />
<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.IdentityModel.Tokens" version="7.2.0" targetFramework="net472" />
<package id="Microsoft.Net.Http.Headers" version="2.2.0" targetFramework="net472" />
<package id="Namotion.Reflection" version="2.0.10" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
@@ -136,10 +136,10 @@
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net472" />
<package id="System.ComponentModel.Annotations" version="4.5.0" targetFramework="net472" />
<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.IdentityModel.Tokens.Jwt" version="6.34.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.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net472" />

View File

@@ -125,20 +125,27 @@ public partial class WireMockAssertions
}
[CustomAssertion]
public AndConstraint<WireMockAssertions> WithHeader(string expectedKey, string value, string because = "", params object[] becauseArgs)
=> WithHeader(expectedKey, new[] { value }, because, becauseArgs);
[CustomAssertion]
public AndConstraint<WireMockAssertions> WithHeader(string expectedKey, string[] expectedValues, string because = "", params object[] becauseArgs)
public AndConstraint<WireMockAssertions> WitHeaderKey(string expectedKey, string because = "", params object[] becauseArgs)
{
using (new AssertionScope("headers from requests sent"))
{
_headers.Select(h => h.Key).Should().Contain(expectedKey, because, becauseArgs);
}
return new AndConstraint<WireMockAssertions>(this);
}
[CustomAssertion]
public AndConstraint<WireMockAssertions> WithHeader(string expectedKey, string value, string because = "", params object[] becauseArgs)
=> WithHeader(expectedKey, new[] { value }, because, becauseArgs);
[CustomAssertion]
public AndConstraint<WireMockAssertions> WithHeader(string expectedKey, string[] expectedValues, string because = "", params object[] becauseArgs)
{
using (new AssertionScope($"header \"{expectedKey}\" from requests sent with value(s)"))
{
var matchingHeaderValues = _headers.Where(h => h.Key == expectedKey).SelectMany(h => h.Value.ToArray()).ToArray();
var matchingHeaderValues = _headers.Where(h => h.Key == expectedKey).SelectMany(h => h.Value.ToArray())
.ToArray();
if (expectedValues.Length == 1)
{
@@ -157,6 +164,45 @@ public partial class WireMockAssertions
return new AndConstraint<WireMockAssertions>(this);
}
[CustomAssertion]
public AndConstraint<WireMockAssertions> WithoutHeaderKey(string unexpectedKey, string because = "", params object[] becauseArgs)
{
using (new AssertionScope("headers from requests sent"))
{
_headers.Select(h => h.Key).Should().NotContain(unexpectedKey, because, becauseArgs);
}
return new AndConstraint<WireMockAssertions>(this);
}
[CustomAssertion]
public AndConstraint<WireMockAssertions> WithoutHeader(string unexpectedKey, string value, string because = "", params object[] becauseArgs)
=> WithoutHeader(unexpectedKey, new[] { value }, because, becauseArgs);
[CustomAssertion]
public AndConstraint<WireMockAssertions> WithoutHeader(string unexpectedKey, string[] expectedValues, string because = "", params object[] becauseArgs)
{
using (new AssertionScope($"header \"{unexpectedKey}\" from requests sent with value(s)"))
{
var matchingHeaderValues = _headers.Where(h => h.Key == unexpectedKey).SelectMany(h => h.Value.ToArray()).ToArray();
if (expectedValues.Length == 1)
{
matchingHeaderValues.Should().NotContain(expectedValues.First(), because, becauseArgs);
}
else
{
var trimmedHeaderValues = string.Join(",", matchingHeaderValues.Select(x => x)).Split(',').Select(x => x.Trim()).ToList();
foreach (var expectedValue in expectedValues)
{
trimmedHeaderValues.Should().NotContain(expectedValue, because, becauseArgs);
}
}
}
return new AndConstraint<WireMockAssertions>(this);
}
private (Func<IReadOnlyList<IRequestMessage>, IReadOnlyList<IRequestMessage>> Filter, Func<IReadOnlyList<IRequestMessage>, bool> Condition) BuildFilterAndCondition(Func<IRequestMessage, bool> predicate)
{
Func<IReadOnlyList<IRequestMessage>, IReadOnlyList<IRequestMessage>> filter = requests => requests.Where(predicate).ToList();

View File

@@ -201,12 +201,12 @@ public interface IWireMockAdminApi
Task<IList<LogEntryModel>> FindRequestsAsync([Body] RequestModel model, CancellationToken cancellationToken = default);
/// <summary>
/// Find a request based on the Mapping Guid.
/// Find requests based on the Mapping Guid.
/// </summary>
/// <param name="mappingGuid">The Mapping Guid</param>
/// <param name="cancellationToken">The optional cancellationToken.</param>
[Get("requests/find")]
Task<LogEntryModel?> FindRequestByMappingGuidAsync([Query] Guid mappingGuid, CancellationToken cancellationToken = default);
Task<IList<LogEntryModel>> FindRequestsByMappingGuidAsync([Query] Guid mappingGuid, CancellationToken cancellationToken = default);
/// <summary>
/// Get all scenarios
@@ -304,4 +304,4 @@ public interface IWireMockAdminApi
/// <param name="cancellationToken">The optional cancellationToken.</param>
[Post("openapi/save")]
Task<StatusModel> OpenApiSaveAsync([Body] string text, CancellationToken cancellationToken = default);
}
}

View File

@@ -29,15 +29,12 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Stef.Validation" Version="0.1.1" />
<PackageReference Include="Testcontainers" Version="3.6.0" />
<PackageReference Include="Testcontainers" Version="[3.7.0]" />
<PackageReference Include="JetBrains.Annotations" VersionOverride="2022.3.1" PrivateAssets="All" Version="2023.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WireMock.Net.RestClient\WireMock.Net.RestClient.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Http\" />
</ItemGroup>
</Project>

View File

@@ -16,10 +16,7 @@ public sealed class WireMockConfiguration : ContainerConfiguration
public bool HasBasicAuthentication => !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password);
public WireMockConfiguration(
string? username = null,
string? password = null
)
public WireMockConfiguration(string? username = null, string? password = null)
{
Username = username;
Password = password;

View File

@@ -21,10 +21,15 @@ public sealed class WireMockContainerBuilder : ContainerBuilder<WireMockContaine
{ true, new ContainerInfo("sheyenrath/wiremock.net-windows:latest", @"c:\app\__admin\mappings") }
};
private const string DefaultLogger = "WireMockConsoleLogger";
private const string DefaultLogger = "WireMockNoNewLinesConsoleLogger";
private readonly Lazy<Task<bool>> _isWindowsAsLazy = new(async () =>
{
if (TestcontainersSettings.OS.DockerEndpointAuthConfig == null)
{
throw new InvalidOperationException($"The {nameof(TestcontainersSettings.OS.DockerEndpointAuthConfig)} is null. Check if Docker is started.");
}
using var dockerClientConfig = TestcontainersSettings.OS.DockerEndpointAuthConfig.GetDockerClientConfiguration();
using var dockerClient = dockerClientConfig.CreateClient();
@@ -152,7 +157,7 @@ public sealed class WireMockContainerBuilder : ContainerBuilder<WireMockContaine
return builder
.WithPortBinding(WireMockContainer.ContainerPort, true)
.WithCommand($"--WireMockLogger {DefaultLogger}")
.WithWaitStrategy(waitForContainerOS.UntilMessageIsLogged("By Stef Heyenrath"));
.WithWaitStrategy(waitForContainerOS.UntilMessageIsLogged("WireMock.Net server running"));
}
/// <inheritdoc />

View File

@@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System;
using Newtonsoft.Json;
using WireMock.Admin.Requests;
namespace WireMock.Logging;
@@ -10,58 +10,65 @@ namespace WireMock.Logging;
/// <seealso cref="IWireMockLogger" />
public class WireMockConsoleLogger : IWireMockLogger
{
private const string NewlineWindows = "\r\n";
private const string NewlineUnix = "\n";
private readonly bool _removeNewLines;
/// <summary>
/// Initializes a new instance of the <see cref="WireMockConsoleLogger"/> class.
/// </summary>
public WireMockConsoleLogger()
public WireMockConsoleLogger(bool removeNewLines = false)
{
_removeNewLines = removeNewLines;
Console.OutputEncoding = System.Text.Encoding.UTF8;
}
/// <see cref="IWireMockLogger.Debug"/>
/// <inheritdoc />
public void Debug(string formatString, params object[] args)
{
Console.WriteLine(Format("Debug", formatString, args));
WriteLine(Format("Debug", formatString, args));
}
/// <see cref="IWireMockLogger.Info"/>
/// <inheritdoc />
public void Info(string formatString, params object[] args)
{
Console.WriteLine(Format("Info", formatString, args));
WriteLine(Format("Info", formatString, args));
}
/// <see cref="IWireMockLogger.Warn"/>
/// <inheritdoc />
public void Warn(string formatString, params object[] args)
{
Console.WriteLine(Format("Warn", formatString, args));
WriteLine(Format("Warn", formatString, args));
}
/// <see cref="IWireMockLogger.Error(string, object[])"/>
/// <inheritdoc />
public void Error(string formatString, params object[] args)
{
Console.WriteLine(Format("Error", formatString, args));
WriteLine(Format("Error", formatString, args));
}
/// <see cref="IWireMockLogger.Error(string, Exception)"/>
/// <inheritdoc />
public void Error(string formatString, Exception exception)
{
Console.WriteLine(Format("Error", formatString, exception.Message));
WriteLine(Format("Error", formatString, exception.Message));
if (exception is AggregateException ae)
{
ae.Handle(ex =>
{
Console.WriteLine(Format("Error", "Exception {0}", ex.Message));
WriteLine(Format("Error", "Exception {0}", ex.Message));
return true;
});
}
}
/// <see cref="IWireMockLogger.DebugRequestResponse"/>
/// <inheritdoc />
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
{
string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented);
Console.WriteLine(Format("DebugRequestResponse", "Admin[{0}] {1}", isAdminRequest, message));
WriteLine(Format("DebugRequestResponse", "Admin[{0}] {1}", isAdminRequest, message));
}
private static string Format(string level, string formatString, params object[] args)
@@ -70,4 +77,13 @@ public class WireMockConsoleLogger : IWireMockLogger
return $"{DateTime.UtcNow} [{level}] : {message}";
}
/// <summary>
/// Writes the specified string value, followed by the current line terminator, to the console.
/// </summary>
/// <param name="value">The value to write.</param>
private void WriteLine(string value)
{
Console.WriteLine(!_removeNewLines ? value : value.Replace(NewlineWindows, string.Empty).Replace(NewlineUnix, string.Empty));
}
}

View File

@@ -99,7 +99,7 @@ public partial class WireMockServer
// __admin/requests/find
Given(Request.Create().WithPath(AdminRequests + "/find").UsingPost()).AtPriority(WireMockConstants.AdminPriority).RespondWith(new DynamicResponseProvider(RequestsFind));
Given(Request.Create().WithPath(AdminRequests + "/find").UsingGet().WithParam("mappingGuid", new NotNullOrEmptyMatcher())).AtPriority(WireMockConstants.AdminPriority).RespondWith(new DynamicResponseProvider(RequestFindByMappingGuid));
Given(Request.Create().WithPath(AdminRequests + "/find").UsingGet().WithParam("mappingGuid", new NotNullOrEmptyMatcher())).AtPriority(WireMockConstants.AdminPriority).RespondWith(new DynamicResponseProvider(RequestsFindByMappingGuid));
// __admin/scenarios
Given(Request.Create().WithPath(AdminScenarios).UsingGet()).AtPriority(WireMockConstants.AdminPriority).RespondWith(new DynamicResponseProvider(ScenariosGet));
@@ -602,21 +602,17 @@ public partial class WireMockServer
return ToJson(result);
}
private IResponseMessage RequestFindByMappingGuid(IRequestMessage requestMessage)
private IResponseMessage RequestsFindByMappingGuid(IRequestMessage requestMessage)
{
if (requestMessage.Query != null &&
requestMessage.Query.TryGetValue("mappingGuid", out var value) &&
Guid.TryParse(value.ToString(), out var mappingGuid)
)
{
var logEntry = LogEntries.SingleOrDefault(le => !le.RequestMessage.Path.StartsWith("/__admin/") && le.MappingGuid == mappingGuid);
if (logEntry != null)
{
var logEntryMapper = new LogEntryMapper(_options);
return ToJson(logEntryMapper.Map(logEntry));
}
return ResponseMessageBuilder.Create(HttpStatusCode.OK);
var logEntries = LogEntries.Where(le => !le.RequestMessage.Path.StartsWith("/__admin/") && le.MappingGuid == mappingGuid);
var logEntryMapper = new LogEntryMapper(_options);
var result = logEntries.Select(logEntryMapper.Map);
return ToJson(result);
}
return ResponseMessageBuilder.Create(HttpStatusCode.BadRequest);
@@ -833,4 +829,4 @@ public partial class WireMockServer
var singleResult = ((JObject)value).ToObject<T>();
return new[] { singleResult! };
}
}
}

View File

@@ -109,5 +109,5 @@ public class ProxyAndRecordSettings : HttpClientSettings
/// Proxy all Api calls, irrespective of any condition
/// </summary>
[PublicAPI]
public bool ProxyAll { get; set; } = false;
}
public bool ProxyAll { get; set; }
}

View File

@@ -41,25 +41,25 @@ public static class WireMockServerSettingsParser
{
AdminAzureADAudience = parser.GetStringValue(nameof(WireMockServerSettings.AdminAzureADAudience)),
AdminAzureADTenant = parser.GetStringValue(nameof(WireMockServerSettings.AdminAzureADTenant)),
AdminPassword = parser.GetStringValue("AdminPassword"),
AdminUsername = parser.GetStringValue("AdminUsername"),
AllowBodyForAllHttpMethods = parser.GetBoolValue("AllowBodyForAllHttpMethods"),
AllowCSharpCodeMatcher = parser.GetBoolValue("AllowCSharpCodeMatcher"),
AllowOnlyDefinedHttpStatusCodeInResponse = parser.GetBoolValue("AllowOnlyDefinedHttpStatusCodeInResponse"),
AllowPartialMapping = parser.GetBoolValue("AllowPartialMapping"),
DisableJsonBodyParsing = parser.GetBoolValue("DisableJsonBodyParsing"),
AdminPassword = parser.GetStringValue(nameof(WireMockServerSettings.AdminPassword)),
AdminUsername = parser.GetStringValue(nameof(WireMockServerSettings.AdminUsername)),
AllowBodyForAllHttpMethods = parser.GetBoolValue(nameof(WireMockServerSettings.AllowBodyForAllHttpMethods)),
AllowCSharpCodeMatcher = parser.GetBoolValue(nameof(WireMockServerSettings.AllowCSharpCodeMatcher)),
AllowOnlyDefinedHttpStatusCodeInResponse = parser.GetBoolValue(nameof(WireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse)),
AllowPartialMapping = parser.GetBoolValue(nameof(WireMockServerSettings.AllowPartialMapping)),
DisableJsonBodyParsing = parser.GetBoolValue(nameof(WireMockServerSettings.DisableJsonBodyParsing)),
DisableRequestBodyDecompressing = parser.GetBoolValue(nameof(WireMockServerSettings.DisableRequestBodyDecompressing)),
DisableDeserializeFormUrlEncoded = parser.GetBoolValue(nameof(WireMockServerSettings.DisableDeserializeFormUrlEncoded)),
HandleRequestsSynchronously = parser.GetBoolValue("HandleRequestsSynchronously"),
MaxRequestLogCount = parser.GetIntValue("MaxRequestLogCount"),
ReadStaticMappings = parser.GetBoolValue("ReadStaticMappings"),
RequestLogExpirationDuration = parser.GetIntValue("RequestLogExpirationDuration"),
HandleRequestsSynchronously = parser.GetBoolValue(nameof(WireMockServerSettings.HandleRequestsSynchronously)),
MaxRequestLogCount = parser.GetIntValue(nameof(WireMockServerSettings.MaxRequestLogCount)),
ReadStaticMappings = parser.GetBoolValue(nameof(WireMockServerSettings.ReadStaticMappings)),
RequestLogExpirationDuration = parser.GetIntValue(nameof(WireMockServerSettings.RequestLogExpirationDuration)),
SaveUnmatchedRequests = parser.GetBoolValue(nameof(WireMockServerSettings.SaveUnmatchedRequests)),
StartAdminInterface = parser.GetBoolValue("StartAdminInterface", true),
StartAdminInterface = parser.GetBoolValue(nameof(WireMockServerSettings.StartAdminInterface), true),
StartTimeout = parser.GetIntValue(nameof(WireMockServerSettings.StartTimeout), WireMockServerSettings.DefaultStartTimeout),
UseRegexExtended = parser.GetBoolValue(nameof(WireMockServerSettings.UseRegexExtended), true),
WatchStaticMappings = parser.GetBoolValue("WatchStaticMappings"),
WatchStaticMappingsInSubdirectories = parser.GetBoolValue("WatchStaticMappingsInSubdirectories"),
WatchStaticMappings = parser.GetBoolValue(nameof(WireMockServerSettings.WatchStaticMappings)),
WatchStaticMappingsInSubdirectories = parser.GetBoolValue(nameof(WireMockServerSettings.WatchStaticMappingsInSubdirectories)),
HostingScheme = parser.GetEnumValue<HostingScheme>(nameof(WireMockServerSettings.HostingScheme)),
DoNotSaveDynamicResponseInLogEntry = parser.GetBoolValue(nameof(WireMockServerSettings.DoNotSaveDynamicResponseInLogEntry)),
QueryParameterMultipleValueSupport = parser.GetEnumValue<QueryParameterMultipleValueSupport>(nameof(WireMockServerSettings.QueryParameterMultipleValueSupport)),
@@ -83,10 +83,16 @@ public static class WireMockServerSettingsParser
private static void ParseLoggerSettings(WireMockServerSettings settings, IWireMockLogger? logger, SimpleSettingsParser parser)
{
var loggerType = parser.GetStringValue("WireMockLogger");
var removeNewLines = parser.GetBoolValue("RemoveNewLines");
switch (loggerType)
{
case nameof(WireMockConsoleLogger):
settings.Logger = new WireMockConsoleLogger();
settings.Logger = new WireMockConsoleLogger(removeNewLines);
break;
case "WireMockNoNewLinesConsoleLogger":
settings.Logger = new WireMockConsoleLogger(true);
break;
case nameof(WireMockNullLogger):
@@ -110,21 +116,21 @@ public static class WireMockServerSettingsParser
{
var proxyAndRecordSettings = new ProxyAndRecordSettings
{
AllowAutoRedirect = parser.GetBoolValue("AllowAutoRedirect"),
ClientX509Certificate2ThumbprintOrSubjectName = parser.GetStringValue("ClientX509Certificate2ThumbprintOrSubjectName"),
ExcludedCookies = parser.GetValues("ExcludedCookies"),
ExcludedHeaders = parser.GetValues("ExcludedHeaders"),
AllowAutoRedirect = parser.GetBoolValue(nameof(ProxyAndRecordSettings.AllowAutoRedirect)),
ClientX509Certificate2ThumbprintOrSubjectName = parser.GetStringValue(nameof(ProxyAndRecordSettings.ClientX509Certificate2ThumbprintOrSubjectName)),
ExcludedCookies = parser.GetValues(nameof(ProxyAndRecordSettings.ExcludedCookies)),
ExcludedHeaders = parser.GetValues(nameof(ProxyAndRecordSettings.ExcludedHeaders)),
// PreferProxyMapping = parser.GetBoolValue(nameof(ProxyAndRecordSettings.PreferProxyMapping)),
SaveMapping = parser.GetBoolValue("SaveMapping"),
SaveMappingForStatusCodePattern = parser.GetStringValue("SaveMappingForStatusCodePattern", "*"),
SaveMappingToFile = parser.GetBoolValue("SaveMappingToFile"),
SaveMapping = parser.GetBoolValue(nameof(ProxyAndRecordSettings.SaveMapping)),
SaveMappingForStatusCodePattern = parser.GetStringValue(nameof(ProxyAndRecordSettings.SaveMappingForStatusCodePattern), "*"),
SaveMappingToFile = parser.GetBoolValue(nameof(ProxyAndRecordSettings.SaveMappingToFile)),
UseDefinedRequestMatchers = parser.GetBoolValue(nameof(ProxyAndRecordSettings.UseDefinedRequestMatchers)),
AppendGuidToSavedMappingFile = parser.GetBoolValue(nameof(ProxyAndRecordSettings.AppendGuidToSavedMappingFile)),
PrefixForSavedMappingFile = parser.GetStringValue(nameof(ProxyAndRecordSettings.PrefixForSavedMappingFile), null),
PrefixForSavedMappingFile = parser.GetStringValue(nameof(ProxyAndRecordSettings.PrefixForSavedMappingFile), ProxyAndRecordSettings.DefaultPrefixForSavedMappingFile),
Url = proxyUrl!,
SaveMappingSettings = new ProxySaveMappingSettings
{
StatusCodePattern = parser.GetStringValue("SaveMappingForStatusCodePattern", "*"),
StatusCodePattern = parser.GetStringValue(nameof(ProxyAndRecordSettings.SaveMappingForStatusCodePattern), "*"),
// HttpMethods = new ProxySaveMappingSetting<string[]>(parser.GetValues("DoNotSaveMappingForHttpMethods", new string[0]), MatchBehaviour.RejectOnMatch)
},
ProxyAll = parser.GetBoolValue(nameof(ProxyAndRecordSettings.ProxyAll))
@@ -188,7 +194,7 @@ public static class WireMockServerSettingsParser
settings.ReplaceSettings = new ProxyUrlReplaceSettings
{
OldValue = proxyUrlReplaceOldValue!,
NewValue = proxyUrlReplaceNewValue!
NewValue = proxyUrlReplaceNewValue
};
}
}

View File

@@ -74,7 +74,7 @@
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard1.3' ">
<PackageReference Include="XPath2.Extensions" Version="1.1.4" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.12.2" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.34.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'net452' ">

View File

@@ -130,6 +130,17 @@ public class WireMockAssertionsTests : IDisposable
_httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer a");
await _httpClient.GetAsync("").ConfigureAwait(false);
_server.Should()
.HaveReceivedACall()
.WitHeaderKey("Authorization");
}
[Fact]
public async Task HaveReceivedACall_WithHeader_WhenACallWasMadeWithExpectedHeaderWithValue_Should_BeOK()
{
_httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer a");
await _httpClient.GetAsync("").ConfigureAwait(false);
_server.Should()
.HaveReceivedACall()
.WithHeader("Authorization", "Bearer a");
@@ -163,7 +174,7 @@ public class WireMockAssertionsTests : IDisposable
act.Should().Throw<Exception>()
.And.Message.Should()
.Contain("to contain \"Authorization\".");
.Contain("\"Authorization\"");
}
[Fact]
@@ -240,8 +251,13 @@ public class WireMockAssertionsTests : IDisposable
});
// Assert
server.Should().HaveReceivedACall().WithHeader("Authorization", "Bearer invalidToken");
server.Should().HaveReceivedACall().WithHeader("Authorization", "Bearer validToken");
server.Should()
.HaveReceivedACall()
.WithHeader("Authorization", "Bearer invalidToken").And.WithoutHeader("x", "y").And.WithoutHeaderKey("a");
server.Should().
HaveReceivedACall()
.WithHeader("Authorization", "Bearer validToken").And.WithoutHeader("Authorization", "y");
}
[Fact]

View File

@@ -0,0 +1,43 @@
#if NET6_0_OR_GREATER
using System.Threading.Tasks;
using FluentAssertions;
using FluentAssertions.Execution;
using WireMock.Net.Testcontainers;
using Xunit;
namespace WireMock.Net.Tests.Testcontainers;
public class TestcontainersTests
{
[Fact]
public async Task WireMockContainer_Build_and_StartAsync_and_StopAsync()
{
// Act
var wireMockContainer = new WireMockContainerBuilder()
.WithAutoRemove(true)
.WithCleanUp(true)
.Build();
try
{
await wireMockContainer.StartAsync().ConfigureAwait(false);
// Assert
using (new AssertionScope())
{
var url = wireMockContainer.GetPublicUrl();
url.Should().NotBeNullOrWhiteSpace();
var adminClient = wireMockContainer.CreateWireMockAdminClient();
var settings = await adminClient.GetSettingsAsync();
settings.Should().NotBeNull();
}
}
finally
{
await wireMockContainer.StopAsync();
}
}
}
#endif

View File

@@ -105,6 +105,10 @@
<PackageReference Include="JsonConverter.System.Text.Json" Version="0.4.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net8.0'">
<ProjectReference Include="..\..\src\WireMock.Net.Testcontainers\WireMock.Net.Testcontainers.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="OpenApiParser\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View File

@@ -1,5 +1,6 @@
#if !(NET452 || NET461 || NETCOREAPP3_1)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
@@ -25,6 +26,7 @@ using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;
using WireMock.Settings;
using WireMock.Types;
using Xunit;
namespace WireMock.Net.Tests;
@@ -254,7 +256,7 @@ public class WireMockAdminApiTests
}
[Fact]
public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_Found()
public async Task IWireMockAdminApi_FindRequestsByMappingGuidAsync_Found()
{
// Arrange
var mappingGuid = Guid.NewGuid();
@@ -269,21 +271,33 @@ public class WireMockAdminApiTests
.RespondWith(Response.Create());
var serverUrl = "http://localhost:" + server.Ports[0];
await new HttpClient().GetAsync(serverUrl + "/foo").ConfigureAwait(false);
using var client = new HttpClient();
await client.GetAsync(serverUrl + "/foo").ConfigureAwait(false);
await client.GetAsync(serverUrl + "/foo?bar=baz").ConfigureAwait(false);
var api = RestClient.For<IWireMockAdminApi>(serverUrl);
// Act
var logEntryModel = await api.FindRequestByMappingGuidAsync(mappingGuid).ConfigureAwait(false);
var logEntryModels = await api.FindRequestsByMappingGuidAsync(mappingGuid).ConfigureAwait(false);
// Assert
logEntryModel.Should().NotBeNull();
logEntryModel!.Request.Method.Should().Be("GET");
logEntryModel!.Request.Body.Should().BeNull();
logEntryModel!.Request.Path.Should().Be("/foo");
logEntryModels.Should().HaveCount(2);
logEntryModels[0].Should().NotBeNull();
logEntryModels[0]!.Request.Method.Should().Be("GET");
logEntryModels[0]!.Request.Body.Should().BeNull();
logEntryModels[0]!.Request.Path.Should().Be("/foo");
logEntryModels[0]!.Request.Query.Should().BeNullOrEmpty();
logEntryModels[1].Should().NotBeNull();
logEntryModels[1]!.Request.Method.Should().Be("GET");
logEntryModels[1]!.Request.Body.Should().BeNull();
logEntryModels[1]!.Request.Path.Should().Be("/foo");
logEntryModels[1]!.Request.Query.Should().BeEquivalentTo(new Dictionary<string, WireMockList<string>>
{
{"bar", new WireMockList<string>("baz")}
});
}
[Fact]
public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_NotFound()
public async Task IWireMockAdminApi_FindRequestsByMappingGuidAsync_NotFound()
{
// Arrange
var server = WireMockServer.Start(new WireMockServerSettings
@@ -301,14 +315,14 @@ public class WireMockAdminApiTests
var api = RestClient.For<IWireMockAdminApi>(serverUrl);
// Act
var logEntryModel = await api.FindRequestByMappingGuidAsync(Guid.NewGuid()).ConfigureAwait(false);
var logEntryModels = await api.FindRequestsByMappingGuidAsync(Guid.NewGuid()).ConfigureAwait(false);
// Assert
logEntryModel.Should().BeNull();
logEntryModels.Should().BeEmpty();
}
[Fact]
public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_Invalid_ShouldReturnBadRequest()
public async Task IWireMockAdminApi_FindRequestsByMappingGuidAsync_Invalid_ShouldReturnBadRequest()
{
// Arrange
var server = WireMockServer.Start(new WireMockServerSettings
@@ -1001,4 +1015,4 @@ text
server.Stop();
}
}
#endif
#endif