Compare commits

...

5 Commits

Author SHA1 Message Date
Stef Heyenrath
abf3969bee 1.5.45 2023-12-21 22:18:26 +01:00
Stef Heyenrath
a8339a0867 FindRequestByMappingGuidAsync (#1043)
* FindRequestByMappingGuidAsync

* fix

* sc
2023-12-21 20:03:22 +01:00
Stef Heyenrath
4721b73a16 Update Handlebars Transformer logic (ReplaceNodeOptions) (#1036)
* Update Handlebars Transformer logic (ReplaceNodeOptions)

* okeee

* EvaluateAndKeep = Evaluate

* fix?

* linux

* _

* tt

* xxx

* fx

* x

* fix test
2023-12-21 20:02:58 +01:00
Stef Heyenrath
c96d7d31b1 1.5.44 2023-12-14 21:08:05 +01:00
Mindaugas Laganeckas
7b8e7bb684 Implement prefix for saved mapping file (#1040)
* Implement PrefixForSavedMappingFile

* Add missing new line

* Add missing new line

* Fix warning

* Fix typo

* Change from readonly to const

* Assign default value

* Use nameof()

* Change from readonly to const

* Update tests

* Update failing test

* Rename settingsMock to settings

* Create public const

* Use const from ProxyAndRecordSettings

---------

Co-authored-by: Mindaugas Laganeckas <mindaugas.laganeckas@nexigroup.com>
2023-12-14 08:28:21 +01:00
69 changed files with 788 additions and 1439 deletions

View File

@@ -1,3 +1,13 @@
# 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)
- [#1039](https://github.com/WireMock-Net/WireMock.Net/issues/1039) - [Admin API] Find a request that matched a given mapping [feature]
# 1.5.44 (14 December 2023)
- [#1040](https://github.com/WireMock-Net/WireMock.Net/pull/1040) - Implement prefix for saved mapping file [feature] contributed by [MindaugasLaganeckas](https://github.com/MindaugasLaganeckas)
- [#1033](https://github.com/WireMock-Net/WireMock.Net/issues/1033) - How to get a Random Long? [bug]
- [#1037](https://github.com/WireMock-Net/WireMock.Net/issues/1037) - Make mapping filenames more user friendly [feature]
# 1.5.43 (11 December 2023)
- [#1026](https://github.com/WireMock-Net/WireMock.Net/pull/1026) - Add ProxyUrlReplaceSettings to Response [feature] contributed by [StefH](https://github.com/StefH)
- [#1038](https://github.com/WireMock-Net/WireMock.Net/pull/1038) - Proxy all requests - even a repeated one [feature] contributed by [sameena-ops](https://github.com/sameena-ops)

View File

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

View File

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

View File

@@ -1,7 +1,6 @@
# 1.5.43 (11 December 2023)
- #1026 Add ProxyUrlReplaceSettings to Response [feature]
- #1038 Proxy all requests - even a repeated one [feature]
- #592 Proxy all requests - even a repeated one [feature]
- #1024 Scenario with proxy not removing route prefix [feature]
# 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]
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md

View File

@@ -36,8 +36,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp3", "examples\WireMock.Net.Console.NETCoreApp3\WireMock.Net.Console.NETCoreApp3.csproj", "{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.Proxy.NETCoreApp2", "examples\WireMock.Net.Console.Proxy.NETCoreApp2\WireMock.Net.Console.Proxy.NETCoreApp2.csproj", "{41C19451-E980-4ED4-A011-DA7A1C23FC05}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Client", "examples\WireMock.Net.Client\WireMock.Net.Client.csproj", "{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp", "examples\WireMock.Net.Console.NETCoreApp\WireMock.Net.Console.NETCoreApp.csproj", "{FE281639-B014-4C8A-96FA-141164A74713}"
@@ -50,8 +48,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Net461
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Net452.Classic", "examples\WireMock.Net.Console.Net452.Classic\WireMock.Net.Console.Net452.Classic.csproj", "{668F689E-57B4-422E-8846-C0FF643CA268}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp2", "examples\WireMock.Net.Console.NETCoreApp2\WireMock.Net.Console.NETCoreApp2.csproj", "{83645809-9E01-4E81-8733-BA9497554ABF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.RequestLogTest", "examples\WireMock.Net.Console.RequestLogTest\WireMock.Net.Console.RequestLogTest.csproj", "{A9D039B9-7509-4CF1-9EFD-87EB82998575}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.OpenApiParser", "src\WireMock.Net.OpenApiParser\WireMock.Net.OpenApiParser.csproj", "{D3804228-91F4-4502-9595-39584E5AADAD}"
@@ -60,8 +56,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.OpenApiParser.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.FluentAssertions", "src\WireMock.Net.FluentAssertions\WireMock.Net.FluentAssertions.csproj", "{B6269AAC-170A-4346-8B9A-579DED3D9A95}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore2", "examples\WireMock.Net.WebApplication.NETCore2\WireMock.Net.WebApplication.NETCore2.csproj", "{6F38CB3A-6DA1-408A-AECD-E434523C2838}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore3", "examples\WireMock.Net.WebApplication.NETCore3\WireMock.Net.WebApplication.NETCore3.csproj", "{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp3WithCertificate", "examples\WireMock.Net.Console.NETCoreApp3WithCertificate\WireMock.Net.Console.NETCoreApp3WithCertificate.csproj", "{925E421A-1B3F-4202-B48F-734743573A4B}"
@@ -104,8 +98,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NET6.W
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMockAzureQueueExample", "examples\WireMockAzureQueueExample\WireMockAzureQueueExample.csproj", "{BAA9EC2A-874B-45CE-8E51-A73622DC7F3D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMockAzureQueueProxy", "examples\WireMockAzureQueueProxy\WireMockAzureQueueProxy.csproj", "{ADB557D8-D66B-4387-912B-3F73E290B478}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Testcontainers", "src\WireMock.Net.Testcontainers\WireMock.Net.Testcontainers.csproj", "{12B016A5-9D8B-4EFE-96C2-CA51BE43367D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.TestcontainersExample", "examples\WireMock.Net.TestcontainersExample\WireMock.Net.TestcontainersExample.csproj", "{56A38798-C48B-4A4A-B805-071E05C02CE1}"
@@ -118,6 +110,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.NET7.U
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NET8", "examples\WireMock.Net.Console.NET8\WireMock.Net.Console.NET8.csproj", "{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMockAzureQueueProxy", "examples\WireMockAzureQueueProxy\WireMockAzureQueueProxy.csproj", "{7FC0B409-2682-40EE-B3B9-3930D6769D01}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -148,10 +142,6 @@ Global
{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}.Release|Any CPU.Build.0 = Release|Any CPU
{41C19451-E980-4ED4-A011-DA7A1C23FC05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41C19451-E980-4ED4-A011-DA7A1C23FC05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41C19451-E980-4ED4-A011-DA7A1C23FC05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41C19451-E980-4ED4-A011-DA7A1C23FC05}.Release|Any CPU.Build.0 = Release|Any CPU
{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -176,10 +166,6 @@ Global
{668F689E-57B4-422E-8846-C0FF643CA268}.Debug|Any CPU.Build.0 = Debug|Any CPU
{668F689E-57B4-422E-8846-C0FF643CA268}.Release|Any CPU.ActiveCfg = Release|Any CPU
{668F689E-57B4-422E-8846-C0FF643CA268}.Release|Any CPU.Build.0 = Release|Any CPU
{83645809-9E01-4E81-8733-BA9497554ABF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83645809-9E01-4E81-8733-BA9497554ABF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83645809-9E01-4E81-8733-BA9497554ABF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{83645809-9E01-4E81-8733-BA9497554ABF}.Release|Any CPU.Build.0 = Release|Any CPU
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -196,10 +182,6 @@ Global
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.Build.0 = Release|Any CPU
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Release|Any CPU.Build.0 = Release|Any CPU
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -256,10 +238,6 @@ Global
{BAA9EC2A-874B-45CE-8E51-A73622DC7F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAA9EC2A-874B-45CE-8E51-A73622DC7F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAA9EC2A-874B-45CE-8E51-A73622DC7F3D}.Release|Any CPU.Build.0 = Release|Any CPU
{ADB557D8-D66B-4387-912B-3F73E290B478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADB557D8-D66B-4387-912B-3F73E290B478}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADB557D8-D66B-4387-912B-3F73E290B478}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADB557D8-D66B-4387-912B-3F73E290B478}.Release|Any CPU.Build.0 = Release|Any CPU
{12B016A5-9D8B-4EFE-96C2-CA51BE43367D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12B016A5-9D8B-4EFE-96C2-CA51BE43367D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12B016A5-9D8B-4EFE-96C2-CA51BE43367D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -280,6 +258,10 @@ Global
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Release|Any CPU.Build.0 = Release|Any CPU
{7FC0B409-2682-40EE-B3B9-3930D6769D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FC0B409-2682-40EE-B3B9-3930D6769D01}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FC0B409-2682-40EE-B3B9-3930D6769D01}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FC0B409-2682-40EE-B3B9-3930D6769D01}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -291,19 +273,16 @@ Global
{B6269AAC-170A-43D5-8B9A-579DED3D9A95} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E} = {0BB8B634-407A-4610-A91F-11586990767A}
{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{41C19451-E980-4ED4-A011-DA7A1C23FC05} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{FE281639-B014-4C8A-96FA-141164A74713} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{26433A8F-BF01-4962-97EB-81BFFBB61096} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{7F0B2446-0363-4720-AF46-F47F83B557DC} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{1261BB9B-A7D4-456C-8985-3CE560361B8E} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{668F689E-57B4-422E-8846-C0FF643CA268} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{83645809-9E01-4E81-8733-BA9497554ABF} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{A9D039B9-7509-4CF1-9EFD-87EB82998575} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{D3804228-91F4-4502-9595-39584E5AADAD} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
{5C09FB93-1535-4F92-AF26-21E8A061EE4A} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{B6269AAC-170A-4346-8B9A-579DED3D9A95} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
{6F38CB3A-6DA1-408A-AECD-E434523C2838} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{925E421A-1B3F-4202-B48F-734743573A4B} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{40BF24B5-12E6-4610-9489-138798632E28} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
@@ -320,12 +299,12 @@ Global
{0DE0954F-8C00-4E8D-B94A-4361FC1CBE44} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
{7C2A9DE8-C89F-4841-9058-6B9BF81E5E34} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{BAA9EC2A-874B-45CE-8E51-A73622DC7F3D} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{ADB557D8-D66B-4387-912B-3F73E290B478} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{12B016A5-9D8B-4EFE-96C2-CA51BE43367D} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
{56A38798-C48B-4A4A-B805-071E05C02CE1} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{07C30227-ADEC-4BDE-8CDC-849D85A690BB} = {0147029F-FA4A-44B3-B79A-3C3574054EE4}
{941229D6-191B-4B5E-AC81-0905EBF4F19D} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{7FC0B409-2682-40EE-B3B9-3930D6769D01} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458}

View File

@@ -28,7 +28,6 @@
<ItemGroup>
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
<PackageReference Include="Handlebars.Net.Helpers" Version="2.4.0" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

View File

@@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="WireMock.Net" Version="1.5.32" />
<PackageReference Include="WireMock.Net" Version="1.5.42" />
</ItemGroup>
</Project>

View File

@@ -19,12 +19,12 @@
<ItemGroup>
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
<PackageReference Include="Handlebars.Net.Helpers" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.4.0" />
<!--<PackageReference Include="Handlebars.Net.Helpers" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.4.1.0" />
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.4.*" />-->
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

View File

@@ -1,28 +0,0 @@
using System.IO;
using System.Linq;
using System.Reflection;
using log4net;
using log4net.Config;
using log4net.Repository;
using WireMock.Net.ConsoleApplication;
namespace WireMock.Net.Console.NETCoreApp2
{
static class Program
{
private static readonly ILoggerRepository LogRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
private static readonly ILog Log = LogManager.GetLogger(typeof(Program));
static void Main(params string[] args)
{
XmlConfigurator.Configure(LogRepository, new FileInfo("log4net.config"));
foreach (var file in Directory.GetFiles("__admin").Where(f => !f.StartsWith("wiremock")))
{
File.Delete(file);
}
MainApp.Run();
}
}
}

View File

@@ -1,65 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<ApplicationIcon>../../resources/WireMock.Net-Logo.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\WireMock.Net.Console.Net452.Classic\MainApp.cs" Link="MainApp.cs" />
<Compile Include="..\WireMock.Net.Console.Net452.Classic\CustomFileSystemFileHandler.cs" Link="CustomFileSystemFileHandler.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="__admin\mappings\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Remove="__admin\mappings\1.cs" />
</ItemGroup>
<ItemGroup>
<Content Remove="__admin\mappings\wiremock-petstore-openapi3.json" />
</ItemGroup>
<ItemGroup>
<None Remove="__admin\mappings\array.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
<PackageReference Include="Handlebars.Net.Helpers" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.4.0" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<None Update="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="nlog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="__admin\mappings\791a3f31-6946-4ce7-8e6f-0237c7443275.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="__admin\mappings\791a3f31-6946-4ce7-8e6f-0237c7443275.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Update="__admin\mappings\MyXmlResponse.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="__admin\mappings\wiremock-petstore-openapi3.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -1,22 +0,0 @@
{
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/static/mapping"
}
]
},
"Methods": [
"get"
]
},
"Response": {
"BodyAsJson": { "body": "static mapping" },
"Headers": {
"Content-Type": "application/json",
"Test-X": [ "test 1", "test 2" ]
}
}
}

View File

@@ -1,29 +0,0 @@
{
"Guid": "791a3f31-6946-4ce7-8e6f-0237c7443275",
"Title": "",
"Priority": 0,
"Request": {
"Path": "/proxy-google-test-post",
"Methods": [
"post"
],
"Body": {}
},
"Response": {
"StatusCode": 404,
"Body": "<!DOCTYPE html>\n<html lang=en>\n <meta charset=utf-8>\n <meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\">\n <title>Error 404 (Not Found)!!1</title>\n <style>\n *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\n </style>\n <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\n <p><b>404.</b> <ins>Thats an error.</ins>\n <p>The requested URL <code>/proxy-google-test-post</code> was not found on this server. <ins>Thats all we know.</ins>\n",
"BodyAsBytes": "PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ZW4+CiAgPG1ldGEgY2hhcnNldD11dGYtOD4KICA8bWV0YSBuYW1lPXZpZXdwb3J0IGNvbnRlbnQ9ImluaXRpYWwtc2NhbGU9MSwgbWluaW11bS1zY2FsZT0xLCB3aWR0aD1kZXZpY2Utd2lkdGgiPgogIDx0aXRsZT5FcnJvciA0MDQgKE5vdCBGb3VuZCkhITE8L3RpdGxlPgogIDxzdHlsZT4KICAgICp7bWFyZ2luOjA7cGFkZGluZzowfWh0bWwsY29kZXtmb250OjE1cHgvMjJweCBhcmlhbCxzYW5zLXNlcmlmfWh0bWx7YmFja2dyb3VuZDojZmZmO2NvbG9yOiMyMjI7cGFkZGluZzoxNXB4fWJvZHl7bWFyZ2luOjclIGF1dG8gMDttYXgtd2lkdGg6MzkwcHg7bWluLWhlaWdodDoxODBweDtwYWRkaW5nOjMwcHggMCAxNXB4fSogPiBib2R5e2JhY2tncm91bmQ6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2Vycm9ycy9yb2JvdC5wbmcpIDEwMCUgNXB4IG5vLXJlcGVhdDtwYWRkaW5nLXJpZ2h0OjIwNXB4fXB7bWFyZ2luOjExcHggMCAyMnB4O292ZXJmbG93OmhpZGRlbn1pbnN7Y29sb3I6Izc3Nzt0ZXh0LWRlY29yYXRpb246bm9uZX1hIGltZ3tib3JkZXI6MH1AbWVkaWEgc2NyZWVuIGFuZCAobWF4LXdpZHRoOjc3MnB4KXtib2R5e2JhY2tncm91bmQ6bm9uZTttYXJnaW4tdG9wOjA7bWF4LXdpZHRoOm5vbmU7cGFkZGluZy1yaWdodDowfX0jbG9nb3tiYWNrZ3JvdW5kOnVybCgvL3d3dy5nb29nbGUuY29tL2ltYWdlcy9icmFuZGluZy9nb29nbGVsb2dvLzF4L2dvb2dsZWxvZ29fY29sb3JfMTUweDU0ZHAucG5nKSBuby1yZXBlYXQ7bWFyZ2luLWxlZnQ6LTVweH1AbWVkaWEgb25seSBzY3JlZW4gYW5kIChtaW4tcmVzb2x1dGlvbjoxOTJkcGkpeyNsb2dve2JhY2tncm91bmQ6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2JyYW5kaW5nL2dvb2dsZWxvZ28vMngvZ29vZ2xlbG9nb19jb2xvcl8xNTB4NTRkcC5wbmcpIG5vLXJlcGVhdCAwJSAwJS8xMDAlIDEwMCU7LW1vei1ib3JkZXItaW1hZ2U6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2JyYW5kaW5nL2dvb2dsZWxvZ28vMngvZ29vZ2xlbG9nb19jb2xvcl8xNTB4NTRkcC5wbmcpIDB9fUBtZWRpYSBvbmx5IHNjcmVlbiBhbmQgKC13ZWJraXQtbWluLWRldmljZS1waXhlbC1yYXRpbzoyKXsjbG9nb3tiYWNrZ3JvdW5kOnVybCgvL3d3dy5nb29nbGUuY29tL2ltYWdlcy9icmFuZGluZy9nb29nbGVsb2dvLzJ4L2dvb2dsZWxvZ29fY29sb3JfMTUweDU0ZHAucG5nKSBuby1yZXBlYXQ7LXdlYmtpdC1iYWNrZ3JvdW5kLXNpemU6MTAwJSAxMDAlfX0jbG9nb3tkaXNwbGF5OmlubGluZS1ibG9jaztoZWlnaHQ6NTRweDt3aWR0aDoxNTBweH0KICA8L3N0eWxlPgogIDxhIGhyZWY9Ly93d3cuZ29vZ2xlLmNvbS8+PHNwYW4gaWQ9bG9nbyBhcmlhLWxhYmVsPUdvb2dsZT48L3NwYW4+PC9hPgogIDxwPjxiPjQwNC48L2I+IDxpbnM+VGhhdOKAmXMgYW4gZXJyb3IuPC9pbnM+CiAgPHA+VGhlIHJlcXVlc3RlZCBVUkwgPGNvZGU+L3Byb3h5LWdvb2dsZS10ZXN0LXBvc3Q8L2NvZGU+IHdhcyBub3QgZm91bmQgb24gdGhpcyBzZXJ2ZXIuICA8aW5zPlRoYXTigJlzIGFsbCB3ZSBrbm93LjwvaW5zPgo=",
"BodyEncoding": {
"CodePage": 65001,
"EncodingName": "Unicode (UTF-8)",
"WebName": "utf-8"
},
"UseTransformer": false,
"Headers": {
"Date": "Wed, 27 Oct 2017 18:57:40 GMT",
"Alt-Svc": "quic=\":443\"; ma=2592000; v=\"39,38,37,35\"",
"Referrer-Policy": "no-referrer",
"Connection": "close"
}
}
}

View File

@@ -1,19 +0,0 @@
{
"Guid": "873d495f-940e-4b86-a1f4-4f0fc7be8b8b",
"Priority": 4,
"Request": {
"Path": {},
"Methods": [
"get"
]
},
"Response": {
"StatusCode": 200,
"BodyDestination": "SameAsSource",
"Body": "NO PATH OR URL",
"UseTransformer": false,
"Headers": {
"Content-Type": "application/json"
}
}
}

View File

@@ -1,22 +0,0 @@
{
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/bodyasfilexmltest",
"IgnoreCase": false
}
]
},
"Methods": [
"get"
]
},
"Response": {
"StatusCode": 200,
"Headers": {"Content-Type": "application/xml"},
"BodyAsFile": "MyXmlResponse.xml",
"UseTransformer": false
}
}

View File

@@ -1,3 +0,0 @@
<xml>
<hello>world</hello>
</xml>

View File

@@ -1,46 +0,0 @@
[
{
"Title": "1",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/mappings_static_1"
}
]
},
"Methods": [
"get"
]
},
"Response": {
"BodyAsJson": { "result": "mappings static_1" },
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Title": "2",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/mappings_static_2"
}
]
},
"Methods": [
"get"
]
},
"Response": {
"BodyAsJson": { "result": "mappings static_2" },
"Headers": {
"Content-Type": "application/json"
}
}
}
]

