mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-23 01:04:55 +01:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e23249c144 | ||
|
|
7a8f4c3630 | ||
|
|
ddcf2b29a3 | ||
|
|
23709fa587 | ||
|
|
3b0dc46771 | ||
|
|
f6ebb1c256 | ||
|
|
e4071b9c6a | ||
|
|
48c50e8207 | ||
|
|
acee016dec | ||
|
|
951f8e5508 | ||
|
|
1a021a7cff | ||
|
|
ced9fc58f5 | ||
|
|
24ae9a7dad | ||
|
|
919b28fa36 | ||
|
|
5de2ea44e3 | ||
|
|
ebb9f128c5 | ||
|
|
0141cc0d04 | ||
|
|
c41989c0f3 | ||
|
|
e8181e9d53 | ||
|
|
e1c9b7be9b | ||
|
|
c35315e610 | ||
|
|
73e73cebb7 | ||
|
|
92923a12ae | ||
|
|
d4da8dc15d | ||
|
|
f104b24f66 | ||
|
|
a228cdcb7c | ||
|
|
fae27f9dc7 |
35
CHANGELOG.md
35
CHANGELOG.md
@@ -1,3 +1,38 @@
|
|||||||
|
# 1.4.5 (11 February 2021)
|
||||||
|
- [#585](https://github.com/WireMock-Net/WireMock.Net/pull/585) - Fix response date header [bug] contributed by [wolf8196](https://github.com/wolf8196)
|
||||||
|
|
||||||
|
# 1.4.4 (09 February 2021)
|
||||||
|
- [#581](https://github.com/WireMock-Net/WireMock.Net/pull/581) - Use new Handlebars.Net.Helpers [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#582](https://github.com/WireMock-Net/WireMock.Net/pull/582) - Add Xamarin UI tests [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#568](https://github.com/WireMock-Net/WireMock.Net/issues/568) - [Question] Dates in response templates [feature]
|
||||||
|
|
||||||
|
# 1.4.3 (05 February 2021)
|
||||||
|
- [#570](https://github.com/WireMock-Net/WireMock.Net/pull/570) - Bump log4net from 2.0.8 to 2.0.10 in /examples/WireMock.Net.StandAlone.NETCoreApp [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
|
||||||
|
- [#571](https://github.com/WireMock-Net/WireMock.Net/pull/571) - Bump log4net from 2.0.8 to 2.0.10 in /examples/WireMock.Net.Console.NETCoreApp2 [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
|
||||||
|
- [#572](https://github.com/WireMock-Net/WireMock.Net/pull/572) - Bump log4net from 2.0.8 to 2.0.10 in /examples/WireMock.Net.Console.NETCoreApp [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
|
||||||
|
- [#573](https://github.com/WireMock-Net/WireMock.Net/pull/573) - Bump log4net from 2.0.8 to 2.0.10 in /examples/WireMock.Net.Console.Net461.Classic [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
|
||||||
|
- [#574](https://github.com/WireMock-Net/WireMock.Net/pull/574) - Bump log4net from 2.0.8 to 2.0.10 in /examples/WireMock.Net.Console.Net452.Classic [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
|
||||||
|
- [#575](https://github.com/WireMock-Net/WireMock.Net/pull/575) - Bump log4net from 2.0.8 to 2.0.10 in /examples/WireMock.Net.StandAlone.Net452 [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
|
||||||
|
- [#576](https://github.com/WireMock-Net/WireMock.Net/pull/576) - Bump log4net from 2.0.8 to 2.0.10 in /examples/WireMock.Net.Service [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
|
||||||
|
- [#579](https://github.com/WireMock-Net/WireMock.Net/pull/579) - Net5 issue [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#577](https://github.com/WireMock-Net/WireMock.Net/issues/577) - WireMock.Net will not run with certain .net5 dependencies installed in the project [bug]
|
||||||
|
|
||||||
|
# 1.4.2 (24 January 2021)
|
||||||
|
- [#566](https://github.com/WireMock-Net/WireMock.Net/pull/566) - Do not save Mappings when SaveMappingForStatusCodePattern does not match [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#565](https://github.com/WireMock-Net/WireMock.Net/issues/565) - NullReferenceException [bug]
|
||||||
|
|
||||||
|
# 1.4.1 (19 January 2021)
|
||||||
|
- [#562](https://github.com/WireMock-Net/WireMock.Net/pull/562) - Refactor Transformer (add Scriban) [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#214](https://github.com/WireMock-Net/WireMock.Net/issues/214) - Feature: Add support for template language DotLiquid [feature]
|
||||||
|
|
||||||
|
# 1.4.0 (12 January 2021)
|
||||||
|
- [#548](https://github.com/WireMock-Net/WireMock.Net/pull/548) - Move CSharpCodeMatcher to a new project [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
|
||||||
|
# 1.3.10 (23 December 2020)
|
||||||
|
- [#555](https://github.com/WireMock-Net/WireMock.Net/pull/555) - Add more tests for Proxy with Authorization [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#561](https://github.com/WireMock-Net/WireMock.Net/pull/561) - Do not save "admin" mappings when running in Proxy - mode contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#559](https://github.com/WireMock-Net/WireMock.Net/issues/559) - WireMock Setting 'SaveMappingToFile' raising cast object to type error [bug]
|
||||||
|
|
||||||
# 1.3.9 (08 December 2020)
|
# 1.3.9 (08 December 2020)
|
||||||
- [#550](https://github.com/WireMock-Net/WireMock.Net/pull/550) - WithProxy(...) also use all proxy settings [bug] contributed by [StefH](https://github.com/StefH)
|
- [#550](https://github.com/WireMock-Net/WireMock.Net/pull/550) - WithProxy(...) also use all proxy settings [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
- [#551](https://github.com/WireMock-Net/WireMock.Net/pull/551) - Add obsolete warning: CSharpCodeMatcher will be moved to a separate NuGet package 'WireMock.Net.Matchers.CSharpCode' [feature] contributed by [StefH](https://github.com/StefH)
|
- [#551](https://github.com/WireMock-Net/WireMock.Net/pull/551) - Add obsolete warning: CSharpCodeMatcher will be moved to a separate NuGet package 'WireMock.Net.Matchers.CSharpCode' [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VersionPrefix>1.3.9</VersionPrefix>
|
<VersionPrefix>1.4.5</VersionPrefix>
|
||||||
<PackageReleaseNotes>See CHANGELOG.md</PackageReleaseNotes>
|
<PackageReleaseNotes>See CHANGELOG.md</PackageReleaseNotes>
|
||||||
<PackageIconUrl>https://raw.githubusercontent.com/WireMock-Net/WireMock.Net/master/WireMock.Net-Logo.png</PackageIconUrl>
|
<PackageIconUrl>https://raw.githubusercontent.com/WireMock-Net/WireMock.Net/master/WireMock.Net-Logo.png</PackageIconUrl>
|
||||||
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
https://github.com/StefH/GitHubReleaseNotes
|
https://github.com/StefH/GitHubReleaseNotes
|
||||||
|
|
||||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.3.9
|
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.4.5
|
||||||
@@ -12,7 +12,7 @@ For more info, see also this WIKI page: [What is WireMock.Net](https://github.co
|
|||||||
* Per-request conditional proxying
|
* Per-request conditional proxying
|
||||||
* Stateful behaviour simulation
|
* Stateful behaviour simulation
|
||||||
* Response templating / transformation using Handlebars and extensions
|
* Response templating / transformation using Handlebars and extensions
|
||||||
* Can be used locally or in CI/CD scenarios.
|
* Can be used locally or in CI/CD scenarios
|
||||||
|
|
||||||
## Info
|
## Info
|
||||||
| | |
|
| | |
|
||||||
@@ -35,6 +35,7 @@ For more info, see also this WIKI page: [What is WireMock.Net](https://github.co
|
|||||||
| **WireMock.Net.StandAlone** | [](https://www.nuget.org/packages/WireMock.Net.StandAlone) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.StandAlone)
|
| **WireMock.Net.StandAlone** | [](https://www.nuget.org/packages/WireMock.Net.StandAlone) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.StandAlone)
|
||||||
| **WireMock.Net.FluentAssertions** | [](https://www.nuget.org/packages/WireMock.Net.FluentAssertions) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.FluentAssertions)
|
| **WireMock.Net.FluentAssertions** | [](https://www.nuget.org/packages/WireMock.Net.FluentAssertions) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.FluentAssertions)
|
||||||
| **WireMock.Net.RestClient** | [](https://www.nuget.org/packages/WireMock.Net.RestClient) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.RestClient)
|
| **WireMock.Net.RestClient** | [](https://www.nuget.org/packages/WireMock.Net.RestClient) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.RestClient)
|
||||||
|
| **WireMock.Net.Matchers.CSharpCode** | [](https://www.nuget.org/packages/WireMock.Net.Matchers.CSharpCode) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Matchers.CSharpCode)
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
For the supported frameworks and build information, see [this](https://github.com/WireMock-Net/WireMock.Net/wiki/Development-Information) page.
|
For the supported frameworks and build information, see [this](https://github.com/WireMock-Net/WireMock.Net/wiki/Development-Information) page.
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-WireMock", "src\dotn
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NET5", "examples\WireMock.Net.Console.NET5\WireMock.Net.Console.NET5.csproj", "{3F8CF0AE-5F24-4A54-89E7-A3EE829DB5F8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NET5", "examples\WireMock.Net.Console.NET5\WireMock.Net.Console.NET5.csproj", "{3F8CF0AE-5F24-4A54-89E7-A3EE829DB5F8}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Matchers.CSharpCode", "src\WireMock.Net.Matchers.CSharpCode\WireMock.Net.Matchers.CSharpCode.csproj", "{B6269AAC-170A-4346-8B9A-444DED3D9A44}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Net472.Classic", "examples\WireMock.Net.Console.Net472.Classic\WireMock.Net.Console.Net472.Classic.csproj", "{6580580B-1EFD-4922-B0EC-FF290DB279EE}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.XamarinUI.Tests", "test\WireMock.Net.XamarinUI.Tests\WireMock.Net.XamarinUI.Tests.csproj", "{0DE14F1B-A51E-4B59-A87C-C6012DCD2844}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -192,6 +198,22 @@ Global
|
|||||||
{3F8CF0AE-5F24-4A54-89E7-A3EE829DB5F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{3F8CF0AE-5F24-4A54-89E7-A3EE829DB5F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3F8CF0AE-5F24-4A54-89E7-A3EE829DB5F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{3F8CF0AE-5F24-4A54-89E7-A3EE829DB5F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3F8CF0AE-5F24-4A54-89E7-A3EE829DB5F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{3F8CF0AE-5F24-4A54-89E7-A3EE829DB5F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B6269AAC-170A-4346-8B9A-444DED3D9A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B6269AAC-170A-4346-8B9A-444DED3D9A44}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B6269AAC-170A-4346-8B9A-444DED3D9A44}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B6269AAC-170A-4346-8B9A-444DED3D9A44}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6580580B-1EFD-4922-B0EC-FF290DB279EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6580580B-1EFD-4922-B0EC-FF290DB279EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6580580B-1EFD-4922-B0EC-FF290DB279EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6580580B-1EFD-4922-B0EC-FF290DB279EE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0DE14F1B-A51E-4B59-A87C-C6012DCD2844}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0DE14F1B-A51E-4B59-A87C-C6012DCD2844}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0DE14F1B-A51E-4B59-A87C-C6012DCD2844}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0DE14F1B-A51E-4B59-A87C-C6012DCD2844}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B6269AAC-170A-4346-8B9A-444DED3D9A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B6269AAC-170A-4346-8B9A-444DED3D9A44}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B6269AAC-170A-4346-8B9A-444DED3D9A44}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B6269AAC-170A-4346-8B9A-444DED3D9A44}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -224,6 +246,10 @@ Global
|
|||||||
{925E421A-1B3F-4202-B48F-734743573A4B} = {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}
|
{40BF24B5-12E6-4610-9489-138798632E28} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||||
{3F8CF0AE-5F24-4A54-89E7-A3EE829DB5F8} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
{3F8CF0AE-5F24-4A54-89E7-A3EE829DB5F8} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
|
{B6269AAC-170A-4346-8B9A-444DED3D9A44} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||||
|
{B6269AAC-170A-4346-8B9A-444DED3D9A44} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||||
|
{6580580B-1EFD-4922-B0EC-FF290DB279EE} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
|
{0DE14F1B-A51E-4B59-A87C-C6012DCD2844} = {0BB8B634-407A-4610-A91F-11586990767A}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458}
|
SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458}
|
||||||
|
|||||||
@@ -28,10 +28,10 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||||
<PackageReference Include="Handlebars.Net.Helpers" Version="1.1.0" />
|
<PackageReference Include="Handlebars.Net.Helpers" Version="2.*" />
|
||||||
<PackageReference Include="log4net" Version="2.0.8" />
|
<PackageReference Include="log4net" Version="2.0.12" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
<!--<PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="3.4.0" />-->
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -19,8 +19,13 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||||
<PackageReference Include="Handlebars.Net" Version="1.9.5" />
|
<PackageReference Include="Handlebars.Net.Helpers" Version="2.*" />
|
||||||
<PackageReference Include="log4net" Version="2.0.8" />
|
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.*" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.*" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.*" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.*" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.*" />
|
||||||
|
<PackageReference Include="log4net" Version="2.0.10" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,13 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||||
<PackageReference Include="Handlebars.Net" Version="1.9.5" />
|
<PackageReference Include="Handlebars.Net.Helpers" Version="2.*" />
|
||||||
<PackageReference Include="log4net" Version="2.0.8" />
|
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.*" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.*" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.*" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.*" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.*" />
|
||||||
|
<PackageReference Include="log4net" Version="2.0.10" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,14 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||||
<PackageReference Include="Handlebars.Net.Helpers" Version="1.1.0" />
|
<PackageReference Include="Handlebars.Net.Helpers" Version="2.*" />
|
||||||
<PackageReference Include="log4net" Version="2.0.8" />
|
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.*" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.*" />
|
||||||
<!--<PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="3.4.0" />-->
|
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.*" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.*" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.*" />
|
||||||
|
<PackageReference Include="log4net" Version="2.0.12" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -3,4 +3,12 @@
|
|||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||||
</startup>
|
</startup>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="HandlebarsDotNet.Helpers.Core" publicKeyToken="00d131fae0c250bc" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-2.1.1.0" newVersion="2.1.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -13,6 +13,7 @@ using WireMock.Server;
|
|||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using WireMock.Types;
|
||||||
|
|
||||||
namespace WireMock.Net.ConsoleApplication
|
namespace WireMock.Net.ConsoleApplication
|
||||||
{
|
{
|
||||||
@@ -63,7 +64,7 @@ namespace WireMock.Net.ConsoleApplication
|
|||||||
HandlebarsRegistrationCallback = (handlebarsContext, fileSystemHandler) =>
|
HandlebarsRegistrationCallback = (handlebarsContext, fileSystemHandler) =>
|
||||||
{
|
{
|
||||||
var transformer = new CustomNameTransformer();
|
var transformer = new CustomNameTransformer();
|
||||||
handlebarsContext.RegisterHelper(transformer.Name, transformer.Render);
|
// handlebarsContext.RegisterHelper(transformer.Name, transformer.Render); TODO
|
||||||
},
|
},
|
||||||
|
|
||||||
// Uncomment below if you want to use the CustomFileSystemFileHandler
|
// Uncomment below if you want to use the CustomFileSystemFileHandler
|
||||||
@@ -279,7 +280,7 @@ namespace WireMock.Net.ConsoleApplication
|
|||||||
.WithBody("hi"));
|
.WithBody("hi"));
|
||||||
|
|
||||||
server
|
server
|
||||||
.Given(Request.Create().WithPath("/data").UsingPost().WithBody(b => b.Contains("e")))
|
.Given(Request.Create().WithPath("/data").UsingPost().WithBody(b => b != null && b.Contains("e")))
|
||||||
.AtPriority(999)
|
.AtPriority(999)
|
||||||
.RespondWith(Response.Create()
|
.RespondWith(Response.Create()
|
||||||
.WithStatusCode(201)
|
.WithStatusCode(201)
|
||||||
@@ -346,7 +347,7 @@ namespace WireMock.Net.ConsoleApplication
|
|||||||
.WithHeader("Transformed-Postman-Token", "token is {{request.headers.Postman-Token}}")
|
.WithHeader("Transformed-Postman-Token", "token is {{request.headers.Postman-Token}}")
|
||||||
.WithHeader("xyz_{{request.headers.Postman-Token}}", "token is {{request.headers.Postman-Token}}")
|
.WithHeader("xyz_{{request.headers.Postman-Token}}", "token is {{request.headers.Postman-Token}}")
|
||||||
.WithBody(@"{""msg"": ""Hello world CATCH-ALL on /*, {{request.path}}, add={{Math.Add request.query.start.[0] 42}} bykey={{request.query.start}}, bykey={{request.query.stop}}, byidx0={{request.query.stop.[0]}}, byidx1={{request.query.stop.[1]}}"" }")
|
.WithBody(@"{""msg"": ""Hello world CATCH-ALL on /*, {{request.path}}, add={{Math.Add request.query.start.[0] 42}} bykey={{request.query.start}}, bykey={{request.query.stop}}, byidx0={{request.query.stop.[0]}}, byidx1={{request.query.stop.[1]}}"" }")
|
||||||
.WithTransformer()
|
.WithTransformer(TransformerType.Handlebars)
|
||||||
.WithDelay(TimeSpan.FromMilliseconds(100))
|
.WithDelay(TimeSpan.FromMilliseconds(100))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -36,11 +36,17 @@
|
|||||||
<ApplicationIcon>..\..\WireMock.Net-Logo.ico</ApplicationIcon>
|
<ApplicationIcon>..\..\WireMock.Net-Logo.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Handlebars, Version=1.9.5.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
<Reference Include="Handlebars, Version=2.0.4.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.1.9.5\lib\net452\Handlebars.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.2.0.4\lib\net452\Handlebars.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
<Reference Include="Handlebars.Net.Helpers, Version=2.1.1.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.1.1-preview-01\lib\net452\Handlebars.Net.Helpers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.1.1.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.1.1-preview-01\lib\net452\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
@@ -53,7 +59,12 @@
|
|||||||
<HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath>
|
<HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.XML" />
|
<Reference Include="System.XML" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Handlebars.Net" version="1.9.5" targetFramework="net452" />
|
<package id="Handlebars.Net" version="2.0.4" targetFramework="net452" />
|
||||||
<package id="log4net" version="2.0.8" targetFramework="net452" />
|
<package id="Handlebars.Net.Helpers" version="2.1.1-preview-01" targetFramework="net452" />
|
||||||
|
<package id="Handlebars.Net.Helpers.Core" version="2.1.1-preview-01" targetFramework="net452" />
|
||||||
|
<package id="log4net" version="2.0.12" targetFramework="net452" />
|
||||||
<package id="Microsoft.Owin.Host.HttpListener" version="3.1.0" targetFramework="net452" />
|
<package id="Microsoft.Owin.Host.HttpListener" version="3.1.0" targetFramework="net452" />
|
||||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
|
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
|
||||||
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net452" />
|
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net452" />
|
||||||
|
<package id="System.ValueTuple" version="4.3.0" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
||||||
@@ -35,11 +35,17 @@
|
|||||||
<StartupObject>WireMock.Net.ConsoleApplication.Program</StartupObject>
|
<StartupObject>WireMock.Net.ConsoleApplication.Program</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Handlebars, Version=1.9.5.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
<Reference Include="Handlebars, Version=2.0.4.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Handlebars.Net.1.9.5\lib\net452\Handlebars.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.2.0.4\lib\net46\Handlebars.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
<Reference Include="Handlebars.Net.Helpers, Version=2.1.1.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.1.1-preview-01\lib\net452\Handlebars.Net.Helpers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.1.1.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.1.1-preview-01\lib\net452\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
@@ -48,7 +54,12 @@
|
|||||||
<HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath>
|
<HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Handlebars.Net" version="1.9.5" targetFramework="net461" />
|
<package id="Handlebars.Net" version="2.0.4" targetFramework="net461" />
|
||||||
<package id="log4net" version="2.0.8" targetFramework="net461" />
|
<package id="Handlebars.Net.Helpers" version="2.1.1-preview-01" targetFramework="net461" />
|
||||||
|
<package id="Handlebars.Net.Helpers.Core" version="2.1.1-preview-01" targetFramework="net461" />
|
||||||
|
<package id="log4net" version="2.0.12" targetFramework="net461" />
|
||||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
|
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
|
||||||
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net461" />
|
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net461" />
|
||||||
|
<package id="System.ValueTuple" version="4.3.0" targetFramework="net461" />
|
||||||
</packages>
|
</packages>
|
||||||
54
examples/WireMock.Net.Console.Net472.Classic/App.config
Normal file
54
examples/WireMock.Net.Console.Net472.Classic/App.config
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
|
</startup>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Security.Cryptography.Cng" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Microsoft.AspNetCore.Server.IIS" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-2.2.6.0" newVersion="2.2.6.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Microsoft.Extensions.Configuration" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("WireMock.Net.Console.Net461.Classic")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("WireMock.Net.Console.Net461.Classic")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Stef Heyenrath 2018")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("1261bb9b-a7d4-456c-8985-3ce560361b8e")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,329 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\build\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.props" Condition="Exists('..\..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\build\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.props')" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{6580580B-1EFD-4922-B0EC-FF290DB279EE}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>WireMock.Net.Console.Net461.Classic</RootNamespace>
|
||||||
|
<AssemblyName>WireMock.Net.Console.Net461.Classic</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<StartupObject>WireMock.Net.ConsoleApplication.Program</StartupObject>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Fare, Version=2.1.0.0, Culture=neutral, PublicKeyToken=ea68d375bf33a7c8, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Fare.2.1.1\lib\net35\Fare.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Handlebars, Version=2.0.4.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Handlebars.Net.2.0.4\lib\net46\Handlebars.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Handlebars.Net.Helpers, Version=2.1.1.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.2.1.1-preview-01\lib\net452\Handlebars.Net.Helpers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="HandlebarsDotNet.Helpers.Core, Version=2.1.1.0, Culture=neutral, PublicKeyToken=00d131fae0c250bc, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Handlebars.Net.Helpers.Core.2.1.1-preview-01\lib\net452\HandlebarsDotNet.Helpers.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="JmesPath.Net, Version=1.0.125.0, Culture=neutral, PublicKeyToken=b29d616b7f4faff0, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\JmesPath.Net.1.0.125\lib\net45\JmesPath.Net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Authentication.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Authentication.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Authentication.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Authentication.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Connections.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Connections.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Connections.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Diagnostics, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Diagnostics.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Diagnostics.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Diagnostics.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Diagnostics.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Diagnostics.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.HostFiltering, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.HostFiltering.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.HostFiltering.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Hosting, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Hosting.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Hosting.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Hosting.Server.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Hosting.Server.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Server.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Http, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Http.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Http.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Http.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Http.Extensions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Http.Extensions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Http.Features, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Http.Features.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.HttpOverrides, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.HttpOverrides.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.HttpOverrides.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Routing, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Routing.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Routing.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Routing.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Routing.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Server.IIS, Version=2.2.6.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Server.IIS.2.2.6\lib\netstandard2.0\Microsoft.AspNetCore.Server.IIS.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Server.IISIntegration, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Server.IISIntegration.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Server.IISIntegration.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Server.Kestrel, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Server.Kestrel.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Server.Kestrel.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Server.Kestrel.Core.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Server.Kestrel.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Https, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Server.Kestrel.Https.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Server.Kestrel.Https.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.WebUtilities, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.AspNetCore.WebUtilities.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.WebUtilities.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Configuration, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.5.0.0\lib\net461\Microsoft.Extensions.Configuration.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Configuration.Binder, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.Binder.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Configuration.CommandLine, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.CommandLine.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.CommandLine.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Configuration.EnvironmentVariables, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.EnvironmentVariables.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.EnvironmentVariables.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Configuration.FileExtensions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.FileExtensions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.FileExtensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Configuration.Json, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.Json.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Configuration.UserSecrets, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.2.2.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.FileProviders.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.FileProviders.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.FileProviders.Physical, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.FileProviders.Physical.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Physical.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.FileSystemGlobbing, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.FileSystemGlobbing.2.2.0\lib\netstandard2.0\Microsoft.Extensions.FileSystemGlobbing.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Hosting.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Hosting.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Hosting.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Logging, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Logging.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Logging.Configuration, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Configuration.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Logging.Console, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Console.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Console.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Logging.Debug, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Debug.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Debug.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Logging.EventSource, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Logging.EventSource.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Logging.EventSource.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.ObjectPool, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.ObjectPool.2.2.0\lib\netstandard2.0\Microsoft.Extensions.ObjectPool.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Options, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Options.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Options.ConfigurationExtensions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Options.ConfigurationExtensions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Options.ConfigurationExtensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Extensions.Primitives.5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Net.Http.Headers, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="RandomDataGenerator, Version=1.0.12.0, Culture=neutral, PublicKeyToken=ae5c571d29a3b8d9, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\RandomDataGenerator.Net.1.0.12\lib\net45\RandomDataGenerator.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Scriban.Signed, Version=2.1.4.0, Culture=neutral, PublicKeyToken=5675fb69b15f2433, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Scriban.Signed.2.1.4\lib\net45\Scriban.Signed.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SimMetrics.Net, Version=1.0.5.0, Culture=neutral, PublicKeyToken=c58dc06d59f3391b, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Linq.Dynamic.Core, Version=1.0.12.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Linq.Dynamic.Core.1.0.12\lib\net46\System.Linq.Dynamic.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.WebRequest" />
|
||||||
|
<Reference Include="System.Numerics" />
|
||||||
|
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Reflection.Metadata, Version=1.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Cryptography.Cng, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Security.Cryptography.Cng.4.5.0\lib\net47\System.Security.Cryptography.Cng.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Principal.Windows, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Security.Principal.Windows.4.5.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Text.Encodings.Web, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Text.Encodings.Web.4.5.0\lib\netstandard2.0\System.Text.Encodings.Web.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="XPath2, Version=1.1.0.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\XPath2.1.1.0\lib\net40\XPath2.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="XPath2.Extensions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\XPath2.Extensions.1.1.0\lib\net40\XPath2.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\WireMock.Net.Console.Net452.Classic\CustomFileSystemFileHandler.cs">
|
||||||
|
<Link>CustomFileSystemFileHandler.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\WireMock.Net.Console.Net452.Classic\MainApp.cs">
|
||||||
|
<Link>MainApp.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\WireMock.Net.Console.Net452.Classic\Program.cs">
|
||||||
|
<Link>Program.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\WireMock.Net.Console.Net452.Classic\log4net.config">
|
||||||
|
<Link>log4net.config</Link>
|
||||||
|
</None>
|
||||||
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj">
|
||||||
|
<Project>{b6269aac-170a-4346-8b9a-579ded3d9a94}</Project>
|
||||||
|
<Name>WireMock.Net.Abstractions</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj">
|
||||||
|
<Project>{d3804228-91f4-4502-9595-39584e5a01ad}</Project>
|
||||||
|
<Name>WireMock.Net</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\build\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\build\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.props'))" />
|
||||||
|
<Error Condition="!Exists('..\..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\build\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\build\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.targets'))" />
|
||||||
|
<Error Condition="!Exists('..\..\packages\Microsoft.AspNetCore.Server.IIS.2.2.6\build\netstandard2.0\Microsoft.AspNetCore.Server.IIS.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.AspNetCore.Server.IIS.2.2.6\build\netstandard2.0\Microsoft.AspNetCore.Server.IIS.targets'))" />
|
||||||
|
<Error Condition="!Exists('..\..\packages\Microsoft.AspNetCore.Server.IISIntegration.2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Server.IISIntegration.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.AspNetCore.Server.IISIntegration.2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Server.IISIntegration.targets'))" />
|
||||||
|
</Target>
|
||||||
|
<Import Project="..\..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\build\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.targets" Condition="Exists('..\..\packages\Microsoft.Extensions.Configuration.UserSecrets.2.2.0\build\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.targets')" />
|
||||||
|
<Import Project="..\..\packages\Microsoft.AspNetCore.Server.IIS.2.2.6\build\netstandard2.0\Microsoft.AspNetCore.Server.IIS.targets" Condition="Exists('..\..\packages\Microsoft.AspNetCore.Server.IIS.2.2.6\build\netstandard2.0\Microsoft.AspNetCore.Server.IIS.targets')" />
|
||||||
|
<Import Project="..\..\packages\Microsoft.AspNetCore.Server.IISIntegration.2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Server.IISIntegration.targets" Condition="Exists('..\..\packages\Microsoft.AspNetCore.Server.IISIntegration.2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Server.IISIntegration.targets')" />
|
||||||
|
</Project>
|
||||||
83
examples/WireMock.Net.Console.Net472.Classic/packages.config
Normal file
83
examples/WireMock.Net.Console.Net472.Classic/packages.config
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Fare" version="2.1.1" targetFramework="net472" />
|
||||||
|
<package id="Handlebars.Net" version="2.0.4" targetFramework="net472" />
|
||||||
|
<package id="Handlebars.Net.Helpers" version="2.1.1-preview-01" targetFramework="net472" />
|
||||||
|
<package id="Handlebars.Net.Helpers.Core" version="2.1.1-preview-01" targetFramework="net472" />
|
||||||
|
<package id="JmesPath.Net" version="1.0.125" targetFramework="net472" />
|
||||||
|
<package id="log4net" version="2.0.12" targetFramework="net461" />
|
||||||
|
<package id="Microsoft.AspNetCore" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Authentication.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Authentication.Core" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Connections.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Diagnostics" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Diagnostics.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.HostFiltering" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Hosting" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Hosting.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Http" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Http.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Http.Extensions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Http.Features" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.HttpOverrides" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Routing" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Routing.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Server.IIS" version="2.2.6" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Server.IISIntegration" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Server.Kestrel" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Server.Kestrel.Core" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Server.Kestrel.Https" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.AspNetCore.WebUtilities" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.CSharp" version="4.5.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Configuration" version="5.0.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Configuration.Abstractions" version="5.0.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Configuration.Binder" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Configuration.CommandLine" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Configuration.EnvironmentVariables" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Configuration.FileExtensions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Configuration.Json" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Configuration.UserSecrets" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.DependencyInjection" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.FileProviders.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.FileProviders.Physical" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.FileSystemGlobbing" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Hosting.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Logging" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Logging.Abstractions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Logging.Configuration" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Logging.Console" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Logging.Debug" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Logging.EventSource" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.ObjectPool" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Options" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Options.ConfigurationExtensions" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Extensions.Primitives" version="5.0.0" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.Net.Http.Headers" version="2.2.0" targetFramework="net472" />
|
||||||
|
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
|
||||||
|
<package id="RandomDataGenerator.Net" version="1.0.12" targetFramework="net472" />
|
||||||
|
<package id="Scriban.Signed" version="2.1.4" targetFramework="net472" />
|
||||||
|
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net461" />
|
||||||
|
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||||
|
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net472" />
|
||||||
|
<package id="System.ComponentModel.Annotations" version="4.5.0" targetFramework="net472" />
|
||||||
|
<package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net472" />
|
||||||
|
<package id="System.IO.Pipelines" version="4.5.3" targetFramework="net472" />
|
||||||
|
<package id="System.Linq.Dynamic.Core" version="1.0.12" targetFramework="net472" />
|
||||||
|
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
|
||||||
|
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||||
|
<package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net472" />
|
||||||
|
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net472" />
|
||||||
|
<package id="System.Security.Cryptography.Cng" version="4.5.0" targetFramework="net472" />
|
||||||
|
<package id="System.Security.Principal.Windows" version="4.5.0" targetFramework="net472" />
|
||||||
|
<package id="System.Text.Encodings.Web" version="4.5.0" targetFramework="net472" />
|
||||||
|
<package id="System.Threading.Tasks.Extensions" version="4.5.1" targetFramework="net472" />
|
||||||
|
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||||
|
<package id="WireMock.Net" version="1.4.2" targetFramework="net472" />
|
||||||
|
<package id="WireMock.Net.Abstractions" version="1.4.2" targetFramework="net472" />
|
||||||
|
<package id="XPath2" version="1.1.0" targetFramework="net472" />
|
||||||
|
<package id="XPath2.Extensions" version="1.1.0" targetFramework="net472" />
|
||||||
|
</packages>
|
||||||
@@ -3,6 +3,7 @@ using System.Net.Http;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using WireMock.Logging;
|
||||||
using WireMock.RequestBuilders;
|
using WireMock.RequestBuilders;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Server;
|
using WireMock.Server;
|
||||||
@@ -14,9 +15,6 @@ namespace WireMock.Net.Console.Proxy.NETCoreApp2
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
RunTestDifferentPort().Wait(20000); // prints "1"
|
|
||||||
RunTestDifferentPort().Wait(20000); // prints "1"
|
|
||||||
|
|
||||||
var server = WireMockServer.Start(new WireMockServerSettings
|
var server = WireMockServer.Start(new WireMockServerSettings
|
||||||
{
|
{
|
||||||
Urls = new[] { "http://localhost:9091", "https://localhost:9443" },
|
Urls = new[] { "http://localhost:9091", "https://localhost:9443" },
|
||||||
@@ -29,34 +27,18 @@ namespace WireMock.Net.Console.Proxy.NETCoreApp2
|
|||||||
SaveMapping = true,
|
SaveMapping = true,
|
||||||
SaveMappingToFile = false,
|
SaveMappingToFile = false,
|
||||||
ExcludedHeaders = new[] { "dnt", "Content-Length" }
|
ExcludedHeaders = new[] { "dnt", "Content-Length" }
|
||||||
}
|
},
|
||||||
|
Logger= new WireMockConsoleLogger()
|
||||||
});
|
});
|
||||||
|
|
||||||
server.LogEntriesChanged += (sender, eventRecordArgs) =>
|
//server.LogEntriesChanged += (sender, eventRecordArgs) =>
|
||||||
{
|
//{
|
||||||
System.Console.WriteLine(JsonConvert.SerializeObject(eventRecordArgs.NewItems, Formatting.Indented));
|
// System.Console.WriteLine(JsonConvert.SerializeObject(eventRecordArgs.NewItems, Formatting.Indented));
|
||||||
};
|
//};
|
||||||
|
|
||||||
System.Console.WriteLine("Press any key to stop the server");
|
System.Console.WriteLine("Press any key to stop the server");
|
||||||
System.Console.ReadKey();
|
System.Console.ReadKey();
|
||||||
server.Stop();
|
server.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task RunTestDifferentPort()
|
|
||||||
{
|
|
||||||
var server = WireMockServer.Start();
|
|
||||||
|
|
||||||
server.Given(Request.Create().WithPath("/").UsingGet())
|
|
||||||
.RespondWith(Response.Create().WithStatusCode(200).WithBody("Hello"));
|
|
||||||
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
|
|
||||||
var response = await new HttpClient().GetAsync(server.Urls[0]);
|
|
||||||
response.EnsureSuccessStatusCode();
|
|
||||||
|
|
||||||
System.Console.WriteLine("RunTestDifferentPort - server.LogEntries.Count() = " + server.LogEntries.Count());
|
|
||||||
|
|
||||||
server.Stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
|
||||||
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
|
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Handlebars.Net" version="1.9.5" targetFramework="net452" />
|
<package id="Handlebars.Net" version="1.9.5" targetFramework="net452" />
|
||||||
<package id="log4net" version="2.0.8" targetFramework="net452" />
|
<package id="log4net" version="2.0.10" targetFramework="net452" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
|
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
|
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net452" />
|
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net452" />
|
||||||
|
|||||||
@@ -34,11 +34,12 @@ namespace WireMock.Net.StandAlone.NETCoreApp
|
|||||||
|
|
||||||
_server = WireMockServer.Start(settings);
|
_server = WireMockServer.Start(settings);
|
||||||
|
|
||||||
//_server
|
_server
|
||||||
// .Given(Request.Create()
|
.Given(Request.Create()
|
||||||
// .UsingAnyMethod())
|
.UsingAnyMethod())
|
||||||
// .RespondWith(Response.Create()
|
.RespondWith(Response.Create()
|
||||||
// .WithProxy("https://www.google.com"));
|
.WithTransformer()
|
||||||
|
.WithBody("{{Random Type=\"Integer\" Min=100 Max=999999}} {{DateTime.Now}} {{DateTime.Now \"yyyy-MMM\"}} {{String.Format (DateTime.Now) \"MMM-dd\"}}"));
|
||||||
|
|
||||||
Console.WriteLine($"{DateTime.UtcNow} Press Ctrl+C to shut down");
|
Console.WriteLine($"{DateTime.UtcNow} Press Ctrl+C to shut down");
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="log4net" Version="2.0.8" />
|
<PackageReference Include="log4net" Version="2.0.10" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="log4net" version="2.0.8" targetFramework="net452" />
|
<package id="log4net" version="2.0.10" targetFramework="net452" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.6" targetFramework="net452" />
|
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.6" targetFramework="net452" />
|
||||||
<package id="Microsoft.Owin.Host.HttpListener" version="4.0.0" targetFramework="net452" />
|
<package id="Microsoft.Owin.Host.HttpListener" version="4.0.0" targetFramework="net452" />
|
||||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
|
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
|
||||||
|
"contentVersion": "1.0.0.0",
|
||||||
|
"metadata": {
|
||||||
|
"_dependencyType": "appService.windows"
|
||||||
|
},
|
||||||
|
"parameters": {
|
||||||
|
"resourceGroupName": {
|
||||||
|
"type": "string",
|
||||||
|
"defaultValue": "stef-ResourceGroup-WestEuropa",
|
||||||
|
"metadata": {
|
||||||
|
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"resourceGroupLocation": {
|
||||||
|
"type": "string",
|
||||||
|
"defaultValue": "westeurope",
|
||||||
|
"metadata": {
|
||||||
|
"description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"resourceName": {
|
||||||
|
"type": "string",
|
||||||
|
"defaultValue": "WireMockNetWebApplicationNETCore3",
|
||||||
|
"metadata": {
|
||||||
|
"description": "Name of the main resource to be created by this template."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"resourceLocation": {
|
||||||
|
"type": "string",
|
||||||
|
"defaultValue": "[parameters('resourceGroupLocation')]",
|
||||||
|
"metadata": {
|
||||||
|
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"variables": {
|
||||||
|
"appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
|
||||||
|
"appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]"
|
||||||
|
},
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"type": "Microsoft.Resources/resourceGroups",
|
||||||
|
"name": "[parameters('resourceGroupName')]",
|
||||||
|
"location": "[parameters('resourceGroupLocation')]",
|
||||||
|
"apiVersion": "2019-10-01"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Microsoft.Resources/deployments",
|
||||||
|
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
|
||||||
|
"resourceGroup": "[parameters('resourceGroupName')]",
|
||||||
|
"apiVersion": "2019-10-01",
|
||||||
|
"dependsOn": [
|
||||||
|
"[parameters('resourceGroupName')]"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"mode": "Incremental",
|
||||||
|
"template": {
|
||||||
|
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||||
|
"contentVersion": "1.0.0.0",
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"location": "[parameters('resourceLocation')]",
|
||||||
|
"name": "[parameters('resourceName')]",
|
||||||
|
"type": "Microsoft.Web/sites",
|
||||||
|
"apiVersion": "2015-08-01",
|
||||||
|
"tags": {
|
||||||
|
"[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
|
||||||
|
},
|
||||||
|
"dependsOn": [
|
||||||
|
"[variables('appServicePlan_ResourceId')]"
|
||||||
|
],
|
||||||
|
"kind": "app",
|
||||||
|
"properties": {
|
||||||
|
"name": "[parameters('resourceName')]",
|
||||||
|
"kind": "app",
|
||||||
|
"httpsOnly": true,
|
||||||
|
"reserved": false,
|
||||||
|
"serverFarmId": "[variables('appServicePlan_ResourceId')]",
|
||||||
|
"siteConfig": {
|
||||||
|
"metadata": [
|
||||||
|
{
|
||||||
|
"name": "CURRENT_STACK",
|
||||||
|
"value": "dotnetcore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"identity": {
|
||||||
|
"type": "SystemAssigned"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"location": "[parameters('resourceLocation')]",
|
||||||
|
"name": "[variables('appServicePlan_name')]",
|
||||||
|
"type": "Microsoft.Web/serverFarms",
|
||||||
|
"apiVersion": "2015-08-01",
|
||||||
|
"sku": {
|
||||||
|
"name": "S1",
|
||||||
|
"tier": "Standard",
|
||||||
|
"family": "S",
|
||||||
|
"size": "S1"
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"name": "[variables('appServicePlan_name')]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,32 +1,29 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
|
||||||
<StartupObject>WireMock.Net.WebApplication.Program</StartupObject>
|
<StartupObject>WireMock.Net.WebApplication.Program</StartupObject>
|
||||||
<AssemblyName>WireMock.Net.WebApplication</AssemblyName>
|
<AssemblyName>WireMock.Net.WebApplication</AssemblyName>
|
||||||
<RootNamespace>WireMock.Net.WebApplication</RootNamespace>
|
<RootNamespace>WireMock.Net.WebApplication</RootNamespace>
|
||||||
<UserSecretsId>efcf4a18-fd7c-4622-1111-336d65290599</UserSecretsId>
|
<UserSecretsId>efcf4a18-fd7c-4622-1111-336d65290599</UserSecretsId>
|
||||||
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
|
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!--<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />-->
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.8" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.8" />
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
<ItemGroup>
|
||||||
</ItemGroup>
|
<Content Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
<ItemGroup>
|
</Content>
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
</ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Content Update="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using WireMock.Types;
|
||||||
|
|
||||||
namespace WireMock.Admin.Mappings
|
namespace WireMock.Admin.Mappings
|
||||||
{
|
{
|
||||||
@@ -53,10 +54,15 @@ namespace WireMock.Admin.Mappings
|
|||||||
public EncodingModel BodyEncoding { get; set; }
|
public EncodingModel BodyEncoding { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use Handlebars transformer.
|
/// Use ResponseMessage Transformer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool? UseTransformer { get; set; }
|
public bool? UseTransformer { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the type of the transformer.
|
||||||
|
/// </summary>
|
||||||
|
public string TransformerType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use the Handlerbars transformer for the content from the referenced BodyAsFile.
|
/// Use the Handlerbars transformer for the content from the referenced BodyAsFile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
23
src/WireMock.Net.Abstractions/Types/TransformerType.cs
Normal file
23
src/WireMock.Net.Abstractions/Types/TransformerType.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
namespace WireMock.Types
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The ResponseMessage Transformers
|
||||||
|
/// </summary>
|
||||||
|
public enum TransformerType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// https://github.com/Handlebars-Net/Handlebars.Net
|
||||||
|
/// </summary>
|
||||||
|
Handlebars,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// https://github.com/scriban/scriban : default
|
||||||
|
/// </summary>
|
||||||
|
Scriban,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// https://github.com/scriban/scriban : DotLiquid
|
||||||
|
/// </summary>
|
||||||
|
ScribanDotLiquid
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using WireMock.Exceptions;
|
using WireMock.Exceptions;
|
||||||
@@ -10,14 +12,12 @@ namespace WireMock.Matchers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// CSharpCode / CS-Script Matcher
|
/// CSharpCode / CS-Script Matcher
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <inheritdoc cref="IObjectMatcher"/>
|
/// <inheritdoc cref="ICSharpCodeMatcher"/>
|
||||||
/// <inheritdoc cref="IStringMatcher"/>
|
internal class CSharpCodeMatcher : ICSharpCodeMatcher
|
||||||
[Obsolete("This class will be moved to a separate NuGet package 'WireMock.Net.Matchers.CSharpCode'")]
|
|
||||||
internal class CSharpCodeMatcher : IObjectMatcher, IStringMatcher
|
|
||||||
{
|
{
|
||||||
private const string TemplateForIsMatchWithString = "{0} public class CodeHelper {{ public bool IsMatch(string it) {{ {1} }} }}";
|
private const string TemplateForIsMatchWithString = "public class CodeHelper {{ public bool IsMatch(string it) {{ {0} }} }}";
|
||||||
|
|
||||||
private const string TemplateForIsMatchWithDynamic = "{0} public class CodeHelper {{ public bool IsMatch(dynamic it) {{ {1} }} }}";
|
private const string TemplateForIsMatchWithDynamic = "public class CodeHelper {{ public bool IsMatch(dynamic it) {{ {0} }} }}";
|
||||||
|
|
||||||
private readonly string[] _usings =
|
private readonly string[] _usings =
|
||||||
{
|
{
|
||||||
@@ -153,11 +153,19 @@ namespace WireMock.Matchers
|
|||||||
}
|
}
|
||||||
|
|
||||||
#elif (NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP3_1 || NET5_0)
|
#elif (NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP3_1 || NET5_0)
|
||||||
|
Assembly assembly;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
assembly = CSScriptLib.CSScript.Evaluator.CompileCode(source);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new WireMockException($"CSharpCodeMatcher: Unable to compile code `{source}` for WireMock.CodeHelper", ex);
|
||||||
|
}
|
||||||
|
|
||||||
dynamic script;
|
dynamic script;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var assembly = CSScriptLib.CSScript.Evaluator.CompileCode(source);
|
|
||||||
|
|
||||||
#if NETSTANDARD2_0
|
#if NETSTANDARD2_0
|
||||||
script = csscript.GenericExtensions.CreateObject(assembly, "*");
|
script = csscript.GenericExtensions.CreateObject(assembly, "*");
|
||||||
#else
|
#else
|
||||||
@@ -166,7 +174,7 @@ namespace WireMock.Matchers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new WireMockException("CSharpCodeMatcher: Unable to compile code for WireMock.CodeHelper", ex);
|
throw new WireMockException("CSharpCodeMatcher: Unable to create object from assembly", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -178,7 +186,7 @@ namespace WireMock.Matchers
|
|||||||
throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper", ex);
|
throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper", ex);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
throw new NotSupportedException("The 'CSharpCodeMatcher' cannot be used in netstandard 1.3");
|
throw new NotSupportedException("The 'CSharpCodeMatcher' cannot be used in netstandard 1.3");
|
||||||
#endif
|
#endif
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -193,7 +201,16 @@ namespace WireMock.Matchers
|
|||||||
private string GetSourceForIsMatchWithString(string pattern, bool isMatchWithString)
|
private string GetSourceForIsMatchWithString(string pattern, bool isMatchWithString)
|
||||||
{
|
{
|
||||||
string template = isMatchWithString ? TemplateForIsMatchWithString : TemplateForIsMatchWithDynamic;
|
string template = isMatchWithString ? TemplateForIsMatchWithString : TemplateForIsMatchWithDynamic;
|
||||||
return string.Format(template, string.Join(Environment.NewLine, _usings.Select(u => $"using {u};")), pattern);
|
|
||||||
|
var stringBuilder = new StringBuilder();
|
||||||
|
foreach (string @using in _usings)
|
||||||
|
{
|
||||||
|
stringBuilder.AppendLine($"using {@using};");
|
||||||
|
}
|
||||||
|
stringBuilder.AppendLine();
|
||||||
|
stringBuilder.AppendFormat(template, pattern);
|
||||||
|
|
||||||
|
return stringBuilder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IStringMatcher.GetPatterns"/>
|
/// <inheritdoc cref="IStringMatcher.GetPatterns"/>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
[assembly: InternalsVisibleTo("WireMock.Net.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e138ec44d93acac565953052636eb8d5e7e9f27ddb030590055cd1a0ab2069a5623f1f77ca907d78e0b37066ca0f6d63da7eecc3fcb65b76aa8ebeccf7ebe1d11264b8404cd9b1cbbf2c83f566e033b3e54129f6ef28daffff776ba7aebbc53c0d635ebad8f45f78eb3f7e0459023c218f003416e080f96a1a3c5ffeb56bee9e")]
|
||||||
|
|
||||||
|
// Needed for Moq in the UnitTest project
|
||||||
|
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Description>A CSharpCodeMatcher which can be used to match WireMock.Net Requests using C# code.</Description>
|
||||||
|
<AssemblyTitle>WireMock.Net.Matchers.CSharpCode</AssemblyTitle>
|
||||||
|
<Authors>Stef Heyenrath</Authors>
|
||||||
|
<TargetFrameworks>net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<PackageTags>wiremock;matchers;matcher;csharp;csharpcode</PackageTags>
|
||||||
|
<RootNamespace>WireMock</RootNamespace>
|
||||||
|
<ProjectGuid>{B6269AAC-170A-4346-8B9A-444DED3D9A44}</ProjectGuid>
|
||||||
|
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||||
|
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||||
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
||||||
|
<CodeAnalysisRuleSet>../WireMock.Net/WireMock.Net.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<SignAssembly>true</SignAssembly>
|
||||||
|
<AssemblyOriginatorKeyFile>../WireMock.Net/WireMock.Net.snk</AssemblyOriginatorKeyFile>
|
||||||
|
<!--<DelaySign>true</DelaySign>-->
|
||||||
|
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
|
||||||
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- https://github.com/aspnet/RoslynCodeDomProvider/issues/51 -->
|
||||||
|
<!-- This is needed else we cannot build net452 in Azure DevOps Pipeline -->
|
||||||
|
<Target Name="CheckIfShouldKillVBCSCompiler" />
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||||
|
|
||||||
|
<ProjectReference Include="..\WireMock.Net\WireMock.Net.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'net452' ">
|
||||||
|
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="3.6.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' or '$(TargetFramework)' == 'net461' ">
|
||||||
|
<PackageReference Include="CS-Script" Version="3.30.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
|
||||||
|
<PackageReference Include="CS-Script.Core" Version="1.1.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1'">
|
||||||
|
<PackageReference Include="CS-Script.Core" Version="1.4.2-preview" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0'">
|
||||||
|
<PackageReference Include="CS-Script.Core" Version="1.4.2-preview" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -19,7 +19,7 @@ namespace WireMock.Http
|
|||||||
Connection,
|
Connection,
|
||||||
ContentLength,
|
ContentLength,
|
||||||
ContentType,
|
ContentType,
|
||||||
Date,
|
Date, // RFC1123Pattern
|
||||||
Expect,
|
Expect,
|
||||||
Host,
|
Host,
|
||||||
IfModifiedSince,
|
IfModifiedSince,
|
||||||
|
|||||||
11
src/WireMock.Net/Matchers/ICSharpCodeMatcher.cs
Normal file
11
src/WireMock.Net/Matchers/ICSharpCodeMatcher.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace WireMock.Matchers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// CSharpCode / CS-Script Matcher
|
||||||
|
/// </summary>
|
||||||
|
/// <inheritdoc cref="IObjectMatcher"/>
|
||||||
|
/// <inheritdoc cref="IStringMatcher"/>
|
||||||
|
public interface ICSharpCodeMatcher : IObjectMatcher, IStringMatcher
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -150,28 +151,44 @@ namespace WireMock.Owin.Mappers
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetResponseHeaders(ResponseMessage responseMessage, IResponse response)
|
private static void SetResponseHeaders(ResponseMessage responseMessage, IResponse response)
|
||||||
{
|
{
|
||||||
// Set headers
|
// Force setting the Date header (#577)
|
||||||
foreach (var pair in responseMessage.Headers)
|
AppendResponseHeader(
|
||||||
{
|
response,
|
||||||
if (ResponseHeadersToFix.ContainsKey(pair.Key))
|
HttpKnownHeaderNames.Date,
|
||||||
|
new[]
|
||||||
{
|
{
|
||||||
ResponseHeadersToFix[pair.Key]?.Invoke(response, pair.Value);
|
DateTime.UtcNow.ToString(CultureInfo.InvariantCulture.DateTimeFormat.RFC1123Pattern, CultureInfo.InvariantCulture)
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set other headers
|
||||||
|
foreach (var item in responseMessage.Headers)
|
||||||
|
{
|
||||||
|
var headerName = item.Key;
|
||||||
|
var value = item.Value;
|
||||||
|
if (ResponseHeadersToFix.ContainsKey(headerName))
|
||||||
|
{
|
||||||
|
ResponseHeadersToFix[headerName]?.Invoke(response, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check if this response header can be added (#148 and #227)
|
// Check if this response header can be added (#148 and #227)
|
||||||
if (!HttpKnownHeaderNames.IsRestrictedResponseHeader(pair.Key))
|
if (!HttpKnownHeaderNames.IsRestrictedResponseHeader(headerName))
|
||||||
{
|
{
|
||||||
#if !USE_ASPNETCORE
|
AppendResponseHeader(response, headerName, value.ToArray());
|
||||||
response.Headers.AppendValues(pair.Key, pair.Value.ToArray());
|
|
||||||
#else
|
|
||||||
response.Headers.Append(pair.Key, pair.Value.ToArray());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void AppendResponseHeader(IResponse response, string headerName, string[] values)
|
||||||
|
{
|
||||||
|
#if !USE_ASPNETCORE
|
||||||
|
response.Headers.AppendValues(headerName, values);
|
||||||
|
#else
|
||||||
|
response.Headers.Append(headerName, values);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,18 +132,21 @@ namespace WireMock.Owin
|
|||||||
|
|
||||||
var responseBuilder = targetMapping.Provider as Response;
|
var responseBuilder = targetMapping.Provider as Response;
|
||||||
|
|
||||||
if (responseBuilder?.ProxyAndRecordSettings?.SaveMapping == true || targetMapping?.Settings?.ProxyAndRecordSettings?.SaveMapping == true)
|
if (!targetMapping.IsAdminInterface)
|
||||||
{
|
{
|
||||||
_options.Mappings.TryAdd(targetMapping.Guid, targetMapping);
|
if (responseBuilder?.ProxyAndRecordSettings?.SaveMapping == true || targetMapping?.Settings?.ProxyAndRecordSettings?.SaveMapping == true)
|
||||||
}
|
{
|
||||||
|
_options.Mappings.TryAdd(targetMapping.Guid, targetMapping);
|
||||||
|
}
|
||||||
|
|
||||||
if (responseBuilder?.ProxyAndRecordSettings?.SaveMappingToFile == true || targetMapping?.Settings?.ProxyAndRecordSettings?.SaveMappingToFile == true)
|
if (responseBuilder?.ProxyAndRecordSettings?.SaveMappingToFile == true || targetMapping?.Settings?.ProxyAndRecordSettings?.SaveMappingToFile == true)
|
||||||
{
|
{
|
||||||
var matcherMapper = new MatcherMapper(targetMapping.Settings);
|
var matcherMapper = new MatcherMapper(targetMapping.Settings);
|
||||||
var mappingConverter = new MappingConverter(matcherMapper);
|
var mappingConverter = new MappingConverter(matcherMapper);
|
||||||
var mappingToFileSaver = new MappingToFileSaver(targetMapping.Settings, mappingConverter);
|
var mappingToFileSaver = new MappingToFileSaver(targetMapping.Settings, mappingConverter);
|
||||||
|
|
||||||
mappingToFileSaver.SaveMappingToFile(targetMapping);
|
mappingToFileSaver.SaveMappingToFile(targetMapping);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetMapping.Scenario != null)
|
if (targetMapping.Scenario != null)
|
||||||
|
|||||||
57
src/WireMock.Net/Plugin/PluginLoader.cs
Normal file
57
src/WireMock.Net/Plugin/PluginLoader.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace WireMock.Plugin
|
||||||
|
{
|
||||||
|
internal static class PluginLoader
|
||||||
|
{
|
||||||
|
private static readonly ConcurrentDictionary<Type, Type> Assemblies = new ConcurrentDictionary<Type, Type>();
|
||||||
|
|
||||||
|
public static T Load<T>(params object[] args) where T : class
|
||||||
|
{
|
||||||
|
var foundType = Assemblies.GetOrAdd(typeof(T), (type) =>
|
||||||
|
{
|
||||||
|
var files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll");
|
||||||
|
|
||||||
|
Type pluginType = null;
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var assembly = Assembly.Load(new AssemblyName
|
||||||
|
{
|
||||||
|
Name = Path.GetFileNameWithoutExtension(file)
|
||||||
|
});
|
||||||
|
|
||||||
|
pluginType = GetImplementationTypeByInterface<T>(assembly);
|
||||||
|
if (pluginType != null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// no-op: just try next .dll
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pluginType != null)
|
||||||
|
{
|
||||||
|
return pluginType;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new DllNotFoundException($"No dll found which implements type '{type}'");
|
||||||
|
});
|
||||||
|
|
||||||
|
return (T)Activator.CreateInstance(foundType, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Type GetImplementationTypeByInterface<T>(Assembly assembly)
|
||||||
|
{
|
||||||
|
return assembly.GetTypes().FirstOrDefault(t => typeof(T).IsAssignableFrom(t) && !t.GetTypeInfo().IsInterface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
[assembly: InternalsVisibleTo("WireMock.Net.Matchers.CSharpCode, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e138ec44d93acac565953052636eb8d5e7e9f27ddb030590055cd1a0ab2069a5623f1f77ca907d78e0b37066ca0f6d63da7eecc3fcb65b76aa8ebeccf7ebe1d11264b8404cd9b1cbbf2c83f566e033b3e54129f6ef28daffff776ba7aebbc53c0d635ebad8f45f78eb3f7e0459023c218f003416e080f96a1a3c5ffeb56bee9e")]
|
||||||
[assembly: InternalsVisibleTo("WireMock.Net.StandAlone, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e138ec44d93acac565953052636eb8d5e7e9f27ddb030590055cd1a0ab2069a5623f1f77ca907d78e0b37066ca0f6d63da7eecc3fcb65b76aa8ebeccf7ebe1d11264b8404cd9b1cbbf2c83f566e033b3e54129f6ef28daffff776ba7aebbc53c0d635ebad8f45f78eb3f7e0459023c218f003416e080f96a1a3c5ffeb56bee9e")]
|
[assembly: InternalsVisibleTo("WireMock.Net.StandAlone, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e138ec44d93acac565953052636eb8d5e7e9f27ddb030590055cd1a0ab2069a5623f1f77ca907d78e0b37066ca0f6d63da7eecc3fcb65b76aa8ebeccf7ebe1d11264b8404cd9b1cbbf2c83f566e033b3e54129f6ef28daffff776ba7aebbc53c0d635ebad8f45f78eb3f7e0459023c218f003416e080f96a1a3c5ffeb56bee9e")]
|
||||||
[assembly: InternalsVisibleTo("WireMock.Net.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e138ec44d93acac565953052636eb8d5e7e9f27ddb030590055cd1a0ab2069a5623f1f77ca907d78e0b37066ca0f6d63da7eecc3fcb65b76aa8ebeccf7ebe1d11264b8404cd9b1cbbf2c83f566e033b3e54129f6ef28daffff776ba7aebbc53c0d635ebad8f45f78eb3f7e0459023c218f003416e080f96a1a3c5ffeb56bee9e")]
|
[assembly: InternalsVisibleTo("WireMock.Net.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e138ec44d93acac565953052636eb8d5e7e9f27ddb030590055cd1a0ab2069a5623f1f77ca907d78e0b37066ca0f6d63da7eecc3fcb65b76aa8ebeccf7ebe1d11264b8404cd9b1cbbf2c83f566e033b3e54129f6ef28daffff776ba7aebbc53c0d635ebad8f45f78eb3f7e0459023c218f003416e080f96a1a3c5ffeb56bee9e")]
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using WireMock.ResponseBuilders;
|
|||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
using WireMock.Types;
|
using WireMock.Types;
|
||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
|
using WireMock.Validation;
|
||||||
|
|
||||||
namespace WireMock.Proxy
|
namespace WireMock.Proxy
|
||||||
{
|
{
|
||||||
@@ -21,7 +22,7 @@ namespace WireMock.Proxy
|
|||||||
|
|
||||||
public ProxyHelper([NotNull] IWireMockServerSettings settings)
|
public ProxyHelper([NotNull] IWireMockServerSettings settings)
|
||||||
{
|
{
|
||||||
Guard.NotNull(settings, nameof(settings));
|
Check.NotNull(settings, nameof(settings));
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,9 +32,9 @@ namespace WireMock.Proxy
|
|||||||
[NotNull] RequestMessage requestMessage,
|
[NotNull] RequestMessage requestMessage,
|
||||||
[NotNull] string url)
|
[NotNull] string url)
|
||||||
{
|
{
|
||||||
Guard.NotNull(client, nameof(client));
|
Check.NotNull(client, nameof(client));
|
||||||
Guard.NotNull(requestMessage, nameof(requestMessage));
|
Check.NotNull(requestMessage, nameof(requestMessage));
|
||||||
Guard.NotNull(url, nameof(url));
|
Check.NotNull(url, nameof(url));
|
||||||
|
|
||||||
var originalUri = new Uri(requestMessage.Url);
|
var originalUri = new Uri(requestMessage.Url);
|
||||||
var requiredUri = new Uri(url);
|
var requiredUri = new Uri(url);
|
||||||
|
|||||||
@@ -55,6 +55,16 @@ namespace WireMock.RequestBuilders
|
|||||||
return _requestMatchers.OfType<T>().FirstOrDefault();
|
return _requestMatchers.OfType<T>().FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the request message matcher.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type of IRequestMatcher</typeparam>
|
||||||
|
/// <returns>A RequestMatcher</returns>
|
||||||
|
public T GetRequestMessageMatcher<T>(Func<T, bool> func) where T : IRequestMatcher
|
||||||
|
{
|
||||||
|
return _requestMatchers.OfType<T>().FirstOrDefault(func);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IClientIPRequestBuilder.WithClientIP(IStringMatcher[])"/>
|
/// <inheritdoc cref="IClientIPRequestBuilder.WithClientIP(IStringMatcher[])"/>
|
||||||
public IRequestBuilder WithClientIP(params IStringMatcher[] matchers)
|
public IRequestBuilder WithClientIP(params IStringMatcher[] matchers)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace WireMock.ResponseBuilders
|
using WireMock.Types;
|
||||||
|
|
||||||
|
namespace WireMock.ResponseBuilders
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The TransformResponseBuilder interface.
|
/// The TransformResponseBuilder interface.
|
||||||
@@ -6,11 +8,19 @@
|
|||||||
public interface ITransformResponseBuilder : IDelayResponseBuilder
|
public interface ITransformResponseBuilder : IDelayResponseBuilder
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The with transformer.
|
/// Use the Handlebars.Net ResponseMessage transformer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// The <see cref="IResponseBuilder"/>.
|
/// The <see cref="IResponseBuilder"/>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
IResponseBuilder WithTransformer(bool transformContentFromBodyAsFile = false);
|
IResponseBuilder WithTransformer(bool transformContentFromBodyAsFile = false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use a specific ResponseMessage transformer.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// The <see cref="IResponseBuilder"/>.
|
||||||
|
/// </returns>
|
||||||
|
IResponseBuilder WithTransformer(TransformerType transformerType, bool transformContentFromBodyAsFile = false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,8 @@ using WireMock.Proxy;
|
|||||||
using WireMock.ResponseProviders;
|
using WireMock.ResponseProviders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
using WireMock.Transformers;
|
using WireMock.Transformers;
|
||||||
|
using WireMock.Transformers.Handlebars;
|
||||||
|
using WireMock.Transformers.Scriban;
|
||||||
using WireMock.Types;
|
using WireMock.Types;
|
||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
using WireMock.Validation;
|
using WireMock.Validation;
|
||||||
@@ -32,6 +34,11 @@ namespace WireMock.ResponseBuilders
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseTransformer { get; private set; }
|
public bool UseTransformer { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the type of the transformer.
|
||||||
|
/// </summary>
|
||||||
|
public TransformerType TransformerType { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether to use the Handlerbars transformer for the content from the referenced BodyAsFile.
|
/// Gets a value indicating whether to use the Handlerbars transformer for the content from the referenced BodyAsFile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -282,6 +289,16 @@ namespace WireMock.ResponseBuilders
|
|||||||
public IResponseBuilder WithTransformer(bool transformContentFromBodyAsFile = false)
|
public IResponseBuilder WithTransformer(bool transformContentFromBodyAsFile = false)
|
||||||
{
|
{
|
||||||
UseTransformer = true;
|
UseTransformer = true;
|
||||||
|
TransformerType = TransformerType.Handlebars;
|
||||||
|
UseTransformerForBodyAsFile = transformContentFromBodyAsFile;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ITransformResponseBuilder.WithTransformer(TransformerType, bool)"/>
|
||||||
|
public IResponseBuilder WithTransformer(TransformerType transformerType, bool transformContentFromBodyAsFile = false)
|
||||||
|
{
|
||||||
|
UseTransformer = true;
|
||||||
|
TransformerType = transformerType;
|
||||||
UseTransformerForBodyAsFile = transformContentFromBodyAsFile;
|
UseTransformerForBodyAsFile = transformContentFromBodyAsFile;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -328,7 +345,7 @@ namespace WireMock.ResponseBuilders
|
|||||||
|
|
||||||
var proxyHelper = new ProxyHelper(settings);
|
var proxyHelper = new ProxyHelper(settings);
|
||||||
|
|
||||||
var (proxyResponseMessage, mapping) = await proxyHelper.SendAsync(
|
var (proxyResponseMessage, _) = await proxyHelper.SendAsync(
|
||||||
ProxyAndRecordSettings,
|
ProxyAndRecordSettings,
|
||||||
_httpClientForProxy,
|
_httpClientForProxy,
|
||||||
requestMessage,
|
requestMessage,
|
||||||
@@ -369,8 +386,24 @@ namespace WireMock.ResponseBuilders
|
|||||||
|
|
||||||
if (UseTransformer)
|
if (UseTransformer)
|
||||||
{
|
{
|
||||||
var factory = new HandlebarsContextFactory(settings.FileSystemHandler, settings.HandlebarsRegistrationCallback);
|
ITransformer responseMessageTransformer;
|
||||||
var responseMessageTransformer = new ResponseMessageTransformer(factory);
|
switch (TransformerType)
|
||||||
|
{
|
||||||
|
case TransformerType.Handlebars:
|
||||||
|
var factoryHandlebars = new HandlebarsContextFactory(settings.FileSystemHandler, settings.HandlebarsRegistrationCallback);
|
||||||
|
responseMessageTransformer = new Transformer(factoryHandlebars);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TransformerType.Scriban:
|
||||||
|
case TransformerType.ScribanDotLiquid:
|
||||||
|
var factoryDotLiquid = new ScribanContextFactory(settings.FileSystemHandler, TransformerType);
|
||||||
|
responseMessageTransformer = new Transformer(factoryDotLiquid);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new NotImplementedException($"TransformerType '{TransformerType}' is not supported.");
|
||||||
|
}
|
||||||
|
|
||||||
return responseMessageTransformer.Transform(requestMessage, responseMessage, UseTransformerForBodyAsFile);
|
return responseMessageTransformer.Transform(requestMessage, responseMessage, UseTransformerForBodyAsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ namespace WireMock.Serialization
|
|||||||
mappingModel.Response.BodyAsFile = null;
|
mappingModel.Response.BodyAsFile = null;
|
||||||
mappingModel.Response.BodyAsFileIsCached = null;
|
mappingModel.Response.BodyAsFileIsCached = null;
|
||||||
mappingModel.Response.UseTransformer = null;
|
mappingModel.Response.UseTransformer = null;
|
||||||
|
mappingModel.Response.TransformerType = null;
|
||||||
mappingModel.Response.UseTransformerForBodyAsFile = null;
|
mappingModel.Response.UseTransformerForBodyAsFile = null;
|
||||||
mappingModel.Response.BodyEncoding = null;
|
mappingModel.Response.BodyEncoding = null;
|
||||||
mappingModel.Response.ProxyUrl = response.ProxyAndRecordSettings.Url;
|
mappingModel.Response.ProxyUrl = response.ProxyAndRecordSettings.Url;
|
||||||
@@ -133,6 +134,7 @@ namespace WireMock.Serialization
|
|||||||
if (response.UseTransformer)
|
if (response.UseTransformer)
|
||||||
{
|
{
|
||||||
mappingModel.Response.UseTransformer = response.UseTransformer;
|
mappingModel.Response.UseTransformer = response.UseTransformer;
|
||||||
|
mappingModel.Response.TransformerType = response.TransformerType.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.UseTransformerForBodyAsFile)
|
if (response.UseTransformerForBodyAsFile)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using JetBrains.Annotations;
|
|||||||
using SimMetrics.Net;
|
using SimMetrics.Net;
|
||||||
using WireMock.Admin.Mappings;
|
using WireMock.Admin.Mappings;
|
||||||
using WireMock.Matchers;
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Plugin;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
using WireMock.Validation;
|
using WireMock.Validation;
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ namespace WireMock.Serialization
|
|||||||
case "CSharpCodeMatcher":
|
case "CSharpCodeMatcher":
|
||||||
if (_settings.AllowCSharpCodeMatcher == true)
|
if (_settings.AllowCSharpCodeMatcher == true)
|
||||||
{
|
{
|
||||||
return new CSharpCodeMatcher(matchBehaviour, stringPatterns);
|
return PluginLoader.Load<ICSharpCodeMatcher>(matchBehaviour, stringPatterns);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NotSupportedException("It's not allowed to use the 'CSharpCodeMatcher' because IWireMockServerSettings.AllowCSharpCodeMatcher is not set to 'true'.");
|
throw new NotSupportedException("It's not allowed to use the 'CSharpCodeMatcher' because IWireMockServerSettings.AllowCSharpCodeMatcher is not set to 'true'.");
|
||||||
|
|||||||
@@ -261,14 +261,17 @@ namespace WireMock.Server
|
|||||||
proxyUriWithRequestPathAndQuery.AbsoluteUri
|
proxyUriWithRequestPathAndQuery.AbsoluteUri
|
||||||
);
|
);
|
||||||
|
|
||||||
if (settings.ProxyAndRecordSettings.SaveMapping)
|
if (mapping != null)
|
||||||
{
|
{
|
||||||
_options.Mappings.TryAdd(mapping.Guid, mapping);
|
if (settings.ProxyAndRecordSettings.SaveMapping)
|
||||||
}
|
{
|
||||||
|
_options.Mappings.TryAdd(mapping.Guid, mapping);
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.ProxyAndRecordSettings.SaveMappingToFile)
|
if (settings.ProxyAndRecordSettings.SaveMappingToFile)
|
||||||
{
|
{
|
||||||
_mappingToFileSaver.SaveMappingToFile(mapping);
|
_mappingToFileSaver.SaveMappingToFile(mapping);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return responseMessage;
|
return responseMessage;
|
||||||
@@ -770,7 +773,11 @@ namespace WireMock.Server
|
|||||||
|
|
||||||
if (responseModel.UseTransformer == true)
|
if (responseModel.UseTransformer == true)
|
||||||
{
|
{
|
||||||
responseBuilder = responseBuilder.WithTransformer(responseModel.UseTransformerForBodyAsFile == true);
|
if (!Enum.TryParse<TransformerType>(responseModel.TransformerType, out var transformerType))
|
||||||
|
{
|
||||||
|
transformerType = TransformerType.Handlebars;
|
||||||
|
}
|
||||||
|
responseBuilder = responseBuilder.WithTransformer(transformerType, responseModel.UseTransformerForBodyAsFile == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(responseModel.ProxyUrl))
|
if (!string.IsNullOrEmpty(responseModel.ProxyUrl))
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace WireMock.Settings
|
|||||||
string SaveMappingForStatusCodePattern { get; set; }
|
string SaveMappingForStatusCodePattern { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Save the mapping for each request/response also to a file. (Note that SaveMapping must also be set to true.)
|
/// Save the mapping for each request/response to a .json mapping file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool SaveMappingToFile { get; set; }
|
bool SaveMappingToFile { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
using HandlebarsDotNet;
|
|
||||||
using System;
|
|
||||||
using WireMock.Handlers;
|
|
||||||
using WireMock.Validation;
|
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
internal static class HandlebarsFile
|
|
||||||
{
|
|
||||||
public static void Register(IHandlebars handlebarsContext, IFileSystemHandler fileSystemHandler)
|
|
||||||
{
|
|
||||||
handlebarsContext.RegisterHelper("File", (writer, context, arguments) =>
|
|
||||||
{
|
|
||||||
string value = ParseArgumentAndReadFileFragment(handlebarsContext, context, fileSystemHandler, arguments);
|
|
||||||
writer.Write(value);
|
|
||||||
});
|
|
||||||
|
|
||||||
handlebarsContext.RegisterHelper("File", (writer, options, context, arguments) =>
|
|
||||||
{
|
|
||||||
string value = ParseArgumentAndReadFileFragment(handlebarsContext, context, fileSystemHandler, arguments);
|
|
||||||
options.Template(writer, value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string ParseArgumentAndReadFileFragment(IHandlebars handlebarsContext, dynamic context, IFileSystemHandler fileSystemHandler, object[] arguments)
|
|
||||||
{
|
|
||||||
Check.Condition(arguments, args => args.Length == 1, nameof(arguments));
|
|
||||||
Check.NotNull(arguments[0], "arguments[0]");
|
|
||||||
|
|
||||||
switch (arguments[0])
|
|
||||||
{
|
|
||||||
case string path:
|
|
||||||
var templateFunc = handlebarsContext.Compile(path);
|
|
||||||
string transformed = templateFunc(context);
|
|
||||||
return fileSystemHandler.ReadResponseBodyAsString(transformed);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new NotSupportedException($"The value '{arguments[0]}' with type '{arguments[0]?.GetType()}' cannot be used in Handlebars File.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
using HandlebarsDotNet;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Linq;
|
|
||||||
using WireMock.Util;
|
|
||||||
using WireMock.Validation;
|
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
internal static class HandlebarsJsonPath
|
|
||||||
{
|
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
|
||||||
{
|
|
||||||
handlebarsContext.RegisterHelper("JsonPath.SelectToken", (writer, context, arguments) =>
|
|
||||||
{
|
|
||||||
(JToken valueToProcess, string jsonPath) = ParseArguments(arguments);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var result = valueToProcess.SelectToken(jsonPath);
|
|
||||||
writer.WriteSafeString(result);
|
|
||||||
}
|
|
||||||
catch (JsonException)
|
|
||||||
{
|
|
||||||
// Ignore JsonException
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
handlebarsContext.RegisterHelper("JsonPath.SelectTokens", (writer, options, context, arguments) =>
|
|
||||||
{
|
|
||||||
(JToken valueToProcess, string jsonPath) = ParseArguments(arguments);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var values = valueToProcess.SelectTokens(jsonPath);
|
|
||||||
if (values != null)
|
|
||||||
{
|
|
||||||
options.Template(writer, values.ToDictionary(value => value.Path, value => value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (JsonException)
|
|
||||||
{
|
|
||||||
// Ignore JsonException
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static (JToken valueToProcess, string jsonpath) ParseArguments(object[] arguments)
|
|
||||||
{
|
|
||||||
Check.Condition(arguments, args => args.Length == 2, nameof(arguments));
|
|
||||||
Check.NotNull(arguments[0], "arguments[0]");
|
|
||||||
Check.NotNullOrEmpty(arguments[1] as string, "arguments[1]");
|
|
||||||
|
|
||||||
JToken valueToProcess;
|
|
||||||
|
|
||||||
switch (arguments[0])
|
|
||||||
{
|
|
||||||
case JToken tokenValue:
|
|
||||||
valueToProcess = tokenValue;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case string stringValue:
|
|
||||||
valueToProcess = JsonUtils.Parse(stringValue);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IEnumerable enumerableValue:
|
|
||||||
valueToProcess = JArray.FromObject(enumerableValue);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new NotSupportedException($"The value '{arguments[0]}' with type '{arguments[0]?.GetType()}' cannot be used in Handlebars JsonPath.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (valueToProcess, (string)arguments[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Dynamic.Core;
|
|
||||||
using System.Linq.Dynamic.Core.Exceptions;
|
|
||||||
using HandlebarsDotNet;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using WireMock.Util;
|
|
||||||
using WireMock.Validation;
|
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
internal static class HandlebarsLinq
|
|
||||||
{
|
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
|
||||||
{
|
|
||||||
handlebarsContext.RegisterHelper("Linq", (writer, context, arguments) =>
|
|
||||||
{
|
|
||||||
(JToken valueToProcess, string linqStatement) = ParseArguments(arguments);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
object result = ExecuteDynamicLinq(valueToProcess, linqStatement);
|
|
||||||
writer.WriteSafeString(result);
|
|
||||||
}
|
|
||||||
catch (ParseException)
|
|
||||||
{
|
|
||||||
// Ignore ParseException
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
handlebarsContext.RegisterHelper("Linq", (writer, options, context, arguments) =>
|
|
||||||
{
|
|
||||||
(JToken valueToProcess, string linqStatement) = ParseArguments(arguments);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var result = ExecuteDynamicLinq(valueToProcess, linqStatement);
|
|
||||||
options.Template(writer, result);
|
|
||||||
}
|
|
||||||
catch (ParseException)
|
|
||||||
{
|
|
||||||
// Ignore ParseException
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static dynamic ExecuteDynamicLinq(JToken value, string linqStatement)
|
|
||||||
{
|
|
||||||
// Convert a single object to a Queryable JObject-list with 1 entry.
|
|
||||||
var queryable1 = new[] { value }.AsQueryable();
|
|
||||||
|
|
||||||
// Generate the DynamicLinq select statement.
|
|
||||||
string dynamicSelect = JsonUtils.GenerateDynamicLinqStatement(value);
|
|
||||||
|
|
||||||
// Execute DynamicLinq Select statement.
|
|
||||||
var queryable2 = queryable1.Select(dynamicSelect);
|
|
||||||
|
|
||||||
// Execute the Select(...) method and get first result with FirstOrDefault().
|
|
||||||
return queryable2.Select(linqStatement).FirstOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static (JToken valueToProcess, string linqStatement) ParseArguments(object[] arguments)
|
|
||||||
{
|
|
||||||
Check.Condition(arguments, args => args.Length == 2, nameof(arguments));
|
|
||||||
Check.NotNull(arguments[0], "arguments[0]");
|
|
||||||
Check.NotNullOrEmpty(arguments[1] as string, "arguments[1]");
|
|
||||||
|
|
||||||
JToken valueToProcess;
|
|
||||||
switch (arguments[0])
|
|
||||||
{
|
|
||||||
case string jsonAsString:
|
|
||||||
valueToProcess = new JValue(jsonAsString);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case JToken jsonAsJObject:
|
|
||||||
valueToProcess = jsonAsJObject;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new NotSupportedException($"The value '{arguments[0]}' with type '{arguments[0]?.GetType()}' cannot be used in Handlebars Linq.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (valueToProcess, (string) arguments[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
|
||||||
using HandlebarsDotNet;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using RandomDataGenerator.FieldOptions;
|
|
||||||
using RandomDataGenerator.Randomizers;
|
|
||||||
using WireMock.Validation;
|
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
internal static class HandlebarsRandom
|
|
||||||
{
|
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
|
||||||
{
|
|
||||||
handlebarsContext.RegisterHelper("Random", (writer, context, arguments) =>
|
|
||||||
{
|
|
||||||
object value = GetRandomValue(arguments);
|
|
||||||
writer.Write(value);
|
|
||||||
});
|
|
||||||
|
|
||||||
handlebarsContext.RegisterHelper("Random", (writer, options, context, arguments) =>
|
|
||||||
{
|
|
||||||
object value = GetRandomValue(arguments);
|
|
||||||
options.Template(writer, value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static object GetRandomValue(object[] arguments)
|
|
||||||
{
|
|
||||||
var fieldOptions = GetFieldOptionsFromArguments(arguments);
|
|
||||||
dynamic randomizer = RandomizerFactory.GetRandomizerAsDynamic(fieldOptions);
|
|
||||||
|
|
||||||
// Format DateTime as ISO 8601
|
|
||||||
if (fieldOptions is IFieldOptionsDateTime)
|
|
||||||
{
|
|
||||||
DateTime? date = randomizer.Generate();
|
|
||||||
return date?.ToString("s", CultureInfo.InvariantCulture);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the IFieldOptionsGuid defines Uppercase, use the 'GenerateAsString' method.
|
|
||||||
if (fieldOptions is IFieldOptionsGuid fieldOptionsGuid)
|
|
||||||
{
|
|
||||||
return fieldOptionsGuid.Uppercase ? randomizer.GenerateAsString() : randomizer.Generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
return randomizer.Generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static FieldOptionsAbstract GetFieldOptionsFromArguments(object[] arguments)
|
|
||||||
{
|
|
||||||
Check.Condition(arguments, args => args.Length > 0, nameof(arguments));
|
|
||||||
Check.NotNull(arguments[0], "arguments[0]");
|
|
||||||
|
|
||||||
var properties = (Dictionary<string, object>)arguments[0];
|
|
||||||
var newProperties = new Dictionary<string, object>();
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, object> property in properties.Where(p => p.Key != "Type"))
|
|
||||||
{
|
|
||||||
if (property.Value.GetType().Name == "UndefinedBindingResult")
|
|
||||||
{
|
|
||||||
if (TryParseSpecialValue(property.Value, out object parsedValue))
|
|
||||||
{
|
|
||||||
newProperties.Add(property.Key, parsedValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newProperties.Add(property.Key, property.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FieldOptionsFactory.GetFieldOptions((string)properties["Type"], newProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// In case it's an UndefinedBindingResult, just try to convert the value using Json
|
|
||||||
/// This logic adds functionality like parsing an array
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The property value</param>
|
|
||||||
/// <param name="parsedValue">The parsed value</param>
|
|
||||||
/// <returns>true in case parsing is ok, else false</returns>
|
|
||||||
private static bool TryParseSpecialValue(object value, out object parsedValue)
|
|
||||||
{
|
|
||||||
parsedValue = null;
|
|
||||||
string propertyValueAsString = value.ToString();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
JToken jToken = JToken.Parse(propertyValueAsString);
|
|
||||||
switch (jToken)
|
|
||||||
{
|
|
||||||
case JArray jTokenArray:
|
|
||||||
parsedValue = jTokenArray.ToObject<string[]>().ToList(); // Just convert to a String List to enable Random StringList
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return jToken.ToObject<dynamic>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (JsonException)
|
|
||||||
{
|
|
||||||
// Ignore and don't add this value
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using HandlebarsDotNet;
|
|
||||||
using WireMock.Util;
|
|
||||||
using WireMock.Validation;
|
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
internal static class HandlebarsRegex
|
|
||||||
{
|
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
|
||||||
{
|
|
||||||
handlebarsContext.RegisterHelper("Regex.Match", (writer, context, arguments) =>
|
|
||||||
{
|
|
||||||
(string stringToProcess, string regexPattern, object defaultValue) = ParseArguments(arguments);
|
|
||||||
|
|
||||||
Match match = Regex.Match(stringToProcess, regexPattern);
|
|
||||||
|
|
||||||
if (match.Success)
|
|
||||||
{
|
|
||||||
writer.WriteSafeString(match.Value);
|
|
||||||
}
|
|
||||||
else if (defaultValue != null)
|
|
||||||
{
|
|
||||||
writer.WriteSafeString(defaultValue);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
handlebarsContext.RegisterHelper("Regex.Match", (writer, options, context, arguments) =>
|
|
||||||
{
|
|
||||||
(string stringToProcess, string regexPattern, object defaultValue) = ParseArguments(arguments);
|
|
||||||
|
|
||||||
var regex = new Regex(regexPattern);
|
|
||||||
var namedGroups = RegexUtils.GetNamedGroups(regex, stringToProcess);
|
|
||||||
if (namedGroups.Any())
|
|
||||||
{
|
|
||||||
options.Template(writer, namedGroups);
|
|
||||||
}
|
|
||||||
else if (defaultValue != null)
|
|
||||||
{
|
|
||||||
options.Template(writer, defaultValue);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static (string stringToProcess, string regexPattern, object defaultValue) ParseArguments(object[] arguments)
|
|
||||||
{
|
|
||||||
Check.Condition(arguments, args => args.Length == 2 || args.Length == 3, nameof(arguments));
|
|
||||||
|
|
||||||
string ParseAsString(object arg)
|
|
||||||
{
|
|
||||||
if (arg is string argAsString)
|
|
||||||
{
|
|
||||||
return argAsString;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new NotSupportedException($"The value '{arg}' with type '{arg?.GetType()}' cannot be used in Handlebars Regex.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ParseAsString(arguments[0]), ParseAsString(arguments[1]), arguments.Length == 3 ? arguments[2] : null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
using HandlebarsDotNet;
|
|
||||||
using System;
|
|
||||||
using System.Text;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.XPath;
|
|
||||||
using WireMock.Validation;
|
|
||||||
#if !NETSTANDARD1_3
|
|
||||||
using Wmhelp.XPath2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
internal static class HandlebarsXPath
|
|
||||||
{
|
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
|
||||||
{
|
|
||||||
handlebarsContext.RegisterHelper("XPath.SelectSingleNode", (writer, context, arguments) =>
|
|
||||||
{
|
|
||||||
(XPathNavigator nav, string xpath) = ParseArguments(arguments);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
#if NETSTANDARD1_3
|
|
||||||
var result = nav.SelectSingleNode(xpath);
|
|
||||||
#else
|
|
||||||
var result = nav.XPath2SelectSingleNode(xpath);
|
|
||||||
#endif
|
|
||||||
writer.WriteSafeString(result.OuterXml);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// Ignore Exception
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
handlebarsContext.RegisterHelper("XPath.SelectNodes", (writer, context, arguments) =>
|
|
||||||
{
|
|
||||||
(XPathNavigator nav, string xpath) = ParseArguments(arguments);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
#if NETSTANDARD1_3
|
|
||||||
var result = nav.Select(xpath);
|
|
||||||
#else
|
|
||||||
var result = nav.XPath2SelectNodes(xpath);
|
|
||||||
#endif
|
|
||||||
var resultXml = new StringBuilder();
|
|
||||||
foreach (XPathNavigator node in result)
|
|
||||||
{
|
|
||||||
resultXml.Append(node.OuterXml);
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.WriteSafeString(resultXml);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// Ignore Exception
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
handlebarsContext.RegisterHelper("XPath.Evaluate", (writer, context, arguments) =>
|
|
||||||
{
|
|
||||||
(XPathNavigator nav, string xpath) = ParseArguments(arguments);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
#if NETSTANDARD1_3
|
|
||||||
var result = nav.Evaluate(xpath);
|
|
||||||
#else
|
|
||||||
var result = nav.XPath2Evaluate(xpath);
|
|
||||||
#endif
|
|
||||||
writer.WriteSafeString(result);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// Ignore Exception
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static (XPathNavigator nav, string xpath) ParseArguments(object[] arguments)
|
|
||||||
{
|
|
||||||
Check.Condition(arguments, args => args.Length == 2, nameof(arguments));
|
|
||||||
Check.NotNull(arguments[0], "arguments[0]");
|
|
||||||
Check.NotNullOrEmpty(arguments[1] as string, "arguments[1]");
|
|
||||||
|
|
||||||
XPathNavigator nav;
|
|
||||||
|
|
||||||
switch (arguments[0])
|
|
||||||
{
|
|
||||||
case string stringValue:
|
|
||||||
nav = new XmlDocument { InnerXml = stringValue }.CreateNavigator();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new NotSupportedException($"The value '{arguments[0]}' with type '{arguments[0]?.GetType()}' cannot be used in Handlebars XPath.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (nav, (string)arguments[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Fare;
|
|
||||||
using HandlebarsDotNet;
|
|
||||||
using WireMock.Validation;
|
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
internal static class HandlebarsXeger
|
|
||||||
{
|
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
|
||||||
{
|
|
||||||
handlebarsContext.RegisterHelper("Xeger", (writer, context, arguments) =>
|
|
||||||
{
|
|
||||||
string value = ParseArgumentAndGenerate(arguments);
|
|
||||||
writer.Write(value);
|
|
||||||
});
|
|
||||||
|
|
||||||
handlebarsContext.RegisterHelper("Xeger", (writer, options, context, arguments) =>
|
|
||||||
{
|
|
||||||
string value = ParseArgumentAndGenerate(arguments);
|
|
||||||
options.Template(writer, value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string ParseArgumentAndGenerate(object[] arguments)
|
|
||||||
{
|
|
||||||
Check.Condition(arguments, args => args.Length == 1, nameof(arguments));
|
|
||||||
Check.NotNull(arguments[0], "arguments[0]");
|
|
||||||
|
|
||||||
switch (arguments[0])
|
|
||||||
{
|
|
||||||
case string pattern:
|
|
||||||
return new Xeger(pattern).Generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new NotSupportedException($"The value '{arguments[0]}' with type '{arguments[0]?.GetType()}' cannot be used in Handlebars Xeger.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
27
src/WireMock.Net/Transformers/Handlebars/FileHelpers.cs
Normal file
27
src/WireMock.Net/Transformers/Handlebars/FileHelpers.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using HandlebarsDotNet;
|
||||||
|
using HandlebarsDotNet.Helpers.Attributes;
|
||||||
|
using HandlebarsDotNet.Helpers.Enums;
|
||||||
|
using HandlebarsDotNet.Helpers.Helpers;
|
||||||
|
using WireMock.Handlers;
|
||||||
|
|
||||||
|
namespace WireMock.Transformers.Handlebars
|
||||||
|
{
|
||||||
|
internal class FileHelpers : BaseHelpers, IHelpers
|
||||||
|
{
|
||||||
|
private readonly IFileSystemHandler _fileSystemHandler;
|
||||||
|
|
||||||
|
public FileHelpers(IHandlebars context, IFileSystemHandler fileSystemHandler) : base(context)
|
||||||
|
{
|
||||||
|
_fileSystemHandler = fileSystemHandler ?? throw new ArgumentNullException(nameof(fileSystemHandler));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HandlebarsWriter(WriterType.String, usage: HelperUsage.Both, passContext: true, name: "File")]
|
||||||
|
public string Read(Context context, string path)
|
||||||
|
{
|
||||||
|
var templateFunc = Context.Compile(path);
|
||||||
|
string transformed = templateFunc(context.Value);
|
||||||
|
return _fileSystemHandler.ReadResponseBodyAsString(transformed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,18 @@
|
|||||||
using HandlebarsDotNet;
|
using HandlebarsDotNet;
|
||||||
using WireMock.Handlers;
|
using WireMock.Handlers;
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
namespace WireMock.Transformers.Handlebars
|
||||||
{
|
{
|
||||||
internal class HandlebarsContext : IHandlebarsContext
|
internal class HandlebarsContext : IHandlebarsContext
|
||||||
{
|
{
|
||||||
public IHandlebars Handlebars { get; set; }
|
public IHandlebars Handlebars { get; set; }
|
||||||
|
|
||||||
public IFileSystemHandler FileSystemHandler { get; set; }
|
public IFileSystemHandler FileSystemHandler { get; set; }
|
||||||
|
|
||||||
|
public string ParseAndRender(string text, object model)
|
||||||
|
{
|
||||||
|
var template = Handlebars.Compile(text);
|
||||||
|
return template(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,24 @@
|
|||||||
using System;
|
using System;
|
||||||
using HandlebarsDotNet;
|
using HandlebarsDotNet;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using WireMock.Handlers;
|
using WireMock.Handlers;
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
namespace WireMock.Transformers.Handlebars
|
||||||
{
|
{
|
||||||
internal class HandlebarsContextFactory : IHandlebarsContextFactory
|
internal class HandlebarsContextFactory : ITransformerContextFactory
|
||||||
{
|
{
|
||||||
private static readonly HandlebarsConfiguration HandlebarsConfiguration = new HandlebarsConfiguration
|
|
||||||
{
|
|
||||||
UnresolvedBindingFormatter = "{0}"
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly IFileSystemHandler _fileSystemHandler;
|
private readonly IFileSystemHandler _fileSystemHandler;
|
||||||
private readonly Action<IHandlebars, IFileSystemHandler> _action;
|
private readonly Action<IHandlebars, IFileSystemHandler> _action;
|
||||||
|
|
||||||
public HandlebarsContextFactory(IFileSystemHandler fileSystemHandler, Action<IHandlebars, IFileSystemHandler> action)
|
public HandlebarsContextFactory([NotNull] IFileSystemHandler fileSystemHandler, [CanBeNull] Action<IHandlebars, IFileSystemHandler> action)
|
||||||
{
|
{
|
||||||
_fileSystemHandler = fileSystemHandler;
|
_fileSystemHandler = fileSystemHandler ?? throw new ArgumentNullException(nameof(fileSystemHandler));
|
||||||
_action = action;
|
_action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHandlebarsContext Create()
|
public ITransformerContext Create()
|
||||||
{
|
{
|
||||||
var handlebars = Handlebars.Create(HandlebarsConfiguration);
|
var handlebars = HandlebarsDotNet.Handlebars.Create();
|
||||||
|
|
||||||
WireMockHandlebarsHelpers.Register(handlebars, _fileSystemHandler);
|
WireMockHandlebarsHelpers.Register(handlebars, _fileSystemHandler);
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using HandlebarsDotNet;
|
||||||
|
|
||||||
|
namespace WireMock.Transformers.Handlebars
|
||||||
|
{
|
||||||
|
interface IHandlebarsContext : ITransformerContext
|
||||||
|
{
|
||||||
|
IHandlebars Handlebars { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using HandlebarsDotNet;
|
||||||
|
using HandlebarsDotNet.Helpers;
|
||||||
|
using HandlebarsDotNet.Helpers.Helpers;
|
||||||
|
using WireMock.Handlers;
|
||||||
|
|
||||||
|
namespace WireMock.Transformers.Handlebars
|
||||||
|
{
|
||||||
|
internal static class WireMockHandlebarsHelpers
|
||||||
|
{
|
||||||
|
public static void Register(IHandlebars handlebarsContext, IFileSystemHandler fileSystemHandler)
|
||||||
|
{
|
||||||
|
// Register https://github.com/StefH/Handlebars.Net.Helpers
|
||||||
|
HandlebarsHelpers.Register(handlebarsContext, o =>
|
||||||
|
{
|
||||||
|
o.CustomHelperPaths = new string[]
|
||||||
|
{
|
||||||
|
Directory.GetCurrentDirectory()
|
||||||
|
#if !NETSTANDARD1_3
|
||||||
|
, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
.Distinct()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
o.CustomHelpers = new Dictionary<string, IHelpers>
|
||||||
|
{
|
||||||
|
{ "File", new FileHelpers(handlebarsContext, fileSystemHandler) }
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
using HandlebarsDotNet;
|
|
||||||
using WireMock.Handlers;
|
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
interface IHandlebarsContext
|
|
||||||
{
|
|
||||||
IHandlebars Handlebars { get; set; }
|
|
||||||
|
|
||||||
IFileSystemHandler FileSystemHandler { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
interface IHandlebarsContextFactory
|
|
||||||
{
|
|
||||||
IHandlebarsContext Create();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
7
src/WireMock.Net/Transformers/ITransformer.cs
Normal file
7
src/WireMock.Net/Transformers/ITransformer.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace WireMock.Transformers
|
||||||
|
{
|
||||||
|
interface ITransformer
|
||||||
|
{
|
||||||
|
ResponseMessage Transform(RequestMessage requestMessage, ResponseMessage original, bool useTransformerForBodyAsFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/WireMock.Net/Transformers/ITransformerContext.cs
Normal file
11
src/WireMock.Net/Transformers/ITransformerContext.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using WireMock.Handlers;
|
||||||
|
|
||||||
|
namespace WireMock.Transformers
|
||||||
|
{
|
||||||
|
interface ITransformerContext
|
||||||
|
{
|
||||||
|
IFileSystemHandler FileSystemHandler { get; set; }
|
||||||
|
|
||||||
|
string ParseAndRender(string text, object model);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace WireMock.Transformers
|
||||||
|
{
|
||||||
|
interface ITransformerContextFactory
|
||||||
|
{
|
||||||
|
ITransformerContext Create();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
src/WireMock.Net/Transformers/Scriban/ScribanContext.cs
Normal file
27
src/WireMock.Net/Transformers/Scriban/ScribanContext.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using Scriban;
|
||||||
|
using WireMock.Handlers;
|
||||||
|
using WireMock.Types;
|
||||||
|
|
||||||
|
namespace WireMock.Transformers.Scriban
|
||||||
|
{
|
||||||
|
internal class ScribanContext : ITransformerContext
|
||||||
|
{
|
||||||
|
private readonly TransformerType _transformerType;
|
||||||
|
|
||||||
|
public IFileSystemHandler FileSystemHandler { get; set; }
|
||||||
|
|
||||||
|
public ScribanContext(IFileSystemHandler fileSystemHandler, TransformerType transformerType)
|
||||||
|
{
|
||||||
|
FileSystemHandler = fileSystemHandler ?? throw new ArgumentNullException(nameof(fileSystemHandler));
|
||||||
|
_transformerType = transformerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ParseAndRender(string text, object model)
|
||||||
|
{
|
||||||
|
var template = _transformerType == TransformerType.ScribanDotLiquid ? Template.ParseLiquid(text) : Template.Parse(text);
|
||||||
|
|
||||||
|
return template.Render(model, member => member.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using WireMock.Handlers;
|
||||||
|
using WireMock.Types;
|
||||||
|
using WireMock.Validation;
|
||||||
|
|
||||||
|
namespace WireMock.Transformers.Scriban
|
||||||
|
{
|
||||||
|
internal class ScribanContextFactory : ITransformerContextFactory
|
||||||
|
{
|
||||||
|
private readonly IFileSystemHandler _fileSystemHandler;
|
||||||
|
private readonly TransformerType _transformerType;
|
||||||
|
|
||||||
|
public ScribanContextFactory(IFileSystemHandler fileSystemHandler, TransformerType transformerType)
|
||||||
|
{
|
||||||
|
Check.NotNull(fileSystemHandler, nameof(fileSystemHandler));
|
||||||
|
Check.Condition(transformerType, t => t == TransformerType.Scriban || t == TransformerType.ScribanDotLiquid, nameof(transformerType));
|
||||||
|
|
||||||
|
_fileSystemHandler = fileSystemHandler;
|
||||||
|
_transformerType = transformerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITransformerContext Create()
|
||||||
|
{
|
||||||
|
return new ScribanContext(_fileSystemHandler, _transformerType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Scriban;
|
||||||
|
using Scriban.Parsing;
|
||||||
|
using Scriban.Runtime;
|
||||||
|
|
||||||
|
namespace WireMock.Transformers.Scriban
|
||||||
|
{
|
||||||
|
internal class WireMockListAccessor : IListAccessor, IObjectAccessor
|
||||||
|
{
|
||||||
|
#region IListAccessor
|
||||||
|
public int GetLength(TemplateContext context, SourceSpan span, object target)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public object GetValue(TemplateContext context, SourceSpan span, object target, int index)
|
||||||
|
{
|
||||||
|
return target.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetValue(TemplateContext context, SourceSpan span, object target, int index, object value)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IObjectAccessor
|
||||||
|
public int GetMemberCount(TemplateContext context, SourceSpan span, object target)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> GetMembers(TemplateContext context, SourceSpan span, object target)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasMember(TemplateContext context, SourceSpan span, object target, string member)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetValue(TemplateContext context, SourceSpan span, object target, string member, out object value)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TrySetValue(TemplateContext context, SourceSpan span, object target, string member, object value)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using Scriban;
|
||||||
|
using Scriban.Runtime;
|
||||||
|
using WireMock.Types;
|
||||||
|
|
||||||
|
namespace WireMock.Transformers.Scriban
|
||||||
|
{
|
||||||
|
internal class WireMockTemplateContext: TemplateContext
|
||||||
|
{
|
||||||
|
protected override IObjectAccessor GetMemberAccessorImpl(object target)
|
||||||
|
{
|
||||||
|
if (target?.GetType().GetGenericTypeDefinition() == typeof(WireMockList<>))
|
||||||
|
{
|
||||||
|
return new WireMockListAccessor();
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.GetMemberAccessorImpl(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using HandlebarsDotNet;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@@ -9,13 +8,13 @@ using WireMock.Types;
|
|||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
using WireMock.Validation;
|
using WireMock.Validation;
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
namespace WireMock.Transformers.Handlebars
|
||||||
{
|
{
|
||||||
internal class ResponseMessageTransformer
|
internal class Transformer : ITransformer
|
||||||
{
|
{
|
||||||
private readonly IHandlebarsContextFactory _factory;
|
private readonly ITransformerContextFactory _factory;
|
||||||
|
|
||||||
public ResponseMessageTransformer([NotNull] IHandlebarsContextFactory factory)
|
public Transformer([NotNull] ITransformerContextFactory factory)
|
||||||
{
|
{
|
||||||
Check.NotNull(factory, nameof(factory));
|
Check.NotNull(factory, nameof(factory));
|
||||||
|
|
||||||
@@ -28,21 +27,21 @@ namespace WireMock.Transformers
|
|||||||
|
|
||||||
var responseMessage = new ResponseMessage();
|
var responseMessage = new ResponseMessage();
|
||||||
|
|
||||||
var template = new { request = requestMessage };
|
var model = new { request = requestMessage };
|
||||||
|
|
||||||
switch (original.BodyData?.DetectedBodyType)
|
switch (original.BodyData?.DetectedBodyType)
|
||||||
{
|
{
|
||||||
case BodyType.Json:
|
case BodyType.Json:
|
||||||
TransformBodyAsJson(handlebarsContext.Handlebars, template, original, responseMessage);
|
TransformBodyAsJson(handlebarsContext, model, original, responseMessage);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BodyType.File:
|
case BodyType.File:
|
||||||
TransformBodyAsFile(handlebarsContext, template, original, responseMessage, useTransformerForBodyAsFile);
|
TransformBodyAsFile(handlebarsContext, model, original, responseMessage, useTransformerForBodyAsFile);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BodyType.String:
|
case BodyType.String:
|
||||||
responseMessage.BodyOriginal = original.BodyData.BodyAsString;
|
responseMessage.BodyOriginal = original.BodyData.BodyAsString;
|
||||||
TransformBodyAsString(handlebarsContext.Handlebars, template, original, responseMessage);
|
TransformBodyAsString(handlebarsContext, model, original, responseMessage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,13 +52,12 @@ namespace WireMock.Transformers
|
|||||||
var newHeaders = new Dictionary<string, WireMockList<string>>();
|
var newHeaders = new Dictionary<string, WireMockList<string>>();
|
||||||
foreach (var header in original.Headers)
|
foreach (var header in original.Headers)
|
||||||
{
|
{
|
||||||
var templateHeaderKey = handlebarsContext.Handlebars.Compile(header.Key);
|
var headerKey = handlebarsContext.ParseAndRender(header.Key, model);
|
||||||
var templateHeaderValues = header.Value
|
var templateHeaderValues = header.Value
|
||||||
.Select(handlebarsContext.Handlebars.Compile)
|
.Select(text => handlebarsContext.ParseAndRender(text, model))
|
||||||
.Select(func => func(template))
|
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
newHeaders.Add(templateHeaderKey(template), new WireMockList<string>(templateHeaderValues));
|
newHeaders.Add(headerKey, new WireMockList<string>(templateHeaderValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
responseMessage.Headers = newHeaders;
|
responseMessage.Headers = newHeaders;
|
||||||
@@ -71,36 +69,35 @@ namespace WireMock.Transformers
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case string statusCodeAsString:
|
case string statusCodeAsString:
|
||||||
var templateForStatusCode = handlebarsContext.Handlebars.Compile(statusCodeAsString);
|
responseMessage.StatusCode = handlebarsContext.ParseAndRender(statusCodeAsString, model);
|
||||||
responseMessage.StatusCode = templateForStatusCode(template);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return responseMessage;
|
return responseMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TransformBodyAsJson(IHandlebars handlebarsContext, object template, ResponseMessage original, ResponseMessage responseMessage)
|
private static void TransformBodyAsJson(ITransformerContext handlebarsContext, object model, ResponseMessage original, ResponseMessage responseMessage)
|
||||||
{
|
{
|
||||||
JToken jToken;
|
JToken jToken;
|
||||||
switch (original.BodyData.BodyAsJson)
|
switch (original.BodyData.BodyAsJson)
|
||||||
{
|
{
|
||||||
case JObject bodyAsJObject:
|
case JObject bodyAsJObject:
|
||||||
jToken = bodyAsJObject.DeepClone();
|
jToken = bodyAsJObject.DeepClone();
|
||||||
WalkNode(handlebarsContext, jToken, template);
|
WalkNode(handlebarsContext, jToken, model);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Array bodyAsArray:
|
case Array bodyAsArray:
|
||||||
jToken = JArray.FromObject(bodyAsArray);
|
jToken = JArray.FromObject(bodyAsArray);
|
||||||
WalkNode(handlebarsContext, jToken, template);
|
WalkNode(handlebarsContext, jToken, model);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case string bodyAsString:
|
case string bodyAsString:
|
||||||
jToken = ReplaceSingleNode(handlebarsContext, bodyAsString, template);
|
jToken = ReplaceSingleNode(handlebarsContext, bodyAsString, model);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
jToken = JObject.FromObject(original.BodyData.BodyAsJson);
|
jToken = JObject.FromObject(original.BodyData.BodyAsJson);
|
||||||
WalkNode(handlebarsContext, jToken, template);
|
WalkNode(handlebarsContext, jToken, model);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,10 +110,10 @@ namespace WireMock.Transformers
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JToken ReplaceSingleNode(IHandlebars handlebarsContext, string stringValue, object context)
|
private static JToken ReplaceSingleNode(ITransformerContext handlebarsContext, string stringValue, object model)
|
||||||
{
|
{
|
||||||
var templateForStringValue = handlebarsContext.Compile(stringValue);
|
string transformedString = handlebarsContext.ParseAndRender(stringValue, model) as string;
|
||||||
string transformedString = templateForStringValue(context);
|
|
||||||
if (!string.Equals(stringValue, transformedString))
|
if (!string.Equals(stringValue, transformedString))
|
||||||
{
|
{
|
||||||
const string property = "_";
|
const string property = "_";
|
||||||
@@ -131,14 +128,14 @@ namespace WireMock.Transformers
|
|||||||
return stringValue;
|
return stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WalkNode(IHandlebars handlebarsContext, JToken node, object context)
|
private static void WalkNode(ITransformerContext handlebarsContext, JToken node, object model)
|
||||||
{
|
{
|
||||||
if (node.Type == JTokenType.Object)
|
if (node.Type == JTokenType.Object)
|
||||||
{
|
{
|
||||||
// In case of Object, loop all children. Do a ToArray() to avoid `Collection was modified` exceptions.
|
// In case of Object, loop all children. Do a ToArray() to avoid `Collection was modified` exceptions.
|
||||||
foreach (JProperty child in node.Children<JProperty>().ToArray())
|
foreach (JProperty child in node.Children<JProperty>().ToArray())
|
||||||
{
|
{
|
||||||
WalkNode(handlebarsContext, child.Value, context);
|
WalkNode(handlebarsContext, child.Value, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (node.Type == JTokenType.Array)
|
else if (node.Type == JTokenType.Array)
|
||||||
@@ -146,7 +143,7 @@ namespace WireMock.Transformers
|
|||||||
// In case of Array, loop all items. Do a ToArray() to avoid `Collection was modified` exceptions.
|
// In case of Array, loop all items. Do a ToArray() to avoid `Collection was modified` exceptions.
|
||||||
foreach (JToken child in node.Children().ToArray())
|
foreach (JToken child in node.Children().ToArray())
|
||||||
{
|
{
|
||||||
WalkNode(handlebarsContext, child, context);
|
WalkNode(handlebarsContext, child, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (node.Type == JTokenType.String)
|
else if (node.Type == JTokenType.String)
|
||||||
@@ -158,8 +155,7 @@ namespace WireMock.Transformers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var templateForStringValue = handlebarsContext.Compile(stringValue);
|
string transformedString = handlebarsContext.ParseAndRender(stringValue, model);
|
||||||
string transformedString = templateForStringValue(context);
|
|
||||||
if (!string.Equals(stringValue, transformedString))
|
if (!string.Equals(stringValue, transformedString))
|
||||||
{
|
{
|
||||||
ReplaceNodeValue(node, transformedString);
|
ReplaceNodeValue(node, transformedString);
|
||||||
@@ -190,23 +186,20 @@ namespace WireMock.Transformers
|
|||||||
node.Replace(value);
|
node.Replace(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TransformBodyAsString(IHandlebars handlebarsContext, object template, ResponseMessage original, ResponseMessage responseMessage)
|
private static void TransformBodyAsString(ITransformerContext handlebarsContext, object model, ResponseMessage original, ResponseMessage responseMessage)
|
||||||
{
|
{
|
||||||
var templateBodyAsString = handlebarsContext.Compile(original.BodyData.BodyAsString);
|
|
||||||
|
|
||||||
responseMessage.BodyData = new BodyData
|
responseMessage.BodyData = new BodyData
|
||||||
{
|
{
|
||||||
Encoding = original.BodyData.Encoding,
|
Encoding = original.BodyData.Encoding,
|
||||||
DetectedBodyType = original.BodyData.DetectedBodyType,
|
DetectedBodyType = original.BodyData.DetectedBodyType,
|
||||||
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
||||||
BodyAsString = templateBodyAsString(template)
|
BodyAsString = handlebarsContext.ParseAndRender(original.BodyData.BodyAsString, model)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TransformBodyAsFile(IHandlebarsContext handlebarsContext, object template, ResponseMessage original, ResponseMessage responseMessage, bool useTransformerForBodyAsFile)
|
private void TransformBodyAsFile(ITransformerContext handlebarsContext, object model, ResponseMessage original, ResponseMessage responseMessage, bool useTransformerForBodyAsFile)
|
||||||
{
|
{
|
||||||
var templateBodyAsFile = handlebarsContext.Handlebars.Compile(original.BodyData.BodyAsFile);
|
string transformedBodyAsFilename = handlebarsContext.ParseAndRender(original.BodyData.BodyAsFile, model);
|
||||||
string transformedBodyAsFilename = templateBodyAsFile(template);
|
|
||||||
|
|
||||||
if (!useTransformerForBodyAsFile)
|
if (!useTransformerForBodyAsFile)
|
||||||
{
|
{
|
||||||
@@ -220,13 +213,12 @@ namespace WireMock.Transformers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string text = handlebarsContext.FileSystemHandler.ReadResponseBodyAsString(transformedBodyAsFilename);
|
string text = handlebarsContext.FileSystemHandler.ReadResponseBodyAsString(transformedBodyAsFilename);
|
||||||
var templateBodyAsString = handlebarsContext.Handlebars.Compile(text);
|
|
||||||
|
|
||||||
responseMessage.BodyData = new BodyData
|
responseMessage.BodyData = new BodyData
|
||||||
{
|
{
|
||||||
DetectedBodyType = BodyType.String,
|
DetectedBodyType = BodyType.String,
|
||||||
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
||||||
BodyAsString = templateBodyAsString(template),
|
BodyAsString = handlebarsContext.ParseAndRender(text, model),
|
||||||
BodyAsFile = transformedBodyAsFilename
|
BodyAsFile = transformedBodyAsFilename
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
using HandlebarsDotNet;
|
|
||||||
using HandlebarsDotNet.Helpers;
|
|
||||||
using WireMock.Handlers;
|
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
internal static class WireMockHandlebarsHelpers
|
|
||||||
{
|
|
||||||
public static void Register(IHandlebars handlebarsContext, IFileSystemHandler fileSystemHandler)
|
|
||||||
{
|
|
||||||
// Register https://github.com/StefH/Handlebars.Net.Helpers
|
|
||||||
HandlebarsHelpers.Register(handlebarsContext);
|
|
||||||
|
|
||||||
// Register WireMock.Net specific helpers
|
|
||||||
HandlebarsRegex.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandlebarsJsonPath.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandlebarsLinq.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandlebarsRandom.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandlebarsXeger.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandlebarsXPath.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandlebarsFile.Register(handlebarsContext, fileSystemHandler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
<!-- https://github.com/aspnet/RoslynCodeDomProvider/issues/51 -->
|
<!-- https://github.com/aspnet/RoslynCodeDomProvider/issues/51 -->
|
||||||
<!-- This is needed else we cannot build net452 in Azure DevOps Pipeline -->
|
<!-- This is needed else we cannot build net452 in Azure DevOps Pipeline -->
|
||||||
<Target Name="CheckIfShouldKillVBCSCompiler" />
|
<!--<Target Name="CheckIfShouldKillVBCSCompiler" />-->
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
<!--<PathMap>$(MSBuildProjectDirectory)=/</PathMap>-->
|
<!--<PathMap>$(MSBuildProjectDirectory)=/</PathMap>-->
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
<DefineConstants>USE_ASPNETCORE;NET46</DefineConstants>
|
<DefineConstants>USE_ASPNETCORE;NET46</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
|
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
|
||||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
@@ -58,7 +58,6 @@
|
|||||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.12" />
|
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.12" />
|
||||||
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.12" />
|
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.12" />
|
||||||
<PackageReference Include="JmesPath.Net" Version="1.0.125" />
|
<PackageReference Include="JmesPath.Net" Version="1.0.125" />
|
||||||
<PackageReference Include="Handlebars.Net.Helpers" Version="1.1.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(Configuration)' == 'Debug - Sonar'">
|
<ItemGroup Condition="'$(Configuration)' == 'Debug - Sonar'">
|
||||||
@@ -72,22 +71,13 @@
|
|||||||
<PackageReference Include="XPath2.Extensions" Version="1.1.0" />
|
<PackageReference Include="XPath2.Extensions" Version="1.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'net452' ">
|
||||||
<!-- Required for WebRequestHandler -->
|
<!-- Required for WebRequestHandler -->
|
||||||
<Reference Include="System.Net.Http.WebRequest" />
|
<Reference Include="System.Net.Http.WebRequest" />
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.2.6" />
|
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.2.6" />
|
||||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||||
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="2.0.1" />
|
<PackageReference Include="Scriban.Signed" Version="2.1.4" />
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
|
|
||||||
<!-- Required for WebRequestHandler -->
|
|
||||||
<Reference Include="System.Net.Http.WebRequest" />
|
|
||||||
|
|
||||||
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.2.6" />
|
|
||||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
|
||||||
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="2.0.1" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
|
||||||
@@ -97,16 +87,15 @@
|
|||||||
<PackageReference Include="Microsoft.Owin.Hosting" Version="4.0.0" />
|
<PackageReference Include="Microsoft.Owin.Hosting" Version="4.0.0" />
|
||||||
<PackageReference Include="System.Net.Http" Version="4.3.3" />
|
<PackageReference Include="System.Net.Http" Version="4.3.3" />
|
||||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||||
<PackageReference Include="CS-Script" Version="3.29.0" />
|
<PackageReference Include="Scriban.Signed" Version="2.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
|
||||||
|
<PackageReference Include="Scriban.Signed" Version="2.1.4" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
||||||
|
|
||||||
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/507 -->
|
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/507 -->
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Server.IIS" Version="2.2.6" />
|
<PackageReference Include="Microsoft.AspNetCore.Server.IIS" Version="2.2.6" />
|
||||||
|
|
||||||
<PackageReference Include="CS-Script" Version="3.29.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
|
||||||
@@ -115,39 +104,30 @@
|
|||||||
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
|
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
|
||||||
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
|
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
|
||||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||||
|
<PackageReference Include="Scriban.Signed" Version="2.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1' ">
|
||||||
|
<PackageReference Include="Scriban.Signed" Version="3.3.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
||||||
|
|
||||||
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/507 -->
|
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/507 -->
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Server.IIS" Version="2.2.6" />
|
<PackageReference Include="Microsoft.AspNetCore.Server.IIS" Version="2.2.6" />
|
||||||
<PackageReference Include="CS-Script.Core" Version="1.1.1" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1'">
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0'">
|
||||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
|
||||||
|
|
||||||
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/507 -->
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Server.IIS" Version="2.2.6" />
|
|
||||||
|
|
||||||
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/448 -->
|
|
||||||
<PackageReference Include="CS-Script.Core" Version="1.3.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1'">
|
|
||||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||||
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/448 -->
|
<PackageReference Include="Scriban.Signed" Version="3.3.2" />
|
||||||
<PackageReference Include="CS-Script.Core" Version="1.4.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0'">
|
|
||||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
|
||||||
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/448 -->
|
|
||||||
<PackageReference Include="CS-Script.Core" Version="1.4.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.1.1" />
|
||||||
|
|
||||||
<ProjectReference Include="..\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
<ProjectReference Include="..\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -108,23 +108,6 @@ namespace WireMock.Net.Tests.Owin.Mappers
|
|||||||
_responseMock.VerifySet(r => r.StatusCode = expected, Times.Once);
|
_responseMock.VerifySet(r => r.StatusCode = expected, Times.Once);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task OwinResponseMapper_MapAsync_Null_StatusCode_When_AllowOnlyDefinedHttpStatusCodeInResponseSet_Is_True()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
_optionsMock.SetupGet(o => o.AllowOnlyDefinedHttpStatusCodeInResponse).Returns(true);
|
|
||||||
var responseMessage = new ResponseMessage
|
|
||||||
{
|
|
||||||
StatusCode = null
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await _sut.MapAsync(responseMessage, _responseMock.Object);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
_responseMock.VerifyNoOtherCalls();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task OwinResponseMapper_MapAsync_StatusCode_Is_Null()
|
public async Task OwinResponseMapper_MapAsync_StatusCode_Is_Null()
|
||||||
{
|
{
|
||||||
@@ -138,7 +121,7 @@ namespace WireMock.Net.Tests.Owin.Mappers
|
|||||||
await _sut.MapAsync(responseMessage, _responseMock.Object);
|
await _sut.MapAsync(responseMessage, _responseMock.Object);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
_responseMock.VerifyNoOtherCalls();
|
_responseMock.VerifySet(r => r.StatusCode = It.IsAny<int>(), Times.Never);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
|||||||
35
test/WireMock.Net.Tests/Plugin/PluginLoaderTests.cs
Normal file
35
test/WireMock.Net.Tests/Plugin/PluginLoaderTests.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using FluentAssertions;
|
||||||
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Plugin;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace WireMock.Net.Tests.Plugin
|
||||||
|
{
|
||||||
|
public class PluginLoaderTests
|
||||||
|
{
|
||||||
|
public interface IDummy
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Load_Valid()
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
var result = PluginLoader.Load<ICSharpCodeMatcher>(MatchBehaviour.AcceptOnMatch, "x");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().NotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Load_Invalid_ThrowsException()
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
Action a = () => PluginLoader.Load<IDummy>();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
a.Should().Throw<DllNotFoundException>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Moq;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
|
using WireMock.Handlers;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
@@ -14,9 +16,19 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
{
|
{
|
||||||
public class ResponseWithBodyTests
|
public class ResponseWithBodyTests
|
||||||
{
|
{
|
||||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
|
||||||
private const string ClientIp = "::1";
|
private const string ClientIp = "::1";
|
||||||
|
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
|
public ResponseWithBodyTests()
|
||||||
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Response_ProvideResponse_WithBody_Bytes_Encoding_Destination_String()
|
public async Task Response_ProvideResponse_WithBody_Bytes_Encoding_Destination_String()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
|
using WireMock.Handlers;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
@@ -11,8 +13,19 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
{
|
{
|
||||||
public class ResponseWithCallbackTests
|
public class ResponseWithCallbackTests
|
||||||
{
|
{
|
||||||
|
private const string ClientIp = "::1";
|
||||||
|
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
|
public ResponseWithCallbackTests()
|
||||||
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Response_WithCallbackAsync()
|
public async Task Response_WithCallbackAsync()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using FluentAssertions;
|
using System.Threading.Tasks;
|
||||||
using Moq;
|
using FluentAssertions;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using HandlebarsDotNet;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
@@ -76,7 +77,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Response_ProvideResponseAsync_Handlebars_File_WithMissingArgument_ThrowsArgumentOutOfRangeException()
|
public void Response_ProvideResponseAsync_Handlebars_File_WithMissingArgument_Throws_HandlebarsException()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp);
|
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp);
|
||||||
@@ -89,7 +90,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Check.ThatAsyncCode(() => response.ProvideResponseAsync(request, _settings)).Throws<ArgumentOutOfRangeException>();
|
Check.ThatAsyncCode(() => response.ProvideResponseAsync(request, _settings)).Throws<HandlebarsException>();
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
_filesystemHandlerMock.Verify(fs => fs.ReadResponseBodyAsString(It.IsAny<string>()), Times.Never);
|
_filesystemHandlerMock.Verify(fs => fs.ReadResponseBodyAsString(It.IsAny<string>()), Times.Never);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Moq;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
|
using WireMock.Handlers;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
@@ -11,9 +13,19 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
{
|
{
|
||||||
public class ResponseWithHandlebarsHelpersTests
|
public class ResponseWithHandlebarsHelpersTests
|
||||||
{
|
{
|
||||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
|
||||||
private const string ClientIp = "::1";
|
private const string ClientIp = "::1";
|
||||||
|
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
|
public ResponseWithHandlebarsHelpersTests()
|
||||||
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Response_ProvideResponseAsync_HandlebarsHelpers_String_Uppercase()
|
public async Task Response_ProvideResponseAsync_HandlebarsHelpers_String_Uppercase()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Moq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
|
using WireMock.Handlers;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
@@ -13,9 +17,19 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
{
|
{
|
||||||
public class ResponseWithHandlebarsJsonPathTests
|
public class ResponseWithHandlebarsJsonPathTests
|
||||||
{
|
{
|
||||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
|
||||||
private const string ClientIp = "::1";
|
private const string ClientIp = "::1";
|
||||||
|
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
|
public ResponseWithHandlebarsJsonPathTests()
|
||||||
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Response_ProvideResponse_Handlebars_JsonPath_SelectToken_Object_ResponseBodyAsJson()
|
public async Task Response_ProvideResponse_Handlebars_JsonPath_SelectToken_Object_ResponseBodyAsJson()
|
||||||
{
|
{
|
||||||
@@ -333,5 +347,32 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
// Act
|
// Act
|
||||||
Check.ThatAsyncCode(() => response.ProvideResponseAsync(request, _settings)).Throws<ArgumentNullException>();
|
Check.ThatAsyncCode(() => response.ProvideResponseAsync(request, _settings)).Throws<ArgumentNullException>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Response_ProvideResponse_Transformer_WithBodyAsFile_JsonPath()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
string jsonString = "{ \"MyUniqueNumber\": \"1\" }";
|
||||||
|
var bodyData = new BodyData
|
||||||
|
{
|
||||||
|
BodyAsString = jsonString,
|
||||||
|
BodyAsJson = JsonConvert.DeserializeObject(jsonString),
|
||||||
|
DetectedBodyType = BodyType.Json,
|
||||||
|
DetectedBodyTypeFromContentType = BodyType.Json,
|
||||||
|
Encoding = Encoding.UTF8
|
||||||
|
};
|
||||||
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, bodyData);
|
||||||
|
|
||||||
|
string jsonPath = "\"$.MyUniqueNumber\"";
|
||||||
|
var response = Response.Create()
|
||||||
|
.WithTransformer()
|
||||||
|
.WithBodyFromFile(@"c:\\{{JsonPath.SelectToken request.body " + jsonPath + "}}\\test.json"); // why use a \\ here ?
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(responseMessage.BodyData.BodyAsFile).Equals(@"c:\1\test.json");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using FluentAssertions;
|
||||||
|
using HandlebarsDotNet;
|
||||||
|
using Moq;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
|
using WireMock.Handlers;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
@@ -13,8 +17,17 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
{
|
{
|
||||||
public class ResponseWithHandlebarsLinqTests
|
public class ResponseWithHandlebarsLinqTests
|
||||||
{
|
{
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
|
public ResponseWithHandlebarsLinqTests()
|
||||||
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Response_ProvideResponse_Handlebars_Linq1_String0()
|
public async Task Response_ProvideResponse_Handlebars_Linq1_String0()
|
||||||
{
|
{
|
||||||
@@ -128,7 +141,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Response_ProvideResponse_Handlebars_Linq_Throws_NotSupportedException()
|
public void Response_ProvideResponse_Handlebars_Linq_Throws_ArgumentException()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var body = new BodyData
|
var body = new BodyData
|
||||||
@@ -144,7 +157,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Check.ThatAsyncCode(() => response.ProvideResponseAsync(request, _settings)).Throws<NotSupportedException>();
|
Check.ThatAsyncCode(() => response.ProvideResponseAsync(request, _settings)).Throws<ArgumentException>();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -164,7 +177,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Response_ProvideResponse_Handlebars_Linq1_Throws_ArgumentException()
|
public void Response_ProvideResponse_Handlebars_Linq1_Throws_HandlebarsException()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var body = new BodyData();
|
var body = new BodyData();
|
||||||
@@ -176,11 +189,11 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Check.ThatAsyncCode(() => response.ProvideResponseAsync(request, _settings)).Throws<ArgumentException>();
|
Check.ThatAsyncCode(() => response.ProvideResponseAsync(request, _settings)).Throws<HandlebarsException>();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async void Response_ProvideResponse_Handlebars_Linq1_ParseError_Returns_Empty()
|
public void Response_ProvideResponse_Handlebars_Linq1_ParseError_Throws_ExceptionMessage()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var body = new BodyData
|
var body = new BodyData
|
||||||
@@ -200,15 +213,14 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
Func<Task> a = async () => await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
JObject j = JObject.FromObject(responseMessage.BodyData.BodyAsJson);
|
a.Should().Throw<HandlebarsException>();
|
||||||
Check.That(j["x"].ToString()).IsEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async void Response_ProvideResponse_Handlebars_Linq2_ParseError_Returns_Empty()
|
public void Response_ProvideResponse_Handlebars_Linq2_ParseError_Throws_ExceptionMessage()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var body = new BodyData
|
var body = new BodyData
|
||||||
@@ -228,11 +240,10 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
Func<Task> a = async () => await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
JObject j = JObject.FromObject(responseMessage.BodyData.BodyAsJson);
|
a.Should().Throw<HandlebarsException>();
|
||||||
Check.That(j["x"].ToString()).IsEmpty();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Moq;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
|
using WireMock.Handlers;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
@@ -11,9 +13,19 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
{
|
{
|
||||||
public class ResponseWithHandlebarsRandomTests
|
public class ResponseWithHandlebarsRandomTests
|
||||||
{
|
{
|
||||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
|
||||||
private const string ClientIp = "::1";
|
private const string ClientIp = "::1";
|
||||||
|
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
|
public ResponseWithHandlebarsRandomTests()
|
||||||
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Response_ProvideResponseAsync_Handlebars_Random1()
|
public async Task Response_ProvideResponseAsync_Handlebars_Random1()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Moq;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
|
using WireMock.Handlers;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
@@ -12,9 +14,19 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
{
|
{
|
||||||
public class ResponseWithHandlebarsRegexTests
|
public class ResponseWithHandlebarsRegexTests
|
||||||
{
|
{
|
||||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
|
||||||
private const string ClientIp = "::1";
|
private const string ClientIp = "::1";
|
||||||
|
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
|
public ResponseWithHandlebarsRegexTests()
|
||||||
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Response_ProvideResponseAsync_Handlebars_RegexMatch()
|
public async Task Response_ProvideResponseAsync_Handlebars_RegexMatch()
|
||||||
{
|
{
|
||||||
@@ -24,7 +36,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBody("{{Regex.Match request.body \"^(?<x>\\w+)$\"}}")
|
.WithBody("{{Regex.Match request.body \"^(\\w+)$\"}}")
|
||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -142,7 +154,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
// Act and Assert
|
// Act and Assert
|
||||||
Check.ThatAsyncCode(() => response.ProvideResponseAsync(request, _settings)).Throws<NotSupportedException>();
|
Check.ThatAsyncCode(() => response.ProvideResponseAsync(request, _settings)).Throws<ArgumentNullException>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,8 @@ using WireMock.Settings;
|
|||||||
using WireMock.Types;
|
using WireMock.Types;
|
||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using Moq;
|
||||||
|
using WireMock.Handlers;
|
||||||
#if !NETSTANDARD1_3
|
#if !NETSTANDARD1_3
|
||||||
using Wmhelp.XPath2;
|
using Wmhelp.XPath2;
|
||||||
#endif
|
#endif
|
||||||
@@ -15,9 +17,19 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
{
|
{
|
||||||
public class ResponseWithHandlebarsXPathTests
|
public class ResponseWithHandlebarsXPathTests
|
||||||
{
|
{
|
||||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
|
||||||
private const string ClientIp = "::1";
|
private const string ClientIp = "::1";
|
||||||
|
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
|
public ResponseWithHandlebarsXPathTests()
|
||||||
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Response_ProvideResponse_Handlebars_XPath_SelectSingleNode_Request_BodyAsString()
|
public async Task Response_ProvideResponse_Handlebars_XPath_SelectSingleNode_Request_BodyAsString()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using WireMock.Handlers;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
@@ -11,9 +12,19 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
{
|
{
|
||||||
public class ResponseWithHandlebarsXegerTests
|
public class ResponseWithHandlebarsXegerTests
|
||||||
{
|
{
|
||||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
|
||||||
private const string ClientIp = "::1";
|
private const string ClientIp = "::1";
|
||||||
|
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
|
public ResponseWithHandlebarsXegerTests()
|
||||||
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Response_ProvideResponseAsync_Handlebars_Xeger1()
|
public async Task Response_ProvideResponseAsync_Handlebars_Xeger1()
|
||||||
{
|
{
|
||||||
@@ -23,8 +34,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBodyAsJson(new
|
.WithBodyAsJson(new
|
||||||
{
|
{
|
||||||
Number = "{{Xeger \"[1-9]{1}\\d{3}\"}}",
|
Number = "{{Xeger.Generate \"[1-9]{1}\\d{3}\"}}",
|
||||||
Postcode = "{{Xeger \"[1-9][0-9]{3}[A-Z]{2}\"}}"
|
Postcode = "{{Xeger.Generate \"[1-9][0-9]{3}[A-Z]{2}\"}}"
|
||||||
})
|
})
|
||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
@@ -46,8 +57,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBodyAsJson(new
|
.WithBodyAsJson(new
|
||||||
{
|
{
|
||||||
Number = "{{#Xeger \"[1-9]{1}\\d{3}\"}}{{this}}{{/Xeger}}",
|
Number = "{{#Xeger.Generate \"[1-9]{1}\\d{3}\"}}{{this}}{{/Xeger.Generate}}",
|
||||||
Postcode = "{{#Xeger \"[1-9][0-9]{3}[A-Z]{2}\"}}{{this}}{{/Xeger}}"
|
Postcode = "{{#Xeger.Generate \"[1-9][0-9]{3}[A-Z]{2}\"}}{{this}}{{/Xeger.Generate}}"
|
||||||
})
|
})
|
||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FluentAssertions;
|
||||||
|
using NFluent;
|
||||||
|
using WireMock.Models;
|
||||||
|
using WireMock.ResponseBuilders;
|
||||||
|
using WireMock.Settings;
|
||||||
|
using WireMock.Types;
|
||||||
|
using WireMock.Util;
|
||||||
|
using Xunit;
|
||||||
|
using WireMock.Handlers;
|
||||||
|
using Moq;
|
||||||
|
#if NET452
|
||||||
|
using Microsoft.Owin;
|
||||||
|
#else
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace WireMock.Net.Tests.ResponseBuilders
|
||||||
|
{
|
||||||
|
public class ResponseWithScribanTests
|
||||||
|
{
|
||||||
|
private const string ClientIp = "::1";
|
||||||
|
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
|
public ResponseWithScribanTests()
|
||||||
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Response_ProvideResponse_DotLiquid_WithNullBody_ShouldNotThrowException()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var urlDetails = UrlUtils.Parse(new Uri("http://localhost/wiremock/a/b"), new PathString("/wiremock"));
|
||||||
|
var request = new RequestMessage(urlDetails, "GET", ClientIp);
|
||||||
|
|
||||||
|
var response = Response.Create().WithTransformer(TransformerType.ScribanDotLiquid);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
responseMessage.BodyData.Should().BeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Response_ProvideResponse_DotLiquid_UrlPathVerb()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var body = new BodyData
|
||||||
|
{
|
||||||
|
BodyAsString = "whatever",
|
||||||
|
DetectedBodyType = BodyType.String
|
||||||
|
};
|
||||||
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POSt", ClientIp, body);
|
||||||
|
|
||||||
|
var response = Response.Create()
|
||||||
|
.WithBody("test {{request.Url}} {{request.Path}} {{request.Method}}")
|
||||||
|
.WithTransformer(TransformerType.Scriban);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(responseMessage.BodyData.BodyAsString).Equals("test http://localhost/foo /foo POSt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,20 +21,32 @@ using Microsoft.AspNetCore.Http;
|
|||||||
|
|
||||||
namespace WireMock.Net.Tests.ResponseBuilders
|
namespace WireMock.Net.Tests.ResponseBuilders
|
||||||
{
|
{
|
||||||
public class ResponseWithHandlebarsTests
|
public class ResponseWithTransformerTests
|
||||||
{
|
{
|
||||||
|
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||||
|
|
||||||
private const string ClientIp = "::1";
|
private const string ClientIp = "::1";
|
||||||
|
|
||||||
[Fact]
|
public ResponseWithTransformerTests()
|
||||||
public async Task Response_ProvideResponse_Handlebars_WithNullBody_ShouldNotThrowException()
|
{
|
||||||
|
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
|
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||||
|
|
||||||
|
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData(TransformerType.Handlebars)]
|
||||||
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Transformer_WithNullBody_ShouldNotThrowException(TransformerType transformerType)
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var urlDetails = UrlUtils.Parse(new Uri("http://localhost/wiremock/a/b"), new PathString("/wiremock"));
|
var urlDetails = UrlUtils.Parse(new Uri("http://localhost/wiremock/a/b"), new PathString("/wiremock"));
|
||||||
var request = new RequestMessage(urlDetails, "GET", ClientIp);
|
var request = new RequestMessage(urlDetails, "GET", ClientIp);
|
||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create().WithTransformer(transformerType);
|
||||||
.WithTransformer();
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
@@ -43,8 +55,11 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
responseMessage.BodyData.Should().BeNull();
|
responseMessage.BodyData.Should().BeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public async Task Response_ProvideResponse_Handlebars_UrlPathVerb()
|
[InlineData(TransformerType.Handlebars)]
|
||||||
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Transformer_UrlPathVerb(TransformerType transformerType)
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var body = new BodyData
|
var body = new BodyData
|
||||||
@@ -55,8 +70,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POSt", ClientIp, body);
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POSt", ClientIp, body);
|
||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBody("test {{request.url}} {{request.path}} {{request.method}}")
|
.WithBody("test {{request.Url}} {{request.Path}} {{request.Method}}")
|
||||||
.WithTransformer();
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
@@ -66,23 +81,27 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("Get")]
|
[InlineData(TransformerType.Handlebars, "Get")]
|
||||||
[InlineData("Post")]
|
[InlineData(TransformerType.Handlebars, "Post")]
|
||||||
public async Task Response_ProvideResponse_Handlebars_UrlPath(string httpMethod)
|
[InlineData(TransformerType.Scriban, "Get")]
|
||||||
|
[InlineData(TransformerType.Scriban, "Post")]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid, "Get")]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid, "Post")]
|
||||||
|
public async Task Response_ProvideResponse_Transformer_UrlPath(TransformerType transformerType, string httpMethod)
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var urlDetails = UrlUtils.Parse(new Uri("http://localhost/wiremock/a/b"), new PathString("/wiremock"));
|
var urlDetails = UrlUtils.Parse(new Uri("http://localhost/wiremock/a/b"), new PathString("/wiremock"));
|
||||||
var request = new RequestMessage(urlDetails, httpMethod, ClientIp);
|
var request = new RequestMessage(urlDetails, httpMethod, ClientIp);
|
||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBody("{{request.url}} {{request.absoluteurl}} {{request.path}} {{request.absolutepath}}")
|
.WithBody("url={{request.Url}} absoluteurl={{request.AbsoluteUrl}} path={{request.Path}} absolutepath={{request.AbsolutePath}}")
|
||||||
.WithTransformer();
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("http://localhost/a/b http://localhost/wiremock/a/b /a/b /wiremock/a/b");
|
Check.That(responseMessage.BodyData.BodyAsString).Equals("url=http://localhost/a/b absoluteurl=http://localhost/wiremock/a/b path=/a/b absolutepath=/wiremock/a/b");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -93,7 +112,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
var request = new RequestMessage(urlDetails, "POST", ClientIp);
|
var request = new RequestMessage(urlDetails, "POST", ClientIp);
|
||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBody("{{request.pathsegments.[0]}} {{request.absolutepathsegments.[0]}}")
|
.WithBody("{{request.PathSegments.[0]}} {{request.AbsolutePathSegments.[0]}}")
|
||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -103,6 +122,26 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("a wiremock");
|
Check.That(responseMessage.BodyData.BodyAsString).Equals("a wiremock");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Theory(Skip = "Invalid token `OpenBracket`")]
|
||||||
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Scriban_PathSegments(TransformerType transformerType)
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var urlDetails = UrlUtils.Parse(new Uri("http://localhost/wiremock/a/b"), new PathString("/wiremock"));
|
||||||
|
var request = new RequestMessage(urlDetails, "POST", ClientIp);
|
||||||
|
|
||||||
|
var response = Response.Create()
|
||||||
|
.WithBody("{{request.PathSegments.[0]}} {{request.AbsolutePathSegments.[0]}}")
|
||||||
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(responseMessage.BodyData.BodyAsString).Equals("a wiremock");
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Response_ProvideResponse_Handlebars_Query()
|
public async Task Response_ProvideResponse_Handlebars_Query()
|
||||||
{
|
{
|
||||||
@@ -121,6 +160,30 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(responseMessage.BodyData.BodyAsString).Equals("test keya=1,2 idx=1 idx=2 keyb=5");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory(Skip = "Invalid token `OpenBracket`")]
|
||||||
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Scriban_Query(TransformerType transformerType)
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var body = new BodyData
|
||||||
|
{
|
||||||
|
BodyAsString = "abc",
|
||||||
|
DetectedBodyType = BodyType.String
|
||||||
|
};
|
||||||
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo?a=1&a=2&b=5"), "POST", ClientIp, body);
|
||||||
|
|
||||||
|
var response = Response.Create()
|
||||||
|
.WithBody("test keya={{request.query.a}} idx={{request.query.a.[0]}} idx={{request.query.a.[1]}} keyb={{request.query.b}}")
|
||||||
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("test keya=1 idx=1 idx=2 keyb=5");
|
Check.That(responseMessage.BodyData.BodyAsString).Equals("test keya=1 idx=1 idx=2 keyb=5");
|
||||||
}
|
}
|
||||||
@@ -149,8 +212,37 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
Check.That(responseMessage.StatusCode).Equals("400");
|
Check.That(responseMessage.StatusCode).Equals("400");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory(Skip = "WireMockList is not supported by Scriban")]
|
||||||
public async Task Response_ProvideResponse_Handlebars_StatusCodeIsNull()
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Scriban_StatusCode(TransformerType transformerType)
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var body = new BodyData
|
||||||
|
{
|
||||||
|
BodyAsString = "abc",
|
||||||
|
DetectedBodyType = BodyType.String
|
||||||
|
};
|
||||||
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo?a=400"), "POST", ClientIp, body);
|
||||||
|
|
||||||
|
var response = Response.Create()
|
||||||
|
.WithStatusCode("{{request.Query.a}}")
|
||||||
|
.WithBody("test")
|
||||||
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(responseMessage.BodyData.BodyAsString).Equals("test");
|
||||||
|
Check.That(responseMessage.StatusCode).Equals("400");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData(TransformerType.Handlebars)]
|
||||||
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Transformer_StatusCodeIsNull(TransformerType transformerType)
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var body = new BodyData
|
var body = new BodyData
|
||||||
@@ -162,7 +254,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBody("test")
|
.WithBody("test")
|
||||||
.WithTransformer();
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
@@ -217,8 +309,36 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
Check.That(responseMessage.Headers["x"]).Contains("http://localhost/foo");
|
Check.That(responseMessage.Headers["x"]).Contains("http://localhost/foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory(Skip = "WireMockList is not supported by Scriban")]
|
||||||
public async Task Response_ProvideResponse_Handlebars_Origin_Port_Protocol_Host()
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Scriban_Headers(TransformerType transformerType)
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var body = new BodyData
|
||||||
|
{
|
||||||
|
BodyAsString = "abc",
|
||||||
|
DetectedBodyType = BodyType.String
|
||||||
|
};
|
||||||
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body, new Dictionary<string, string[]> { { "Content-Type", new[] { "text/plain" } } });
|
||||||
|
|
||||||
|
var response = Response.Create().WithHeader("x", "{{request.Headers[\"Content-Type\"]}}", "{{request.Url}}").WithBody("test").WithTransformer(transformerType);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(responseMessage.BodyData.BodyAsString).Equals("test");
|
||||||
|
Check.That(responseMessage.Headers).ContainsKey("x");
|
||||||
|
Check.That(responseMessage.Headers["x"]).Contains("text/plain");
|
||||||
|
Check.That(responseMessage.Headers["x"]).Contains("http://localhost/foo");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData(TransformerType.Handlebars)]
|
||||||
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Transformer_Origin_Port_Protocol_Host(TransformerType transformerType)
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var body = new BodyData
|
var body = new BodyData
|
||||||
@@ -229,8 +349,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBody("test {{request.origin}} {{request.port}} {{request.protocol}} {{request.host}}")
|
.WithBody("test {{request.Origin}} {{request.Port}} {{request.Protocol}} {{request.Host}}")
|
||||||
.WithTransformer();
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
@@ -239,8 +359,11 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("test http://localhost:1234 1234 http localhost");
|
Check.That(responseMessage.BodyData.BodyAsString).Equals("test http://localhost:1234 1234 http localhost");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public async Task Response_ProvideResponse_Handlebars_WithBodyAsJson_ResultAsObject()
|
[InlineData(TransformerType.Handlebars)]
|
||||||
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Transformer_WithBodyAsJson_ResultAsObject(TransformerType transformerType)
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
string jsonString = "{ \"things\": [ { \"name\": \"RequiredThing\" }, { \"name\": \"Wiremock\" } ] }";
|
string jsonString = "{ \"things\": [ { \"name\": \"RequiredThing\" }, { \"name\": \"Wiremock\" } ] }";
|
||||||
@@ -253,8 +376,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo_object"), "POST", ClientIp, bodyData);
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo_object"), "POST", ClientIp, bodyData);
|
||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBodyAsJson(new { x = "test {{request.path}}" })
|
.WithBodyAsJson(new { x = "test {{request.Path}}" })
|
||||||
.WithTransformer();
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
@@ -263,8 +386,11 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
Check.That(JsonConvert.SerializeObject(responseMessage.BodyData.BodyAsJson)).Equals("{\"x\":\"test /foo_object\"}");
|
Check.That(JsonConvert.SerializeObject(responseMessage.BodyData.BodyAsJson)).Equals("{\"x\":\"test /foo_object\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public async Task Response_ProvideResponse_Handlebars_WithBodyAsJson_ResultAsArray()
|
[InlineData(TransformerType.Handlebars)]
|
||||||
|
//[InlineData(TransformerType.Scriban)] Scriban cannot access dynamic Json Objects
|
||||||
|
//[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Transformer_WithBodyAsJson_ResultAsArray(TransformerType transformerType)
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
string jsonString = "{ \"a\": \"test 1\", \"b\": \"test 2\" }";
|
string jsonString = "{ \"a\": \"test 1\", \"b\": \"test 2\" }";
|
||||||
@@ -278,7 +404,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBodyAsJson(new[] { "first", "{{request.path}}", "{{request.bodyAsJson.a}}", "{{request.bodyAsJson.b}}", "last" })
|
.WithBodyAsJson(new[] { "first", "{{request.path}}", "{{request.bodyAsJson.a}}", "{{request.bodyAsJson.b}}", "last" })
|
||||||
.WithTransformer();
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
@@ -304,8 +430,30 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
Check.That(responseMessage.BodyData.BodyAsFile).Equals(@"c:\1\test.xml");
|
Check.That(responseMessage.BodyData.BodyAsFile).Equals(@"c:\1\test.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory(Skip = @"Does not work in Scriban --> c:\\[""1""]\\test.xml")]
|
||||||
public async Task Response_ProvideResponse_Handlebars_WithBodyAsFile_And_TransformContentFromBodyAsFile()
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Scriban_WithBodyAsFile(TransformerType transformerType)
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo?MyUniqueNumber=1"), "GET", ClientIp);
|
||||||
|
|
||||||
|
var response = Response.Create()
|
||||||
|
.WithTransformer(transformerType)
|
||||||
|
.WithBodyFromFile(@"c:\\{{request.query.MyUniqueNumber}}\\test.xml");
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(responseMessage.BodyData.BodyAsFile).Equals(@"c:\1\test.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData(TransformerType.Handlebars)]
|
||||||
|
//[InlineData(TransformerType.Scriban)] ["c:\\["1"]\\test.xml"]
|
||||||
|
//[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Transformer_WithBodyAsFile_And_TransformContentFromBodyAsFile(TransformerType transformerType)
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
var filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||||
@@ -316,7 +464,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo?MyUniqueNumber=1"), "GET", ClientIp);
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo?MyUniqueNumber=1"), "GET", ClientIp);
|
||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithTransformer(true)
|
.WithTransformer(transformerType, true)
|
||||||
.WithBodyFromFile(@"c:\\{{request.query.MyUniqueNumber}}\\test.xml");
|
.WithBodyFromFile(@"c:\\{{request.query.MyUniqueNumber}}\\test.xml");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -328,35 +476,11 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("<xml MyUniqueNumber=\"1\"></xml>");
|
Check.That(responseMessage.BodyData.BodyAsString).Equals("<xml MyUniqueNumber=\"1\"></xml>");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public async Task Response_ProvideResponse_Handlebars_WithBodyAsFile_JsonPath()
|
[InlineData(TransformerType.Handlebars)]
|
||||||
{
|
[InlineData(TransformerType.Scriban)]
|
||||||
// Assign
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
string jsonString = "{ \"MyUniqueNumber\": \"1\" }";
|
public async Task Response_ProvideResponse_Transformer_WithBodyAsJson_ResultAsNormalString(TransformerType transformerType)
|
||||||
var bodyData = new BodyData
|
|
||||||
{
|
|
||||||
BodyAsString = jsonString,
|
|
||||||
BodyAsJson = JsonConvert.DeserializeObject(jsonString),
|
|
||||||
DetectedBodyType = BodyType.Json,
|
|
||||||
DetectedBodyTypeFromContentType = BodyType.Json,
|
|
||||||
Encoding = Encoding.UTF8
|
|
||||||
};
|
|
||||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, bodyData);
|
|
||||||
|
|
||||||
string jsonPath = "\"$.MyUniqueNumber\"";
|
|
||||||
var response = Response.Create()
|
|
||||||
.WithTransformer()
|
|
||||||
.WithBodyFromFile(@"c:\\{{JsonPath.SelectToken request.body " + jsonPath + "}}\\test.json"); // why use a \\ here ?
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Check.That(responseMessage.BodyData.BodyAsFile).Equals(@"c:\1\test.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task Response_ProvideResponse_Handlebars_WithBodyAsJson_ResultAsNormalString()
|
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
string jsonString = "{ \"name\": \"WireMock\" }";
|
string jsonString = "{ \"name\": \"WireMock\" }";
|
||||||
@@ -370,7 +494,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBodyAsJson("test")
|
.WithBodyAsJson("test")
|
||||||
.WithTransformer();
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
@@ -379,8 +503,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
Check.That(JsonConvert.SerializeObject(responseMessage.BodyData.BodyAsJson)).Equals("\"test\"");
|
Check.That(JsonConvert.SerializeObject(responseMessage.BodyData.BodyAsJson)).Equals("\"test\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact(Skip = "todo...")]
|
||||||
public async Task Response_ProvideResponse_Handlebars_WithBodyAsJson_ResultAsHandlebarsString()
|
public async Task Response_ProvideResponse_Handlebars_WithBodyAsJson_ResultAsTemplatedString()
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
string jsonString = "{ \"name\": \"WireMock\" }";
|
string jsonString = "{ \"name\": \"WireMock\" }";
|
||||||
@@ -393,7 +517,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo_object"), "POST", ClientIp, bodyData);
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo_object"), "POST", ClientIp, bodyData);
|
||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBodyAsJson("{{{request.bodyAsJson}}}")
|
.WithBodyAsJson("{{{request.BodyAsJson}}}")
|
||||||
.WithTransformer();
|
.WithTransformer();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -403,8 +527,37 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
Check.That(JsonConvert.SerializeObject(responseMessage.BodyData.BodyAsJson)).Equals("{\"name\":\"WireMock\"}");
|
Check.That(JsonConvert.SerializeObject(responseMessage.BodyData.BodyAsJson)).Equals("{\"name\":\"WireMock\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory(Skip = "{{{ }}} Does not work in Scriban")]
|
||||||
public async Task Response_ProvideResponse_Handlebars_WithBodyAsString_KeepsEncoding()
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Scriban_WithBodyAsJson_ResultAsTemplatedString(TransformerType transformerType)
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
string jsonString = "{ \"name\": \"WireMock\" }";
|
||||||
|
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 response = Response.Create()
|
||||||
|
.WithBodyAsJson("{{{request.BodyAsJson}}}")
|
||||||
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(JsonConvert.SerializeObject(responseMessage.BodyData.BodyAsJson)).Equals("{\"name\":\"WireMock\"}");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData(TransformerType.Handlebars)]
|
||||||
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public async Task Response_ProvideResponse_Transformer_WithBodyAsString_KeepsEncoding(TransformerType transformerType)
|
||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
const string text = "my-text";
|
const string text = "my-text";
|
||||||
@@ -418,8 +571,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
|||||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo_object"), "POST", ClientIp, bodyData);
|
var request = new RequestMessage(new UrlDetails("http://localhost/foo_object"), "POST", ClientIp, bodyData);
|
||||||
|
|
||||||
var response = Response.Create()
|
var response = Response.Create()
|
||||||
.WithBody("{{request.body}}", BodyDestinationFormat.SameAsSource, enc)
|
.WithBody("{{request.Body}}", BodyDestinationFormat.SameAsSource, enc)
|
||||||
.WithTransformer();
|
.WithTransformer(transformerType);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
var responseMessage = await response.ProvideResponseAsync(request, _settings);
|
||||||
@@ -20,6 +20,50 @@ namespace WireMock.Net.Tests.Serialization
|
|||||||
_sut = new MatcherMapper(_settings);
|
_sut = new MatcherMapper(_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void MatcherModelMapper_Map_CSharpCodeMatcher()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var model = new MatcherModel
|
||||||
|
{
|
||||||
|
Name = "CSharpCodeMatcher",
|
||||||
|
Patterns = new[] { "return it == \"x\";" }
|
||||||
|
};
|
||||||
|
var sut = new MatcherMapper(new WireMockServerSettings { AllowCSharpCodeMatcher = true });
|
||||||
|
|
||||||
|
// Act 1
|
||||||
|
var matcher1 = (ICSharpCodeMatcher)sut.Map(model);
|
||||||
|
|
||||||
|
// Assert 1
|
||||||
|
matcher1.Should().NotBeNull();
|
||||||
|
matcher1.IsMatch("x").Should().Be(1.0d);
|
||||||
|
|
||||||
|
// Act 2
|
||||||
|
var matcher2 = (ICSharpCodeMatcher)sut.Map(model);
|
||||||
|
|
||||||
|
// Assert 2
|
||||||
|
matcher2.Should().NotBeNull();
|
||||||
|
matcher2.IsMatch("x").Should().Be(1.0d);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void MatcherModelMapper_Map_CSharpCodeMatcher_NotAllowed_ThrowsException()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var model = new MatcherModel
|
||||||
|
{
|
||||||
|
Name = "CSharpCodeMatcher",
|
||||||
|
Patterns = new[] { "x" }
|
||||||
|
};
|
||||||
|
var sut = new MatcherMapper(new WireMockServerSettings { AllowCSharpCodeMatcher = false });
|
||||||
|
|
||||||
|
// Act
|
||||||
|
Action action = () => sut.Map(model);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
action.Should().Throw<NotSupportedException>();
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void MatcherModelMapper_Map_Null()
|
public void MatcherModelMapper_Map_Null()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ using HandlebarsDotNet;
|
|||||||
using Moq;
|
using Moq;
|
||||||
using System;
|
using System;
|
||||||
using WireMock.Handlers;
|
using WireMock.Handlers;
|
||||||
using WireMock.Transformers;
|
using WireMock.Transformers.Handlebars;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace WireMock.Net.Tests.Transformers
|
namespace WireMock.Net.Tests.Transformers.Handlebars
|
||||||
{
|
{
|
||||||
public class HandlebarsContextFactoryTests
|
public class HandlebarsContextFactoryTests
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
|
using WireMock.Handlers;
|
||||||
|
using WireMock.Transformers.Scriban;
|
||||||
|
using WireMock.Types;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace WireMock.Net.Tests.Transformers.Scriban
|
||||||
|
{
|
||||||
|
public class ScribanContextFactoryTests
|
||||||
|
{
|
||||||
|
private readonly Mock<IFileSystemHandler> _fileSystemHandlerMock = new Mock<IFileSystemHandler>();
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData(TransformerType.Scriban)]
|
||||||
|
[InlineData(TransformerType.ScribanDotLiquid)]
|
||||||
|
public void Create_With_Scriban_TransformerType_Creates_ITransformerContext(TransformerType transformerType)
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var sut = new ScribanContextFactory(_fileSystemHandlerMock.Object, transformerType);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = sut.Create();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().NotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Create_With_Invalid_TransformerType_Throws_Exception()
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
Action action = () => new ScribanContextFactory(_fileSystemHandlerMock.Object, TransformerType.Handlebars);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
action.Should().Throw<Exception>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Authors>Stef Heyenrath</Authors>
|
<Authors>Stef Heyenrath</Authors>
|
||||||
<TargetFrameworks>net452;netcoreapp3.1;net5.0</TargetFrameworks>
|
<TargetFrameworks>net452;net461;netcoreapp3.1;net5.0</TargetFrameworks>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<AssemblyName>WireMock.Net.Tests</AssemblyName>
|
<AssemblyName>WireMock.Net.Tests</AssemblyName>
|
||||||
@@ -26,35 +26,36 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net.FluentAssertions\WireMock.Net.FluentAssertions.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net.FluentAssertions\WireMock.Net.FluentAssertions.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\WireMock.Net.Matchers.CSharpCode\WireMock.Net.Matchers.CSharpCode.csproj" />
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net.RestClient\WireMock.Net.RestClient.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net.RestClient\WireMock.Net.RestClient.csproj" />
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Codecov" Version="1.10.0" />
|
<PackageReference Include="Codecov" Version="1.10.0" />
|
||||||
<PackageReference Include="coverlet.msbuild" Version="3.0.0-preview.9">
|
<PackageReference Include="coverlet.msbuild" Version="3.0.2">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="coverlet.collector" Version="3.0.0-preview.9">
|
<PackageReference Include="coverlet.collector" Version="3.0.2">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
||||||
<PackageReference Include="FluentAssertions" Version="5.10.3" />
|
<PackageReference Include="FluentAssertions" Version="5.10.3" />
|
||||||
<PackageReference Include="Moq" Version="4.13.1" />
|
<PackageReference Include="Moq" Version="4.16.0" />
|
||||||
<PackageReference Include="System.Threading" Version="4.3.0" />
|
<PackageReference Include="System.Threading" Version="4.3.0" />
|
||||||
<PackageReference Include="RestEase" Version="1.4.10" />
|
<PackageReference Include="RestEase" Version="1.4.10" />
|
||||||
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.12" />
|
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.12" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
<PackageReference Include="NFluent" Version="2.7.0" />
|
<PackageReference Include="NFluent" Version="2.7.1" />
|
||||||
<!--<PackageReference Include="OpenCover" Version="4.7.922" />-->
|
<!--<PackageReference Include="OpenCover" Version="4.7.922" />-->
|
||||||
<!--<PackageReference Include="ReportGenerator" Version="4.8.1" />-->
|
<!--<PackageReference Include="ReportGenerator" Version="4.8.1" />-->
|
||||||
<PackageReference Include="SimMetrics.Net" Version="1.0.5" />
|
<PackageReference Include="SimMetrics.Net" Version="1.0.5" />
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
#if !NET452 && !NET461
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
@@ -553,3 +554,4 @@ namespace WireMock.Net.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
@@ -6,13 +6,16 @@ using System.Net.Http.Headers;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
using NFluent;
|
using NFluent;
|
||||||
using WireMock.Admin.Mappings;
|
using WireMock.Admin.Mappings;
|
||||||
|
using WireMock.Handlers;
|
||||||
using WireMock.Matchers.Request;
|
using WireMock.Matchers.Request;
|
||||||
using WireMock.RequestBuilders;
|
using WireMock.RequestBuilders;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Server;
|
using WireMock.Server;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
|
using WireMock.Util;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace WireMock.Net.Tests
|
namespace WireMock.Net.Tests
|
||||||
@@ -50,6 +53,105 @@ namespace WireMock.Net.Tests
|
|||||||
Check.That(server.LogEntries).HasSize(1);
|
Check.That(server.LogEntries).HasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task WireMockServer_Proxy_With_SaveMapping_Is_True_And_SaveMappingToFile_Is_False_Should_AddInternalMappingOnly()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var settings = new WireMockServerSettings
|
||||||
|
{
|
||||||
|
ProxyAndRecordSettings = new ProxyAndRecordSettings
|
||||||
|
{
|
||||||
|
Url = "http://www.google.com",
|
||||||
|
SaveMapping = true,
|
||||||
|
SaveMappingToFile = false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var server = WireMockServer.Start(settings);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var requestMessage = new HttpRequestMessage
|
||||||
|
{
|
||||||
|
Method = HttpMethod.Get,
|
||||||
|
RequestUri = new Uri(server.Urls[0])
|
||||||
|
};
|
||||||
|
var httpClientHandler = new HttpClientHandler { AllowAutoRedirect = false };
|
||||||
|
await new HttpClient(httpClientHandler).SendAsync(requestMessage);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
server.Mappings.Should().HaveCount(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task WireMockServer_Proxy_With_SaveMapping_Is_False_And_SaveMappingToFile_Is_True_ShouldSaveMappingToFile()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var fileSystemHandlerMock = new Mock<IFileSystemHandler>();
|
||||||
|
fileSystemHandlerMock.Setup(f => f.GetMappingFolder()).Returns("m");
|
||||||
|
|
||||||
|
var settings = new WireMockServerSettings
|
||||||
|
{
|
||||||
|
ProxyAndRecordSettings = new ProxyAndRecordSettings
|
||||||
|
{
|
||||||
|
Url = "http://www.google.com",
|
||||||
|
SaveMapping = false,
|
||||||
|
SaveMappingToFile = true
|
||||||
|
},
|
||||||
|
FileSystemHandler = fileSystemHandlerMock.Object
|
||||||
|
};
|
||||||
|
var server = WireMockServer.Start(settings);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var requestMessage = new HttpRequestMessage
|
||||||
|
{
|
||||||
|
Method = HttpMethod.Get,
|
||||||
|
RequestUri = new Uri(server.Urls[0])
|
||||||
|
};
|
||||||
|
var httpClientHandler = new HttpClientHandler { AllowAutoRedirect = false };
|
||||||
|
await new HttpClient(httpClientHandler).SendAsync(requestMessage);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
server.Mappings.Should().HaveCount(1);
|
||||||
|
|
||||||
|
// Verify
|
||||||
|
fileSystemHandlerMock.Verify(f => f.WriteMappingFile(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task WireMockServer_Proxy_With_SaveMappingForStatusCodePattern_Is_False_Should_Not_SaveMapping()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var fileSystemHandlerMock = new Mock<IFileSystemHandler>();
|
||||||
|
fileSystemHandlerMock.Setup(f => f.GetMappingFolder()).Returns("m");
|
||||||
|
|
||||||
|
var settings = new WireMockServerSettings
|
||||||
|
{
|
||||||
|
ProxyAndRecordSettings = new ProxyAndRecordSettings
|
||||||
|
{
|
||||||
|
Url = "http://www.google.com",
|
||||||
|
SaveMapping = true,
|
||||||
|
SaveMappingToFile = true,
|
||||||
|
SaveMappingForStatusCodePattern = "999" // Just make sure that we don't want this mapping
|
||||||
|
},
|
||||||
|
FileSystemHandler = fileSystemHandlerMock.Object
|
||||||
|
};
|
||||||
|
var server = WireMockServer.Start(settings);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var requestMessage = new HttpRequestMessage
|
||||||
|
{
|
||||||
|
Method = HttpMethod.Get,
|
||||||
|
RequestUri = new Uri(server.Urls[0])
|
||||||
|
};
|
||||||
|
var httpClientHandler = new HttpClientHandler { AllowAutoRedirect = false };
|
||||||
|
await new HttpClient(httpClientHandler).SendAsync(requestMessage);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
server.Mappings.Should().HaveCount(1);
|
||||||
|
|
||||||
|
// Verify
|
||||||
|
fileSystemHandlerMock.Verify(f => f.WriteMappingFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task WireMockServer_Proxy_Should_log_proxied_requests()
|
public async Task WireMockServer_Proxy_Should_log_proxied_requests()
|
||||||
{
|
{
|
||||||
@@ -75,8 +177,8 @@ namespace WireMock.Net.Tests
|
|||||||
await new HttpClient(httpClientHandler).SendAsync(requestMessage);
|
await new HttpClient(httpClientHandler).SendAsync(requestMessage);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Check.That(server.Mappings).HasSize(2);
|
server.Mappings.Should().HaveCount(2);
|
||||||
Check.That(server.LogEntries).HasSize(1);
|
server.LogEntries.Should().HaveCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -148,10 +250,56 @@ namespace WireMock.Net.Tests
|
|||||||
|
|
||||||
// check that new proxied mapping is added
|
// check that new proxied mapping is added
|
||||||
Check.That(server.Mappings).HasSize(2);
|
Check.That(server.Mappings).HasSize(2);
|
||||||
|
}
|
||||||
|
|
||||||
//var newMapping = _server.Mappings.First(m => m.Guid != guid);
|
[Fact]
|
||||||
//var matcher = ((Request)newMapping.RequestMatcher).GetRequestMessageMatchers<RequestMessageHeaderMatcher>().FirstOrDefault(m => m.Name == "bbb");
|
public async Task WireMockServer_Proxy_Should_preserve_Authorization_header_in_proxied_request()
|
||||||
//Check.That(matcher).IsNotNull();
|
{
|
||||||
|
// Assign
|
||||||
|
string path = $"/prx_{Guid.NewGuid()}";
|
||||||
|
var serverForProxyForwarding = WireMockServer.Start();
|
||||||
|
serverForProxyForwarding
|
||||||
|
.Given(Request.Create().WithPath(path))
|
||||||
|
.RespondWith(Response.Create().WithCallback(x => new ResponseMessage
|
||||||
|
{
|
||||||
|
BodyData = new BodyData
|
||||||
|
{
|
||||||
|
BodyAsString = x.Headers["Authorization"].ToString(),
|
||||||
|
DetectedBodyType = Types.BodyType.String
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
var settings = new WireMockServerSettings
|
||||||
|
{
|
||||||
|
ProxyAndRecordSettings = new ProxyAndRecordSettings
|
||||||
|
{
|
||||||
|
Url = serverForProxyForwarding.Urls[0],
|
||||||
|
SaveMapping = true,
|
||||||
|
SaveMappingToFile = false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var server = WireMockServer.Start(settings);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var requestMessage = new HttpRequestMessage
|
||||||
|
{
|
||||||
|
Method = HttpMethod.Post,
|
||||||
|
RequestUri = new Uri($"{server.Urls[0]}{path}"),
|
||||||
|
Content = new StringContent("stringContent", Encoding.ASCII)
|
||||||
|
};
|
||||||
|
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("BASIC", "test-A");
|
||||||
|
var result = await new HttpClient().SendAsync(requestMessage);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
(await result.Content.ReadAsStringAsync()).Should().Be("BASIC test-A");
|
||||||
|
|
||||||
|
var receivedRequest = serverForProxyForwarding.LogEntries.First().RequestMessage;
|
||||||
|
var authorizationHeader = receivedRequest.Headers["Authorization"].ToString().Should().Be("BASIC test-A");
|
||||||
|
|
||||||
|
server.Mappings.Should().HaveCount(2);
|
||||||
|
var authorizationRequestMessageHeaderMatcher = ((Request)server.Mappings.Single(m => !m.IsAdminInterface).RequestMatcher)
|
||||||
|
.GetRequestMessageMatcher<RequestMessageHeaderMatcher>(x => x.Matchers.Any(m => m.GetPatterns().Contains("BASIC test-A")));
|
||||||
|
authorizationRequestMessageHeaderMatcher.Should().NotBeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ namespace WireMock.Net.Tests
|
|||||||
server.Stop();
|
server.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !NET452
|
#if !NET452 && !NET461
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("TRACE")]
|
[InlineData("TRACE")]
|
||||||
[InlineData("GET")]
|
[InlineData("GET")]
|
||||||
|
|||||||
Reference in New Issue
Block a user