View File

@@ -1,602 +0,0 @@
[
{
"Guid": "9d2fde55-e420-4724-bf40-616e8aeaf53e",
"Request": {
"Path": "/pet",
"Methods": [
"PUT"
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": {
"id": 42,
"name": "example-string",
"category": {
"id": 42,
"name": "example-string"
},
"photoUrls": "example-string",
"tags": "example-string",
"status": "example-string"
},
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "1f7acffa-05f4-4640-bda4-4c71c8d5e6e3",
"Request": {
"Path": "/pet",
"Methods": [
"POST"
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": {
"id": 42,
"name": "example-string",
"category": {
"id": 42,
"name": "example-string"
},
"photoUrls": "example-string",
"tags": "example-string",
"status": "example-string"
},
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "a04ed51d-ad5b-4c69-b22f-d0eaeea18bc1",
"Request": {
"Path": "/pet/findByStatus",
"Methods": [
"GET"
],
"Params": [
{
"Name": "status",
"Matchers": [
{
"Name": "ExactMatcher",
"Pattern": "example-string"
}
]
}
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": [
{
"id": 42,
"name": "example-string",
"category": {
"id": 42,
"name": "example-string"
},
"photoUrls": [
"example-string",
"example-string",
"example-string"
],
"tags": [
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
}
],
"status": "example-string"
},
{
"id": 42,
"name": "example-string",
"category": {
"id": 42,
"name": "example-string"
},
"photoUrls": [
"example-string",
"example-string",
"example-string"
],
"tags": [
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
}
],
"status": "example-string"
},
{
"id": 42,
"name": "example-string",
"category": {
"id": 42,
"name": "example-string"
},
"photoUrls": [
"example-string",
"example-string",
"example-string"
],
"tags": [
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
}
],
"status": "example-string"
}
],
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "8d5df48a-05fb-4861-816f-3f77adf5562f",
"Request": {
"Path": "/pet/findByTags",
"Methods": [
"GET"
],
"Params": [
{
"Name": "tags",
"Matchers": [
{
"Name": "ExactMatcher",
"Pattern": "example-string"
}
]
}
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": [
{
"id": 42,
"name": "example-string",
"category": {
"id": 42,
"name": "example-string"
},
"photoUrls": [
"example-string",
"example-string",
"example-string"
],
"tags": [
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
}
],
"status": "example-string"
},
{
"id": 42,
"name": "example-string",
"category": {
"id": 42,
"name": "example-string"
},
"photoUrls": [
"example-string",
"example-string",
"example-string"
],
"tags": [
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
}
],
"status": "example-string"
},
{
"id": 42,
"name": "example-string",
"category": {
"id": 42,
"name": "example-string"
},
"photoUrls": [
"example-string",
"example-string",
"example-string"
],
"tags": [
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
},
{
"id": 42,
"name": "example-string"
}
],
"status": "example-string"
}
],
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "065f790b-125c-419e-8fbd-3616bf09b142",
"Request": {
"Path": "/pet/42",
"Methods": [
"GET"
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": {
"id": 42,
"name": "example-string",
"category": {
"id": 42,
"name": "example-string"
},
"photoUrls": "example-string",
"tags": "example-string",
"status": "example-string"
},
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "737aaddd-5bab-489d-914b-deb4ba773539",
"Request": {
"Path": "/pet/42",
"Methods": [
"POST"
],
"Params": [
{
"Name": "name",
"Matchers": [
{
"Name": "ExactMatcher",
"Pattern": "example-string"
}
]
},
{
"Name": "status",
"Matchers": [
{
"Name": "ExactMatcher",
"Pattern": "example-string"
}
]
}
]
},
"Response": {
"StatusCode": 200
}
},
{
"Guid": "0619896c-c3b3-4a30-903e-59792134898c",
"Request": {
"Path": "/pet/42",
"Methods": [
"DELETE"
]
},
"Response": {
"StatusCode": 200
}
},
{
"Guid": "9aaa6a6d-ca4b-4da3-8a9a-844e3af02272",
"Request": {
"Path": "/pet/42/uploadImage",
"Methods": [
"POST"
],
"Params": [
{
"Name": "additionalMetadata",
"Matchers": [
{
"Name": "ExactMatcher",
"Pattern": "example-string"
}
]
}
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": {
"code": 42,
"type": "example-string",
"message": "example-string"
},
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "085ef9c2-425d-45c2-9311-d3e4697c407f",
"Request": {
"Path": "/store/inventory",
"Methods": [
"GET"
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": {},
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "a68c50e9-418c-45e7-8340-c0426cf5b87c",
"Request": {
"Path": "/store/order",
"Methods": [
"POST"
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": {
"id": 42,
"petId": 42,
"quantity": 42,
"shipDate": "2020-06-16T12:54:18.885+00:00",
"status": "example-string",
"complete": true
},
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "16061ffc-97a5-4419-874f-66d857998f76",
"Request": {
"Path": "/store/order/42",
"Methods": [
"GET"
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": {
"id": 42,
"petId": 42,
"quantity": 42,
"shipDate": "2020-06-16T12:54:18.887+00:00",
"status": "example-string",
"complete": true
},
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "55c071d3-eeb5-4a9c-8692-486585e45e2e",
"Request": {
"Path": "/store/order/42",
"Methods": [
"DELETE"
]
},
"Response": {
"StatusCode": 200
}
},
{
"Guid": "2d9d895d-58e9-4734-92f4-903e2b364dda",
"Request": {
"Path": "/user",
"Methods": [
"POST"
]
},
"Response": {
"StatusCode": 0,
"BodyAsJson": {
"id": 42,
"username": "example-string",
"firstName": "example-string",
"lastName": "example-string",
"email": "example-string",
"password": "example-string",
"phone": "example-string",
"userStatus": 42
},
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "c17eeba0-da58-4128-9ae6-33a6a31971e2",
"Request": {
"Path": "/user/createWithList",
"Methods": [
"POST"
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": {
"id": 42,
"username": "example-string",
"firstName": "example-string",
"lastName": "example-string",
"email": "example-string",
"password": "example-string",
"phone": "example-string",
"userStatus": 42
},
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "c95da645-9449-438e-a8c8-0278ea514558",
"Request": {
"Path": "/user/login",
"Methods": [
"GET"
],
"Params": [
{
"Name": "username",
"Matchers": [
{
"Name": "ExactMatcher",
"Pattern": "example-string"
}
]
},
{
"Name": "password",
"Matchers": [
{
"Name": "ExactMatcher",
"Pattern": "example-string"
}
]
}
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": "example-string",
"Headers": {
"X-Rate-Limit": "example-string",
"X-Expires-After": "example-string",
"Content-Type": "application/json"
}
}
},
{
"Guid": "bd05033f-1189-4d89-8cdc-f681399a46b3",
"Request": {
"Path": "/user/logout",
"Methods": [
"GET"
]
},
"Response": {
"StatusCode": 0
}
},
{
"Guid": "7c1d49d4-e9f0-49b9-b898-f8c7d55ae472",
"Request": {
"Path": "/user/example-string",
"Methods": [
"GET"
]
},
"Response": {
"StatusCode": 200,
"BodyAsJson": {
"id": 42,
"username": "example-string",
"firstName": "example-string",
"lastName": "example-string",
"email": "example-string",
"password": "example-string",
"phone": "example-string",
"userStatus": 42
},
"Headers": {
"Content-Type": "application/json"
}
}
},
{
"Guid": "1b7c4cd8-b251-480a-982e-c42d40dbfd4e",
"Request": {
"Path": "/user/example-string",
"Methods": [
"PUT"
]
},
"Response": {
"StatusCode": 0
}
},
{
"Guid": "8a86e775-4bf9-490d-a52f-641458c256f7",
"Request": {
"Path": "/user/example-string",
"Methods": [
"DELETE"
]
},
"Response": {
"StatusCode": 200
}
}
]

View File

@@ -28,12 +28,12 @@
<ItemGroup>
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
<PackageReference Include="Handlebars.Net.Helpers" Version="2.4.0" />
<!--<PackageReference Include="Handlebars.Net.Helpers" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.4.0" />
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.4.0" />-->
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

View File

@@ -55,11 +55,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="HandlebarsDotNet.Helpers.Core" publicKeyToken="00d131fae0c250bc" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.3.10.0" newVersion="2.3.10.0" />
<bindingRedirect oldVersion="0.0.0.0-2.4.1.2" newVersion="2.4.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="XPath2" publicKeyToken="463c6d7fb740c7e5" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.3.0" newVersion="1.1.3.0" />
<bindingRedirect oldVersion="0.0.0.0-1.1.4.0" newVersion="1.1.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" 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.10.0" newVersion="2.3.10.0" />
<bindingRedirect oldVersion="0.0.0.0-2.4.1.2" newVersion="2.4.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Linq.Dynamic.Core" publicKeyToken="0f07ec44de6ac832" culture="neutral" />

View File

@@ -49,29 +49,29 @@
<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>
<Reference Include="Handlebars.Net.Helpers, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.4.0\lib\net46\Handlebars.Net.Helpers.dll</HintPath>
<Reference Include="Handlebars.Net.Helpers, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.4.1.2\lib\net46\Handlebars.Net.Helpers.dll</HintPath>
</Reference>
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Core.dll</HintPath>
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Core.dll</HintPath>
</Reference>
<Reference Include="HandlebarsDotNet.Helpers.DynamicLinq, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.DynamicLinq.2.4.0\lib\net46\HandlebarsDotNet.Helpers.DynamicLinq.dll</HintPath>
<Reference Include="HandlebarsDotNet.Helpers.DynamicLinq, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.DynamicLinq.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.DynamicLinq.dll</HintPath>
</Reference>
<Reference Include="HandlebarsDotNet.Helpers.Humanizer, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.Humanizer.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Humanizer.dll</HintPath>
<Reference Include="HandlebarsDotNet.Helpers.Humanizer, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.Humanizer.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Humanizer.dll</HintPath>
</Reference>
<Reference Include="HandlebarsDotNet.Helpers.Json, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.Json.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Json.dll</HintPath>
<Reference Include="HandlebarsDotNet.Helpers.Json, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.Json.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Json.dll</HintPath>
</Reference>
<Reference Include="HandlebarsDotNet.Helpers.Random, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.Random.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Random.dll</HintPath>
<Reference Include="HandlebarsDotNet.Helpers.Random, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.Random.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Random.dll</HintPath>
</Reference>
<Reference Include="HandlebarsDotNet.Helpers.Xeger, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.Xeger.2.4.0\lib\net46\HandlebarsDotNet.Helpers.Xeger.dll</HintPath>
<Reference Include="HandlebarsDotNet.Helpers.Xeger, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.Xeger.2.4.1.2\lib\net46\HandlebarsDotNet.Helpers.Xeger.dll</HintPath>
</Reference>
<Reference Include="HandlebarsDotNet.Helpers.XPath, Version=2.4.0.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.XPath.2.4.0\lib\net46\HandlebarsDotNet.Helpers.XPath.dll</HintPath>
<Reference Include="HandlebarsDotNet.Helpers.XPath, Version=2.4.1.2, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
<HintPath>..\..\packages\Handlebars.Net.Helpers.XPath.2.4.1.2\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>
@@ -352,11 +352,11 @@
<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="XPath2, Version=1.1.3.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
<HintPath>..\..\packages\XPath2.1.1.3\lib\net452\XPath2.dll</HintPath>
<Reference Include="XPath2, Version=1.1.4.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
<HintPath>..\..\packages\XPath2.1.1.4\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 Include="XPath2.Extensions, Version=1.1.4.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
<HintPath>..\..\packages\XPath2.Extensions.1.1.4\lib\net452\XPath2.Extensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

View File

@@ -3,14 +3,14 @@
<package id="AnyOf" version="0.3.0" targetFramework="net472" />
<package id="Fare" version="2.2.1" targetFramework="net472" />
<package id="Handlebars.Net" version="2.1.4" targetFramework="net472" />
<package id="Handlebars.Net.Helpers" version="2.4.0" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.Core" version="2.4.0" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.DynamicLinq" version="2.4.0" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.Humanizer" version="2.4.0" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.Json" version="2.4.0" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.Random" version="2.4.0" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.Xeger" version="2.4.0" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.XPath" version="2.4.0" targetFramework="net472" />
<package id="Handlebars.Net.Helpers" version="2.4.1.2" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.Core" version="2.4.1.2" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.DynamicLinq" version="2.4.1.2" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.Humanizer" version="2.4.1.2" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.Json" version="2.4.1.2" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.Random" version="2.4.1.2" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.Xeger" version="2.4.1.2" targetFramework="net472" />
<package id="Handlebars.Net.Helpers.XPath" version="2.4.1.2" 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" />
@@ -151,6 +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="XPath2" version="1.1.3" targetFramework="net472" />
<package id="XPath2.Extensions" version="1.1.3" targetFramework="net472" />
<package id="XPath2" version="1.1.4" targetFramework="net472" />
<package id="XPath2.Extensions" version="1.1.4" targetFramework="net472" />
</packages>

View File

@@ -1,44 +0,0 @@
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using WireMock.Logging;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;
using WireMock.Settings;
namespace WireMock.Net.Console.Proxy.NETCoreApp2
{
class Program
{
static void Main(string[] args)
{
var server = WireMockServer.Start(new WireMockServerSettings
{
Urls = new[] { "http://localhost:9091", "https://localhost:9443" },
StartAdminInterface = true,
ReadStaticMappings = false,
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
Url = "http://postman-echo.com/post",
//ClientX509Certificate2ThumbprintOrSubjectName = "www.yourclientcertname.com OR yourcertificatethumbprint (only if the service you're proxying to requires it)",
SaveMapping = true,
SaveMappingToFile = false,
ExcludedHeaders = new[] { "dnt", "Content-Length" }
},
Logger= new WireMockConsoleLogger()
});
//server.LogEntriesChanged += (sender, eventRecordArgs) =>
//{
// System.Console.WriteLine(JsonConvert.SerializeObject(eventRecordArgs.NewItems, Formatting.Indented));
//};
System.Console.WriteLine("Press any key to stop the server");
System.Console.ReadKey();
server.Stop();
}
}
}

View File

@@ -1,27 +0,0 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:63377/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WireMock.Net.Console.Proxy.NETCoreApp2": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:63378/"
}
}
}

View File

@@ -1,17 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<ApplicationIcon>../../resources/WireMock.Net-Logo.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
</ItemGroup>
</Project>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@@ -79,8 +79,8 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<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 Include="XPath2, Version=1.1.4.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
<HintPath>..\..\packages\XPath2.1.1.4\lib\net452\XPath2.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

View File

@@ -12,5 +12,5 @@
<package id="Owin" version="1.0" targetFramework="net452" />
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net452" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net452" requireReinstallation="true" />
<package id="XPath2" version="1.1.3" targetFramework="net452" />
<package id="XPath2" version="1.1.4" targetFramework="net48" />
</packages>

View File

@@ -1,22 +0,0 @@
using Microsoft.Extensions.Logging;
namespace WireMock.Net.WebApplication
{
public class App
{
private readonly IWireMockService _service;
private readonly ILogger _logger;
public App(IWireMockService service, ILogger logger)
{
_service = service;
_logger = logger;
}
public void Run()
{
_logger.LogInformation("WireMock.Net App running");
_service.Run();
}
}
}

View File

@@ -1,7 +0,0 @@
namespace WireMock.Net.WebApplication
{
public interface IWireMockService
{
void Run();
}
}

View File

@@ -1,57 +0,0 @@
using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using WireMock.Settings;
namespace WireMock.Net.WebApplication
{
public class Program
{
public static void Main(string[] args)
{
// Create service collection
var serviceCollection = new ServiceCollection();
ConfigureServices(serviceCollection);
// Create service provider
var serviceProvider = serviceCollection.BuildServiceProvider();
// Run app
serviceProvider.GetService<App>().Run();
}
private static void ConfigureServices(IServiceCollection serviceCollection)
{
// Build configuration
var configuration = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables() // <-- this is needed to to override settings via the Azure Portal App Settings
.Build();
// Add LoggerFactory
var factory = new LoggerFactory();
serviceCollection.AddSingleton(factory
.AddConsole(configuration.GetSection("Logging"))
.AddDebug()
.AddAzureWebAppDiagnostics()
);
serviceCollection.AddSingleton(factory.CreateLogger("WireMock.Net Logger"));
// Add access to generic IConfigurationRoot
serviceCollection.AddSingleton(configuration);
// Add access to WireMockServerSettings
var settings = configuration.GetSection("WireMockServerSettings").Get<WireMockServerSettings>();
serviceCollection.AddSingleton<WireMockServerSettings>(settings);
// Add services
serviceCollection.AddTransient<IWireMockService, WireMockService>();
// Add app
serviceCollection.AddTransient<App>();
}
}
}

View File

@@ -1,34 +0,0 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:60097/",
"sslPort": 44321
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchUrl": "__admin/settings",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WireMock.Net.WebApplication": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "__admin/settings",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:56514/"
},
"IIS": {
"commandName": "IIS",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "development"
}
}
}
}

View File

@@ -1,35 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<StartupObject>WireMock.Net.WebApplication.Program</StartupObject>
<AssemblyName>WireMock.Net.WebApplication</AssemblyName>
<RootNamespace>WireMock.Net.WebApplication</RootNamespace>
<UserSecretsId>efcf4a18-fd7c-4622-825d-336d65290599</UserSecretsId>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0'">
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1'">
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
<PackageReference Include="Microsoft.AspNetCore.All" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@@ -1,83 +0,0 @@
using System;
using System.Threading;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using WireMock.Admin.Requests;
using WireMock.Logging;
using WireMock.Server;
using WireMock.Settings;
namespace WireMock.Net.WebApplication
{
public class WireMockService : IWireMockService
{
private static int sleepTime = 30000;
private readonly ILogger _logger;
private readonly WireMockServerSettings _settings;
private class Logger : IWireMockLogger
{
private readonly ILogger _logger;
public Logger(ILogger logger)
{
_logger = logger;
}
public void Debug(string formatString, params object[] args)
{
_logger.LogDebug(formatString, args);
}
public void Info(string formatString, params object[] args)
{
_logger.LogInformation(formatString, args);
}
public void Warn(string formatString, params object[] args)
{
_logger.LogWarning(formatString, args);
}
public void Error(string formatString, params object[] args)
{
_logger.LogError(formatString, args);
}
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminrequest)
{
string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented);
_logger.LogDebug("Admin[{0}] {1}", isAdminrequest, message);
}
public void Error(string formatString, Exception exception)
{
_logger.LogError(formatString, exception.Message);
}
}
public WireMockService(ILogger logger, WireMockServerSettings settings)
{
_logger = logger;
_settings = settings;
_settings.Logger = new Logger(logger);
}
public void Run()
{
_logger.LogInformation("WireMock.Net server starting");
WireMockServer.Start(_settings);
_logger.LogInformation($"WireMock.Net server settings {JsonConvert.SerializeObject(_settings)}");
while (true)
{
_logger.LogInformation("WireMock.Net server running");
Thread.Sleep(sleepTime);
}
}
}
}

View File

@@ -1,20 +0,0 @@
{
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Debug"
}
},
"Console": {
"LogLevel": {
"Default": "Debug"
}
}
},
"WireMockServerSettings": {
"AdminUsername": "a",
"AdminPassword": "b",
"StartAdminInterface": true
}
}

View File

@@ -1,5 +0,0 @@
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": []
}

View File

@@ -1,21 +0,0 @@
# Running in IIS
Follow these links / steps:
* https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS
* https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-2.1
* Create a `web.config` file
## IIS Sites
![IIS Multiple](resources/iis-wiremock1and2.png)
## App Pool settings
![IIS Multiple](resources/iis-apppool.png)
## Publish Profiles
Two example publish profiles are created:
* [IIS Localhost 1](./Properties/PublishProfiles/IIS%20Localhost%201.pubxml)
* [IIS Localhost 2](./Properties/PublishProfiles/IIS%20Localhost%202.pubxml)
## Debugging
Select the debug "IIS" if you want to debug in IIS.
![IIS Debug](resources/iis-debug.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>

View File

@@ -15,12 +15,12 @@ public class LogEntryModel
/// <summary>
/// The request.
/// </summary>
public LogRequestModel Request { get; set; }
public required LogRequestModel Request { get; init; }
/// <summary>
/// The response.
/// </summary>
public LogResponseModel Response { get; set; }
public required LogResponseModel Response { get; init; }
/// <summary>
/// The mapping unique identifier.

View File

@@ -69,6 +69,11 @@ public class ProxyAndRecordSettingsModel
/// </summary>
public bool AppendGuidToSavedMappingFile { get; set; }
/// <summary>
/// Set prefix for saved mapping file.
/// </summary>
public string PrefixForSavedMappingFile { get; set; }
/// <summary>
/// Defines the Replace Settings.
/// </summary>

View File

@@ -7,19 +7,16 @@ public enum ReplaceNodeOptions
{
/// <summary>
/// Try to evaluate a templated value.
/// In case this is valid, return the value and if the value can be converted to a primitive type, use that value.
/// In case this is valid, return the value and if the value can be converted to a supported (primitive) type, use that value.
///
/// [Default behaviour]
/// </summary>
EvaluateAndTryToConvert = 0,
/// <summary>
/// Try to evaluate a templated value.
/// In case this is valid, return the value, else fallback to the parse behavior.
/// Parse templated string to a templated string.
/// For example: keep a templated string value (which is always the case) as a string value.
/// </summary>
Evaluate = 1,
/// <summary>
/// Parse templated string to a templated string.
/// (keep a templated string value as string value).
/// </summary>
Parse = 2
EvaluateAndKeep = Evaluate
}

View File

@@ -43,6 +43,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PolySharp" Version="1.14.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard')) and '$(TargetFramework)' != 'netstandard1.0'">

View File

@@ -178,7 +178,7 @@ public interface IWireMockAdminApi
/// Get a request based on the guid
/// </summary>
/// <param name="guid">The Guid</param>
/// <returns>MappingModel</returns>
/// <returns>LogEntryModel</returns>
/// <param name="cancellationToken">The optional cancellationToken.</param>
[Get("requests/{guid}")]
Task<LogEntryModel> GetRequestAsync([Path] Guid guid, CancellationToken cancellationToken = default);
@@ -192,7 +192,7 @@ public interface IWireMockAdminApi
Task<StatusModel> DeleteRequestAsync([Path] Guid guid, CancellationToken cancellationToken = default);
/// <summary>
/// Find a request based on the criteria
/// Find requests based on the criteria (<see cref="RequestModel"/>)
/// </summary>
/// <param name="model">The RequestModel</param>
/// <param name="cancellationToken">The optional cancellationToken.</param>
@@ -200,6 +200,14 @@ public interface IWireMockAdminApi
[Header("Content-Type", "application/json")]
Task<IList<LogEntryModel>> FindRequestsAsync([Body] RequestModel model, CancellationToken cancellationToken = default);
/// <summary>
/// Find a request 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);
/// <summary>
/// Get all scenarios
/// </summary>

View File

@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using JsonConverter.Abstractions;
using WireMock.Matchers;
using WireMock.Matchers.Request;
using WireMock.Util;
namespace WireMock.RequestBuilders;

View File

@@ -29,5 +29,5 @@ public interface ITransformResponseBuilder : IDelayResponseBuilder
/// <returns>
/// The <see cref="IResponseBuilder"/>.
/// </returns>
IResponseBuilder WithTransformer(TransformerType transformerType = TransformerType.Handlebars, bool transformContentFromBodyAsFile = false, ReplaceNodeOptions options = ReplaceNodeOptions.Evaluate);
IResponseBuilder WithTransformer(TransformerType transformerType = TransformerType.Handlebars, bool transformContentFromBodyAsFile = false, ReplaceNodeOptions options = ReplaceNodeOptions.EvaluateAndTryToConvert);
}

View File

@@ -205,7 +205,7 @@ public partial class Response : IResponseBuilder
}
/// <inheritdoc />
public IResponseBuilder WithTransformer(TransformerType transformerType, bool transformContentFromBodyAsFile = false, ReplaceNodeOptions options = ReplaceNodeOptions.Evaluate)
public IResponseBuilder WithTransformer(TransformerType transformerType, bool transformContentFromBodyAsFile = false, ReplaceNodeOptions options = ReplaceNodeOptions.EvaluateAndTryToConvert)
{
UseTransformer = true;
TransformerType = transformerType;

View File

@@ -0,0 +1,48 @@
using System.IO;
using System.Linq;
using Stef.Validation;
using WireMock.Settings;
namespace WireMock.Serialization;
/// <summary>
/// Creates sanitized file names for mappings
/// </summary>
public class MappingFileNameSanitizer
{
private const char ReplaceChar = '_';
private readonly WireMockServerSettings _settings;
public MappingFileNameSanitizer(WireMockServerSettings settings)
{
_settings = Guard.NotNull(settings);
}
/// <summary>
/// Creates sanitized file names for mappings
/// </summary>
public string BuildSanitizedFileName(IMapping mapping)
{
string name;
if (!string.IsNullOrEmpty(mapping.Title))
{
// remove 'Proxy Mapping for ' and an extra space character after the HTTP request method
name = mapping.Title.Replace(ProxyAndRecordSettings.DefaultPrefixForSavedMappingFile, "").Replace(' '.ToString(), string.Empty);
if (_settings.ProxyAndRecordSettings?.AppendGuidToSavedMappingFile == true)
{
name += $"{ReplaceChar}{mapping.Guid}";
}
}
else
{
name = mapping.Guid.ToString();
}
if (!string.IsNullOrEmpty(_settings.ProxyAndRecordSettings?.PrefixForSavedMappingFile))
{
name = $"{_settings.ProxyAndRecordSettings.PrefixForSavedMappingFile}{ReplaceChar}{name}";
}
return $"{Path.GetInvalidFileNameChars().Aggregate(name, (current, c) => current.Replace(c, ReplaceChar))}.json";
}
}

View File

@@ -10,11 +10,13 @@ internal class MappingToFileSaver
{
private readonly WireMockServerSettings _settings;
private readonly MappingConverter _mappingConverter;
private readonly MappingFileNameSanitizer _fileNameSanitizer;
public MappingToFileSaver(WireMockServerSettings settings, MappingConverter mappingConverter)
{
_settings = Guard.NotNull(settings);
_mappingConverter = Guard.NotNull(mappingConverter);
_fileNameSanitizer = new MappingFileNameSanitizer(settings);
}
public void SaveMappingsToFile(IMapping[] mappings, string? folder = null)
@@ -42,7 +44,7 @@ internal class MappingToFileSaver
var model = _mappingConverter.ToMappingModel(mapping);
var filename = BuildSanitizedFileName(mapping);
var filename = _fileNameSanitizer.BuildSanitizedFileName(mapping);
var path = Path.Combine(folder, filename);
Save(model, path);
@@ -54,23 +56,4 @@ internal class MappingToFileSaver
_settings.FileSystemHandler.WriteMappingFile(path, JsonConvert.SerializeObject(value, JsonSerializationConstants.JsonSerializerSettingsDefault));
}
private string BuildSanitizedFileName(IMapping mapping, char replaceChar = '_')
{
string name;
if (!string.IsNullOrEmpty(mapping.Title))
{
name = mapping.Title!;
if (_settings.ProxyAndRecordSettings?.AppendGuidToSavedMappingFile == true)
{
name += $"{replaceChar}{mapping.Guid}";
}
}
else
{
name = mapping.Guid.ToString();
}
return $"{Path.GetInvalidFileNameChars().Aggregate(name, (current, c) => current.Replace(c, replaceChar))}.json";
}
}

View File

@@ -39,7 +39,7 @@ internal static class WebhookMapper
if (!Enum.TryParse<ReplaceNodeOptions>(model.Request.TransformerReplaceNodeOptions, out var option))
{
option = ReplaceNodeOptions.Evaluate;
option = ReplaceNodeOptions.EvaluateAndTryToConvert;
}
webhook.Request.TransformerReplaceNodeOptions = option;
}

View File

@@ -99,6 +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));
// __admin/scenarios
Given(Request.Create().WithPath(AdminScenarios).UsingGet()).AtPriority(WireMockConstants.AdminPriority).RespondWith(new DynamicResponseProvider(ScenariosGet));
@@ -436,7 +437,7 @@ public partial class WireMockServer
var mappingModels = DeserializeRequestMessageToArray<MappingModel>(requestMessage);
if (mappingModels.Length == 1)
{
Guid? guid = ConvertMappingAndRegisterAsRespondProvider(mappingModels[0]);
var guid = ConvertMappingAndRegisterAsRespondProvider(mappingModels[0]);
return ResponseMessageBuilder.Create(201, "Mapping added", guid);
}
@@ -535,7 +536,7 @@ public partial class WireMockServer
{
if (TryParseGuidFromRequestMessage(requestMessage, out var guid))
{
var entry = LogEntries.FirstOrDefault(r => !r.RequestMessage.Path.StartsWith("/__admin/") && r.Guid == guid);
var entry = LogEntries.SingleOrDefault(r => !r.RequestMessage.Path.StartsWith("/__admin/") && r.Guid == guid);
if (entry is { })
{
var model = new LogEntryMapper(_options).Map(entry);
@@ -600,6 +601,26 @@ public partial class WireMockServer
return ToJson(result);
}
private IResponseMessage RequestFindByMappingGuid(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);
}
return ResponseMessageBuilder.Create(HttpStatusCode.BadRequest);
}
#endregion Requests/find
#region Scenarios

View File

@@ -264,14 +264,16 @@ public partial class WireMockServer
transformerType = TransformerType.Handlebars;
}
if (!Enum.TryParse<ReplaceNodeOptions>(responseModel.TransformerReplaceNodeOptions, out var option))
if (!Enum.TryParse<ReplaceNodeOptions>(responseModel.TransformerReplaceNodeOptions, out var replaceNodeOptions))
{
option = ReplaceNodeOptions.Evaluate;
replaceNodeOptions = ReplaceNodeOptions.EvaluateAndTryToConvert;
}
responseBuilder = responseBuilder.WithTransformer(
transformerType,
responseModel.UseTransformerForBodyAsFile == true,
option);
replaceNodeOptions
);
}
if (!string.IsNullOrEmpty(responseModel.ProxyUrl))

View File

@@ -7,6 +7,11 @@ namespace WireMock.Settings;
/// </summary>
public class ProxyAndRecordSettings : HttpClientSettings
{
/// <summary>
/// Default prefix value for saved mapping file
/// </summary>
public const string DefaultPrefixForSavedMappingFile = "Proxy Mapping for ";
/// <summary>
/// The URL to proxy.
/// </summary>
@@ -95,9 +100,14 @@ public class ProxyAndRecordSettings : HttpClientSettings
/// </summary>
public bool AppendGuidToSavedMappingFile { get; set; }
/// <summary>
/// Set prefix for saved mapping file.
/// </summary>
public string PrefixForSavedMappingFile { get; set; } = DefaultPrefixForSavedMappingFile;
/// <summary>
/// Proxy all Api calls, irrespective of any condition
/// </summary>
[PublicAPI]
public bool ProxyAll { get; set; } = false;
}
}

View File

@@ -120,6 +120,7 @@ public static class WireMockServerSettingsParser
SaveMappingToFile = parser.GetBoolValue("SaveMappingToFile"),
UseDefinedRequestMatchers = parser.GetBoolValue(nameof(ProxyAndRecordSettings.UseDefinedRequestMatchers)),
AppendGuidToSavedMappingFile = parser.GetBoolValue(nameof(ProxyAndRecordSettings.AppendGuidToSavedMappingFile)),
PrefixForSavedMappingFile = parser.GetStringValue(nameof(ProxyAndRecordSettings.PrefixForSavedMappingFile), null),
Url = proxyUrl!,
SaveMappingSettings = new ProxySaveMappingSettings
{

View File

@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using HandlebarsDotNet.Helpers.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stef.Validation;
@@ -13,8 +13,6 @@ namespace WireMock.Transformers;
internal class Transformer : ITransformer
{
private static readonly Type[] SupportedTypes = { typeof(bool), typeof(long), typeof(int), typeof(double), typeof(Guid), typeof(DateTime), typeof(TimeSpan), typeof(Uri) };
private readonly JsonSerializer _jsonSerializer;
private readonly ITransformerContextFactory _factory;
@@ -268,9 +266,10 @@ internal class Transformer : ITransformer
return;
case string transformedString:
if (TryConvert(transformedString, out var convertedFromStringValue))
var (isConvertedFromString, convertedValueFromString) = TryConvert(options, transformedString);
if (isConvertedFromString)
{
node.Replace(JToken.FromObject(convertedFromStringValue, _jsonSerializer));
node.Replace(JToken.FromObject(convertedValueFromString, _jsonSerializer));
}
else
{
@@ -292,7 +291,8 @@ internal class Transformer : ITransformer
break;
case { }:
if (TryConvert(transformedValue, out var convertedValue))
var (isConverted, convertedValue) = TryConvert(options, transformedValue);
if (isConverted)
{
node.Replace(JToken.FromObject(convertedValue, _jsonSerializer));
}
@@ -308,23 +308,28 @@ internal class Transformer : ITransformer
return JsonUtils.TryParseAsJObject(stringValue, out var parsedAsjObject) ? parsedAsjObject : stringValue;
}
private static bool TryConvert(object? transformedValue, [NotNullWhen(true)] out object? convertedValue)
private static (bool IsConverted, object ConvertedValue) TryConvert(ReplaceNodeOptions options, object value)
{
foreach (var supportedType in SupportedTypes)
var valueAsString = value as string;
if (options == ReplaceNodeOptions.Evaluate)
{
try
if (valueAsString != null && WrappedString.TryDecode(valueAsString, out var decoded))
{
convertedValue = Convert.ChangeType(transformedValue, supportedType);
return convertedValue is not null;
}
catch
{
// Ignore
return (true, decoded);
}
return (false, value);
}
convertedValue = null;
return false;
if (valueAsString != null)
{
return WrappedString.TryDecode(valueAsString, out var decoded) ?
(true, decoded) :
StringUtils.TryConvertToKnownType(valueAsString);
}
return (false, value);
}
private static IBodyData TransformBodyAsString(ITransformerContext transformerContext, object model, IBodyData original)

View File

@@ -8,6 +8,48 @@ namespace WireMock.Util;
internal static class StringUtils
{
private static readonly string[] ValidUriSchemes =
{
"ftp://",
"http://",
"https://"
};
private static readonly Func<string, (bool IsConverted, object ConvertedValue)>[] ConversionsFunctions =
{
s => bool.TryParse(s, out var result) ? (true, result) : (false, s),
s => int.TryParse(s, out var result) ? (true, result) : (false, s),
s => long.TryParse(s, out var result) ? (true, result) : (false, s),
s => double.TryParse(s, out var result) ? (true, result) : (false, s),
s => Guid.TryParse(s, out var result) ? (true, result) : (false, s),
s => TimeSpan.TryParse(s, out var result) ? (true, result) : (false, s),
s => DateTime.TryParse(s, out var result) ? (true, result) : (false, s),
s =>
{
if (ValidUriSchemes.Any(u => s.StartsWith(u, StringComparison.OrdinalIgnoreCase)) &&
Uri.TryCreate(s, UriKind.RelativeOrAbsolute, out var uri))
{
return (true, uri);
}
return (false, s);
}
};
public static (bool IsConverted, object ConvertedValue) TryConvertToKnownType(string value)
{
foreach (var func in ConversionsFunctions)
{
var result = func(value);
if (result.IsConverted)
{
return result;
}
}
return (false, value);
}
public static MatchOperator ParseMatchOperator(string? value)
{
return value != null && Enum.TryParse<MatchOperator>(value, out var matchOperator)

View File

@@ -72,13 +72,6 @@
<PackageReference Include="TinyMapper" Version="3.0.3" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug - Sonar'">
<PackageReference Include="SonarAnalyzer.CSharp" Version="7.8.0.7320">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard1.3' ">
<PackageReference Include="XPath2.Extensions" Version="1.1.4" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.12.2" />
@@ -189,13 +182,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Handlebars.Net.Helpers" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers.Humanizer" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.4.1.2" />
<PackageReference Include="Handlebars.Net.Helpers" Version="2.4.1.4" />
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.4.1.4" />
<PackageReference Include="Handlebars.Net.Helpers.Humanizer" Version="2.4.1.4" />
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.4.1.4" />
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.4.1.4" />
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.4.1.4" />
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.4.1.4" />
</ItemGroup>
<ItemGroup>

View File

@@ -7,6 +7,7 @@ using WireMock.Handlers;
using WireMock.Models;
using WireMock.ResponseBuilders;
using WireMock.Settings;
using WireMock.Types;
using Xunit;
namespace WireMock.Net.Tests.ResponseBuilders;
@@ -28,8 +29,10 @@ public class ResponseWithHandlebarsDateTimeTests
_settings.FileSystemHandler = filesystemHandlerMock.Object;
}
[Fact]
public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_DateTime()
[Theory]
[InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Integer)]
[InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)]
public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_DateTimeYear(ReplaceNodeOptions options, JTokenType expected)
{
// Assign
var request = new RequestMessage(new UrlDetails("http://localhost"), "GET", ClientIp);
@@ -39,14 +42,61 @@ public class ResponseWithHandlebarsDateTimeTests
{
DateTimeYear = "{{ DateTime.UtcNow \"yyyy\" }}"
})
.WithTransformer();
.WithTransformer(options);
// Act
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
// Assert
var j = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
j["DateTimeYear"]!.Value<string>().Should().Be(DateTime.Now.Year.ToString());
var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
jObject["DateTimeYear"]!.Type.Should().Be(expected);
jObject["DateTimeYear"]!.Value<string>().Should().Be(DateTime.Now.Year.ToString());
}
[Theory]
[InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Date)]
[InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)]
public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_DateTime(ReplaceNodeOptions options, JTokenType expected)
{
// Assign
var request = new RequestMessage(new UrlDetails("http://localhost"), "GET", ClientIp);
var responseBuilder = Response.Create()
.WithBodyAsJson(new
{
DateTime = "{{ DateTime.UtcNow }}"
})
.WithTransformer(options);
// Act
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
// Assert
var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
jObject["DateTime"]!.Type.Should().Be(expected);
}
[Theory]
[InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Integer)]
[InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)]
public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_DateTimeWithStringFormat(ReplaceNodeOptions options, JTokenType expected)
{
// Assign
var request = new RequestMessage(new UrlDetails("http://localhost"), "GET", ClientIp);
var responseBuilder = Response.Create()
.WithBodyAsJson(new
{
StringFormatDateTime = "{{ String.Format (DateTime.UtcNow) \"yyMMddhhmmss\" }}"
})
.WithTransformer(options);
// Act
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
// Assert
var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
jObject["StringFormatDateTime"]!.Type.Should().Be(expected);
}
[Fact]
@@ -65,4 +115,39 @@ public class ResponseWithHandlebarsDateTimeTests
// Assert
response.Message.BodyData!.BodyAsString.Should().Contain($"DateTimeYear = \"{DateTime.Now.Year}\"");
}
[Theory]
[InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert)]
[InlineData(ReplaceNodeOptions.Evaluate)]
public async Task Response_WithBodyAsJson_ProvideResponseAsync_Handlebars_WithStringFormatAsString(ReplaceNodeOptions options)
{
// Assign
var request = new RequestMessage(new UrlDetails("http://localhost"), "GET", ClientIp);
var responseBuilder = Response.Create()
.WithBodyAsJson(new
{
FormatAsString1 = "{{ String.FormatAsString (DateTime.UtcNow) \"yyMMddhhmmss\" }}",
FormatAsString2 = "{{ String.FormatAsString (DateTime.UtcNow) }}",
FormatAsString3 = "{{ String.FormatAsString 42 \"X\" }}",
FormatAsString4 = "{{ String.FormatAsString 42 }}"
})
.WithTransformer(options);
// Act
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
// Assert
var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
jObject["FormatAsString1"]!.Type.Should().Be(JTokenType.String);
jObject["FormatAsString2"]!.Type.Should().Be(JTokenType.String);
var formatAsString3 = jObject["FormatAsString3"]!;
formatAsString3.Type.Should().Be(JTokenType.String);
formatAsString3.Value<string>().Should().Be("2A");
var formatAsString4 = jObject["FormatAsString4"]!;
formatAsString4.Type.Should().Be(JTokenType.String);
formatAsString4.Value<string>().Should().Be("42");
}
}

View File

@@ -78,10 +78,8 @@ public class ResponseWithHandlebarsRandomTests
}
[Theory]
[InlineData(ReplaceNodeOptions.Evaluate, JTokenType.Integer)]
//[InlineData(ReplaceNodeOptions.Bool, JTokenType.String)]
//[InlineData(ReplaceNodeOptions.Integer, JTokenType.Integer)]
//[InlineData(ReplaceNodeOptions.Bool | ReplaceNodeOptions.Integer, JTokenType.Integer)]
[InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Integer)]
[InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)]
public async Task Response_ProvideResponseAsync_Handlebars_Random1_Integer(ReplaceNodeOptions options, JTokenType expected)
{
// Assign
@@ -98,12 +96,14 @@ public class ResponseWithHandlebarsRandomTests
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
// Assert
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
Check.That(j["Value"].Type).IsEqualTo(expected);
var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
jObject["Value"]!.Type.Should().Be(expected);
}
[Fact]
public async Task Response_ProvideResponseAsync_Handlebars_Random1_Guid()
[Theory]
[InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Guid)]
[InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)]
public async Task Response_ProvideResponseAsync_Handlebars_Random1_Guid(ReplaceNodeOptions options, JTokenType expected)
{
// Assign
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp);
@@ -114,17 +114,15 @@ public class ResponseWithHandlebarsRandomTests
Guid1 = "{{Random Type=\"Guid\" Uppercase=false}}",
Guid2 = "{{Random Type=\"Guid\"}}"
})
.WithTransformer();
.WithTransformer(options);
// Act
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
// Assert
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
string guid1 = j["Guid1"].Value<string>();
Check.That(guid1.ToUpper()).IsNotEqualTo(guid1);
string guid2 = j["Guid2"].Value<string>();
Check.That(guid2.ToUpper()).IsEqualTo(guid2);
var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
jObject["Guid1"]!.Type.Should().Be(expected);
jObject["Guid2"]!.Type.Should().Be(expected);
}
[Fact]

View File

@@ -500,34 +500,6 @@ public class ResponseWithTransformerTests
JsonConvert.SerializeObject(response.Message.BodyData!.BodyAsJson).Should().Be("[{\"x\":\"test\"}]");
}
//[Theory]
//[InlineData(TransformerType.Handlebars, "a")]
//[InlineData(TransformerType.Handlebars, "42")]
//[InlineData(TransformerType.Handlebars, "{")]
//[InlineData(TransformerType.Handlebars, "]")]
//[InlineData(TransformerType.Handlebars, " ")]
//public async Task Response_ProvideResponse_Transformer_WithBodyAsJsonWithExtraQuotes_AndSpecialOption_MakesAString_ResultAsObject(TransformerType transformerType, string text)
//{
// string jsonString = $"{{ \"x\": \"{text}\" }}";
// var bodyData = new BodyData
// {
// BodyAsJson = JsonConvert.DeserializeObject(jsonString),
// DetectedBodyType = BodyType.Json,
// Encoding = Encoding.UTF8
// };
// var request = new RequestMessage(new UrlDetails("http://localhost/foo_object"), "POST", ClientIp, bodyData);
// var responseBuilder = Response.Create()
// .WithBodyAsJson(new { text = "\"{{request.bodyAsJson.x}}\"" })
// .WithTransformer(transformerType, false, ReplaceNodeOptions.Default);
// // Act
// var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
// // Assert
// JsonConvert.SerializeObject(response.Message.BodyData.BodyAsJson).Should().Be($"{{\"text\":\"{text}\"}}");
//}
[Theory]
[InlineData(TransformerType.Handlebars, "\"\"", "\"\"")]
[InlineData(TransformerType.Handlebars, "\"a\"", "\"a\"")]
@@ -543,7 +515,7 @@ public class ResponseWithTransformerTests
[InlineData(TransformerType.Handlebars, "2147483647", "2147483647")]
[InlineData(TransformerType.Handlebars, "\"9223372036854775807\"", "\"9223372036854775807\"")]
[InlineData(TransformerType.Handlebars, "9223372036854775807", "9223372036854775807")]
public async Task Response_ProvideResponse_Transformer_WithBodyAsJson_And_ReplaceNodeOptionsKeep(TransformerType transformerType, string value, string expected)
public async Task Response_ProvideResponse_Transformer_WithBodyAsJson_And_ReplaceNodeOptionsEvaluate(TransformerType transformerType, string value, string expected)
{
string jsonString = $"{{ \"x\": {value} }}";
var bodyData = new BodyData

View File

@@ -11,7 +11,7 @@
},
UseTransformer: true,
TransformerType: Handlebars,
TransformerReplaceNodeOptions: Evaluate
TransformerReplaceNodeOptions: EvaluateAndTryToConvert
},
UseWebhooksFireAndForget: false
}

View File

@@ -0,0 +1,160 @@
using System;
using Moq;
using WireMock.Serialization;
using WireMock.Settings;
using Xunit;
namespace WireMock.Net.Tests.Serialization;
public class MappingFileNameSanitizerTests
{
private const string MappingGuid = "ce216a13-e7d6-42d7-91ac-8ae709e2add1";
private const string MappingTitle = "Proxy Mapping for POST _ordermanagement_v1_orders_cancel";
[Fact]
public void BuildSanitizedFileName_WithTitleAndGuid_AppendsGuid()
{
// Arrange
var mappingMock = new Mock<IMapping>();
mappingMock.Setup(m => m.Title).Returns(MappingTitle);
mappingMock.Setup(m => m.Guid).Returns(new Guid(MappingGuid));
var settings = new WireMockServerSettings
{
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
AppendGuidToSavedMappingFile = true
}
};
var sanitizer = new MappingFileNameSanitizer(settings);
// Act
var result = sanitizer.BuildSanitizedFileName(mappingMock.Object);
// Assert
Assert.Equal($"Proxy Mapping for _POST_ordermanagement_v1_orders_cancel_{MappingGuid}.json", result);
}
[Fact]
public void BuildSanitizedFileName_WithoutTitle_UsesGuid()
{
// Arrange
var mappingMock = new Mock<IMapping>();
mappingMock.Setup(m => m.Title).Returns((string?)null);
mappingMock.Setup(m => m.Guid).Returns(new Guid(MappingGuid));
var settings = new WireMockServerSettings
{
ProxyAndRecordSettings = new ()
};
var sanitizer = new MappingFileNameSanitizer(settings);
// Act
var result = sanitizer.BuildSanitizedFileName(mappingMock.Object);
// Assert
Assert.Equal($"Proxy Mapping for _{MappingGuid}.json", result);
}
[Fact]
public void BuildSanitizedFileName_WithTitleAndGuid_NoAppendGuidSetting()
{
// Arrange
var mappingMock = new Mock<IMapping>();
mappingMock.Setup(m => m.Title).Returns(MappingTitle);
mappingMock.Setup(m => m.Guid).Returns(new Guid(MappingGuid));
var settings = new WireMockServerSettings
{
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
AppendGuidToSavedMappingFile = false
}
};
var sanitizer = new MappingFileNameSanitizer(settings);
// Act
var result = sanitizer.BuildSanitizedFileName(mappingMock.Object);
// Assert
Assert.Equal("Proxy Mapping for _POST_ordermanagement_v1_orders_cancel.json", result);
}
[Fact]
public void BuildSanitizedFileName_WithPrefix_AddsPrefix()
{
// Arrange
var mappingMock = new Mock<IMapping>();
mappingMock.Setup(m => m.Title).Returns(MappingTitle);
mappingMock.Setup(m => m.Guid).Returns(new Guid(MappingGuid));
var settings = new WireMockServerSettings
{
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
PrefixForSavedMappingFile = "Prefix"
}
};
var sanitizer = new MappingFileNameSanitizer(settings);
// Act
var result = sanitizer.BuildSanitizedFileName(mappingMock.Object);
// Assert
Assert.Equal($"Prefix_POST_ordermanagement_v1_orders_cancel.json", result);
}
[Fact]
public void BuildSanitizedFileName_WithPrefix_AddsPrefixEmptyString()
{
// Arrange
var mappingMock = new Mock<IMapping>();
mappingMock.Setup(m => m.Title).Returns(MappingTitle);
mappingMock.Setup(m => m.Guid).Returns(new Guid(MappingGuid));
var settings = new WireMockServerSettings
{
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
PrefixForSavedMappingFile = string.Empty
}
};
var sanitizer = new MappingFileNameSanitizer(settings);
// Act
var result = sanitizer.BuildSanitizedFileName(mappingMock.Object);
// Assert
Assert.Equal($"POST_ordermanagement_v1_orders_cancel.json", result);
}
[Fact]
public void BuildSanitizedFileName_WithTitleAndGuid_WithPrefixAndAppendGuidSetting()
{
// Arrange
var mappingMock = new Mock<IMapping>();
mappingMock.Setup(m => m.Title).Returns(MappingTitle);
mappingMock.Setup(m => m.Guid).Returns(new Guid(MappingGuid));
var settings = new WireMockServerSettings
{
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
PrefixForSavedMappingFile = "Prefix",
AppendGuidToSavedMappingFile = true
}
};
var sanitizer = new MappingFileNameSanitizer(settings);
// Act
var result = sanitizer.BuildSanitizedFileName(mappingMock.Object);
// Assert
Assert.Equal($"Prefix_POST_ordermanagement_v1_orders_cancel_{MappingGuid}.json", result);
}
}

View File

@@ -12,7 +12,6 @@
DetectedBodyType: String,
DetectedBodyTypeFromContentType: Bytes
},
UseTransformer: true,
TransformerReplaceNodeOptions: Evaluate
UseTransformer: true
}
}

View File

@@ -1,3 +1,5 @@
using System;
using CultureAwareTesting.xUnit;
using FluentAssertions;
using WireMock.Matchers;
using WireMock.Util;
@@ -7,6 +9,179 @@ namespace WireMock.Net.Tests.Util;
public class StringUtilsTests
{
[Theory]
[InlineData("", "")]
[InlineData("x", "x")]
public void TryConvertToString_ShouldWorkCorrectly(string input, string expectedValue)
{
var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input);
isConverted.Should().Be(false);
if (isConverted)
{
convertedValue.Should().BeOfType<bool>().And.Be(expectedValue);
}
else
{
convertedValue.Should().Be(input);
}
}
[Theory]
[InlineData("true", true, true)]
[InlineData("false", false, true)]
[InlineData("not a bool", false, false)] // Invalid case
public void TryConvertToBool_ShouldWorkCorrectly(string input, bool expectedValue, bool expectedConversion)
{
var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input);
isConverted.Should().Be(expectedConversion);
if (isConverted)
{
convertedValue.Should().BeOfType<bool>().And.Be(expectedValue);
}
else
{
convertedValue.Should().Be(input);
}
}
[Theory]
[InlineData("123", 123, true)]
[InlineData("-456", -456, true)]
[InlineData("not an int", 0, false)] // Invalid case
public void TryConvertToInt_ShouldWorkCorrectly(string input, int expectedValue, bool expectedConversion)
{
var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input);
isConverted.Should().Be(expectedConversion);
if (isConverted)
{
convertedValue.Should().BeOfType<int>().And.Be(expectedValue);
}
else
{
convertedValue.Should().Be(input);
}
}
[Theory]
[InlineData("12345678901", 12345678901L, true)]
[InlineData("-9876543210", -9876543210L, true)]
[InlineData("not a long", 0L, false)] // Invalid case
public void TryConvertToLong_ShouldWorkCorrectly(string input, long expectedValue, bool expectedConversion)
{
var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input);
isConverted.Should().Be(expectedConversion);
if (isConverted)
{
convertedValue.Should().BeOfType<long>().And.Be(expectedValue);
}
else
{
convertedValue.Should().Be(input);
}
}
[CulturedTheory("en-US")]
[InlineData("123.1", 123.1, true)]
[InlineData("-456.1", -456.1, true)]
[InlineData("not a double", 0.0, false)] // Invalid case
public void TryConvertToDouble_ShouldWorkCorrectly(string input, double expectedValue, bool expectedConversion)
{
var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input);
isConverted.Should().Be(expectedConversion);
if (isConverted)
{
((double) convertedValue).Should().BeApproximately(expectedValue, 0.01);
}
else
{
convertedValue.Should().Be(input);
}
}
[Theory]
[InlineData("3F2504E0-4F89-11D3-9A0C-0305E82C3301", true)]
[InlineData("00000000-0000-0000-0000-000000000000", true)]
[InlineData("3f2504e0-4f89-11d3-9a0c-0305e82c3301", true)] // Lowercase Guid
[InlineData("not a guid", false)] // Invalid case
public void TryConvertToGuid_ShouldWorkCorrectly(string input, bool expectedConversion)
{
var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input);
isConverted.Should().Be(expectedConversion);
if (isConverted)
{
convertedValue.Should().BeOfType<Guid>();
}
else
{
convertedValue.Should().Be(input);
}
}
[Theory]
[InlineData("2023-04-01", true)]
[InlineData("01/01/2000", true)]
[InlineData("not a date", false)] // Invalid case
public void TryConvertToDateTime_ShouldWorkCorrectly(string input, bool expectedConversion)
{
var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input);
isConverted.Should().Be(expectedConversion);
if (isConverted)
{
convertedValue.Should().BeOfType<DateTime>().And.Subject.As<DateTime>().Date.Should().Be(DateTime.Parse(input).Date);
}
else
{
convertedValue.Should().Be(input);
}
}
[Theory]
[InlineData("1.00:00:00", true)] // 1 day
[InlineData("00:30:00", true)] // 30 minutes
[InlineData("not a timespan", false)] // Invalid case
public void TryConvertToTimeSpan_ShouldWorkCorrectly(string input, bool expectedConversion)
{
var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input);
isConverted.Should().Be(expectedConversion);
if (isConverted)
{
convertedValue.Should().BeOfType<TimeSpan>().And.Subject.As<TimeSpan>().Should().Be(TimeSpan.Parse(input));
}
else
{
convertedValue.Should().Be(input);
}
}
[Theory]
[InlineData("http://example.com", true)]
[InlineData("https://example.com/path?query=string#fragment", true)]
[InlineData("ftp://example.com", true)]
[InlineData("file://example.com", false)]
[InlineData("not a uri", false)] // Invalid case
public void TryConvertToUri_ShouldWorkCorrectly(string input, bool expectedConversion)
{
var (isConverted, convertedValue) = StringUtils.TryConvertToKnownType(input);
isConverted.Should().Be(expectedConversion);
if (isConverted)
{
convertedValue.Should().BeOfType<Uri>().And.Subject.As<Uri>().AbsoluteUri.Should().Be(new Uri(input).AbsoluteUri);
}
else
{
convertedValue.Should().Be(input);
}
}
[Theory]
[InlineData("And", MatchOperator.And)]
[InlineData("Or", MatchOperator.Or)]

View File

@@ -234,6 +234,10 @@ public class WireMockAdminApiTests
StartAdminInterface = true,
Logger = new WireMockNullLogger()
});
server
.Given(Request.Create().WithPath("/foo").UsingGet())
.RespondWith(Response.Create());
var serverUrl = "http://localhost:" + server.Ports[0];
await new HttpClient().GetAsync(serverUrl + "/foo").ConfigureAwait(false);
var api = RestClient.For<IWireMockAdminApi>(serverUrl);
@@ -242,11 +246,82 @@ public class WireMockAdminApiTests
var requests = await api.FindRequestsAsync(new RequestModel { Methods = new[] { "GET" } }).ConfigureAwait(false);
// Assert
Check.That(requests).HasSize(1);
requests.Should().HaveCount(1);
var requestLogged = requests.First();
Check.That(requestLogged.Request.Method).IsEqualTo("GET");
Check.That(requestLogged.Request.Body).IsNull();
Check.That(requestLogged.Request.Path).IsEqualTo("/foo");
requestLogged.Request.Method.Should().Be("GET");
requestLogged.Request.Body.Should().BeNull();
requestLogged.Request.Path.Should().Be("/foo");
}
[Fact]
public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_Found()
{
// Arrange
var mappingGuid = Guid.NewGuid();
var server = WireMockServer.Start(new WireMockServerSettings
{
StartAdminInterface = true,
Logger = new WireMockNullLogger()
});
server
.Given(Request.Create().WithPath("/foo").UsingGet())
.WithGuid(mappingGuid)
.RespondWith(Response.Create());
var serverUrl = "http://localhost:" + server.Ports[0];
await new HttpClient().GetAsync(serverUrl + "/foo").ConfigureAwait(false);
var api = RestClient.For<IWireMockAdminApi>(serverUrl);
// Act
var logEntryModel = await api.FindRequestByMappingGuidAsync(mappingGuid).ConfigureAwait(false);
// Assert
logEntryModel.Should().NotBeNull();
logEntryModel!.Request.Method.Should().Be("GET");
logEntryModel!.Request.Body.Should().BeNull();
logEntryModel!.Request.Path.Should().Be("/foo");
}
[Fact]
public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_NotFound()
{
// Arrange
var server = WireMockServer.Start(new WireMockServerSettings
{
StartAdminInterface = true,
Logger = new WireMockNullLogger()
});
server
.Given(Request.Create().WithPath("/foo").UsingGet())
.WithGuid(Guid.NewGuid())
.RespondWith(Response.Create());
var serverUrl = "http://localhost:" + server.Ports[0];
await new HttpClient().GetAsync(serverUrl + "/foo").ConfigureAwait(false);
var api = RestClient.For<IWireMockAdminApi>(serverUrl);
// Act
var logEntryModel = await api.FindRequestByMappingGuidAsync(Guid.NewGuid()).ConfigureAwait(false);
// Assert
logEntryModel.Should().BeNull();
}
[Fact]
public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_Invalid_ShouldReturnBadRequest()
{
// Arrange
var server = WireMockServer.Start(new WireMockServerSettings
{
StartAdminInterface = true,
Logger = new WireMockNullLogger()
});
// Act
var result = await server.CreateClient().GetAsync("/__admin/requests/find?mappingGuid=x");
// Assert
result.StatusCode.Should().Be(HttpStatusCode.BadRequest);
}
[Fact]
@@ -815,7 +890,7 @@ public class WireMockAdminApiTests
.RespondWith(
Response.Create()
.WithStatusCode(HttpStatusCode.AlreadyReported)
.WithBodyAsJson(new { @as = 1, b=1.2, d=true, e=false, f=new[]{1,2,3,4}, g= new{z1=1, z2=2, z3=new []{"a","b","c"}, z4=new[]{new {a=1, b=2},new {a=2, b=3}}}, date_field = new DateTime(2023,05,08,11,20,19), string_field_with_date="2021-03-13T21:04:00Z", multiline_text= @"This
.WithBodyAsJson(new { @as = 1, b = 1.2, d = true, e = false, f = new[] { 1, 2, 3, 4 }, g = new { z1 = 1, z2 = 2, z3 = new[] { "a", "b", "c" }, z4 = new[] { new { a = 1, b = 2 }, new { a = 2, b = 3 } } }, date_field = new DateTime(2023, 05, 08, 11, 20, 19), string_field_with_date = "2021-03-13T21:04:00Z", multiline_text = @"This
is
multiline
text
@@ -826,7 +901,7 @@ text
.Given(
Request.Create()
.WithPath("/foo3")
.WithBody(new JsonPartialMatcher(new { a=1, b=2}))
.WithBody(new JsonPartialMatcher(new { a = 1, b = 2 }))
.UsingPost()
)
.WithGuid(guid4)

View File

@@ -117,7 +117,7 @@ public class WireMockServerProxyTests
}
// Assert
server.Mappings.Should().HaveCount(34);
server.Mappings.Should().HaveCount(35);
}
[Fact]
@@ -174,7 +174,7 @@ public class WireMockServerProxyTests
server.Mappings.Should().HaveCount(2);
// Verify
fileSystemHandlerMock.Verify(f => f.WriteMappingFile($"m{System.IO.Path.DirectorySeparatorChar}{title}.json", It.IsRegex(stringBody)), Times.Once);
fileSystemHandlerMock.Verify(f => f.WriteMappingFile($"m{System.IO.Path.DirectorySeparatorChar}Proxy Mapping for _{title}.json", It.IsRegex(stringBody)), Times.Once);
}
[Fact]

View File

@@ -81,7 +81,7 @@ public class WireMockServerSettingsTests
// Assert
server.Mappings.Should().NotBeNull();
server.Mappings.Should().HaveCount(32);
server.Mappings.Should().HaveCount(33);
server.Mappings.All(m => m.Priority == WireMockConstants.AdminPriority).Should().BeTrue();
}
@@ -100,9 +100,9 @@ public class WireMockServerSettingsTests
// Assert
server.Mappings.Should().NotBeNull();
server.Mappings.Should().HaveCount(33);
server.Mappings.Should().HaveCount(34);
server.Mappings.Count(m => m.Priority == WireMockConstants.AdminPriority).Should().Be(32);
server.Mappings.Count(m => m.Priority == WireMockConstants.AdminPriority).Should().Be(33);
server.Mappings.Count(m => m.Priority == WireMockConstants.ProxyPriority).Should().Be(1);
}