Compare commits

..

10 Commits

Author SHA1 Message Date
Stef Heyenrath
4bfb97b192 wip 2020-10-12 21:48:37 +02:00
Crossbow78
477f3b5cd3 Apply ILogger, IOptions, IHostedService patterns to .NET Core 3.1 example (#514) 2020-10-06 12:24:45 +02:00
Stef Heyenrath
b303f7cf89 add example static .json 2020-10-05 14:29:21 +00:00
Stef Heyenrath
0964eb2c2d WireMock.Net.WebApplication.NETCore3 2020-10-01 12:32:51 +00:00
Stef Heyenrath
5f8bdff936 1.3.1 2020-09-30 18:18:33 +02:00
Anthony Iacono
942fc3a385 Adding netcoreapp3.1 as a target framework (#509)
* Adding netcoreapp3.0 and netcoreapp3.1 as a target framework

* Expanding NETSTANDARD check to include ASP.NET Core targets

* End of life netcoreapp3.0 changes and using NETCOREAPP3_1 instead of USE_ASPNETCORE where possible
2020-09-30 18:11:32 +02:00
Stef Heyenrath
2f5298b0a2 1.3.0 2020-09-29 12:21:14 +00:00
Stef Heyenrath
55cf0f0416 Fix vulnerability in NuGet dependencies (#508)
* .

* .

* test

* Microsoft.AspNetCore.Server.IIS
2020-09-29 14:16:01 +02:00
Stef Heyenrath
76f0ac6465 WireMock (java version) 2020-09-28 17:11:15 +02:00
Stef Heyenrath
7abf56eafa Fix Sonarqube issues 2020-08-13 14:14:04 +02:00
82 changed files with 1221 additions and 888 deletions

View File

@@ -16,7 +16,7 @@ A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Is your feature request supported by [Handlebarsjs](https://handlebarsjs.com/)? Please provide details.**
**Is your feature request supported by [WireMock (java version)](https://www.wiremock.org)? Please provide details.**
Provide relevant information if requested feature is supported in [Handlebarsjs](https://handlebarsjs.com/) but is missing in our implementation.
**Additional context**

View File

@@ -1,3 +1,11 @@
# 1.3.1 (30 September 2020)
- [#509](https://github.com/WireMock-Net/WireMock.Net/pull/509) - Adding netcoreapp3.1 as a target framework [feature] contributed by [APIWT](https://github.com/APIWT)
# 1.3.0 (29 September 2020)
- [#508](https://github.com/WireMock-Net/WireMock.Net/pull/508) - Fix vulnerability in NuGet dependencies contributed by [StefH](https://github.com/StefH)
- [#327](https://github.com/WireMock-Net/WireMock.Net/issues/327) - Index must be within the bounds of the List - Bug [bug]
- [#507](https://github.com/WireMock-Net/WireMock.Net/issues/507) - Fix vulnerability found in Microsoft.AspNetCore dependency [feature]
# 1.2.18 (13 August 2020)
- [#496](https://github.com/WireMock-Net/WireMock.Net/pull/496) - Add setting to handle requests synchronously [feature] contributed by [StefH](https://github.com/StefH)
- [#500](https://github.com/WireMock-Net/WireMock.Net/pull/500) - Add ThrowExceptionWhenMatcherFails option to all Matchers [feature] contributed by [StefH](https://github.com/StefH)

View File

@@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>1.2.18</VersionPrefix>
<VersionPrefix>1.3.1</VersionPrefix>
<PackageReleaseNotes>See CHANGELOG.md</PackageReleaseNotes>
<PackageIconUrl>https://raw.githubusercontent.com/WireMock-Net/WireMock.Net/master/WireMock.Net-Logo.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>

View File

@@ -1,3 +1,3 @@
https://github.com/StefH/GitHubReleaseNotes
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.2.18
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.3.1

View File

@@ -47,8 +47,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.StandAlone.NET
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.StandAlone.Net452", "examples\WireMock.Net.StandAlone.Net452\WireMock.Net.StandAlone.Net452.csproj", "{668F689E-57B4-422E-8846-C0FF643CA999}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore2", "examples\WireMock.Net.WebApplication\WireMock.Net.WebApplication.NETCore2.csproj", "{049539C1-7A66-4559-AD7A-B1C73B97CBB0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Proxy.Net452", "examples\WireMock.Net.Console.Proxy.Net452\WireMock.Net.Console.Proxy.Net452.csproj", "{26433A8F-BF01-4962-97EB-81BFFBB61096}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.StandAlone.Net461", "examples\WireMock.Net.StandAlone.Net461\WireMock.Net.StandAlone.Net461.csproj", "{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}"
@@ -63,13 +61,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCor
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.RequestLogTest", "examples\WireMock.Net.Console.RequestLogTest\WireMock.Net.Console.RequestLogTest.csproj", "{A9D039B9-7509-4CF1-9EFD-87EB82998575}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Client.Net472", "examples\WireMock.Net.Client.Net472\WireMock.Net.Client.Net472.csproj", "{02082E34-DEF2-47D0-AF0B-3326FAA908CE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.OpenApiParser", "src\WireMock.Net.OpenApiParser\WireMock.Net.OpenApiParser.csproj", "{D3804228-91F4-4502-9595-39584E5AADAD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.OpenApiParser.ConsoleApp", "examples\WireMock.Net.OpenApiParser.ConsoleApp\WireMock.Net.OpenApiParser.ConsoleApp.csproj", "{5C09FB93-1535-4F92-AF26-21E8A061EE4A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.FluentAssertions", "src\WireMock.Net.FluentAssertions\WireMock.Net.FluentAssertions.csproj", "{2C837E73-5EDD-43AD-B65A-194E4A3AD9FE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.FluentAssertions", "src\WireMock.Net.FluentAssertions\WireMock.Net.FluentAssertions.csproj", "{B6269AAC-170A-4346-8B9A-579DED3D9A95}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore2", "examples\WireMock.Net.WebApplication.NETCore2\WireMock.Net.WebApplication.NETCore2.csproj", "{6F38CB3A-6DA1-408A-AECD-E434523C2838}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore3", "examples\WireMock.Net.WebApplication.NETCore3\WireMock.Net.WebApplication.NETCore3.csproj", "{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -125,10 +125,6 @@ Global
{668F689E-57B4-422E-8846-C0FF643CA999}.Debug|Any CPU.Build.0 = Debug|Any CPU
{668F689E-57B4-422E-8846-C0FF643CA999}.Release|Any CPU.ActiveCfg = Release|Any CPU
{668F689E-57B4-422E-8846-C0FF643CA999}.Release|Any CPU.Build.0 = Release|Any CPU
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Release|Any CPU.Build.0 = Release|Any CPU
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -157,10 +153,6 @@ Global
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Release|Any CPU.Build.0 = Release|Any CPU
{02082E34-DEF2-47D0-AF0B-3326FAA908CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02082E34-DEF2-47D0-AF0B-3326FAA908CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02082E34-DEF2-47D0-AF0B-3326FAA908CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02082E34-DEF2-47D0-AF0B-3326FAA908CE}.Release|Any CPU.Build.0 = Release|Any CPU
{D3804228-91F4-4502-9595-39584E5AADAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3804228-91F4-4502-9595-39584E5AADAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3804228-91F4-4502-9595-39584E5AADAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -169,10 +161,18 @@ Global
{5C09FB93-1535-4F92-AF26-21E8A061EE4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C09FB93-1535-4F92-AF26-21E8A061EE4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C09FB93-1535-4F92-AF26-21E8A061EE4A}.Release|Any CPU.Build.0 = Release|Any CPU
{2C837E73-5EDD-43AD-B65A-194E4A3AD9FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C837E73-5EDD-43AD-B65A-194E4A3AD9FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C837E73-5EDD-43AD-B65A-194E4A3AD9FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C837E73-5EDD-43AD-B65A-194E4A3AD9FE}.Release|Any CPU.Build.0 = Release|Any CPU
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.Build.0 = Release|Any CPU
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Release|Any CPU.Build.0 = Release|Any CPU
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -190,7 +190,6 @@ Global
{1995E414-F197-4AB4-90C2-68D806B5AF59} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{10E16614-61CA-48D8-8BDD-664C13913DED} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{668F689E-57B4-422E-8846-C0FF643CA999} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{049539C1-7A66-4559-AD7A-B1C73B97CBB0} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{26433A8F-BF01-4962-97EB-81BFFBB61096} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{7F0B2446-0363-4720-AF46-F47F83B557DC} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
@@ -198,10 +197,11 @@ Global
{668F689E-57B4-422E-8846-C0FF643CA268} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{83645809-9E01-4E81-8733-BA9497554ABF} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{A9D039B9-7509-4CF1-9EFD-87EB82998575} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{02082E34-DEF2-47D0-AF0B-3326FAA908CE} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{D3804228-91F4-4502-9595-39584E5AADAD} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
{5C09FB93-1535-4F92-AF26-21E8A061EE4A} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{2C837E73-5EDD-43AD-B65A-194E4A3AD9FE} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
{B6269AAC-170A-4346-8B9A-579DED3D9A95} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
{6F38CB3A-6DA1-408A-AECD-E434523C2838} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458}

View File

@@ -133,7 +133,7 @@ namespace WireMock.Net.ConsoleApplication
.WithPath("/proxy-execute-keep-alive")
)
.RespondWith(Response.Create()
.WithProxy(new ProxyAndRecordSettings { Url = "http://localhost:9999", BlackListedHeaders = new[] { "Keep-Alive" } })
.WithProxy(new ProxyAndRecordSettings { Url = "http://localhost:9999", ExcludedHeaders = new[] { "Keep-Alive" } })
.WithHeader("Keep-Alive-Test", "stef")
);

View File

@@ -28,7 +28,7 @@ namespace WireMock.Net.Console.Proxy.NETCoreApp2
//ClientX509Certificate2ThumbprintOrSubjectName = "www.yourclientcertname.com OR yourcertificatethumbprint (only if the service you're proxying to requires it)",
SaveMapping = true,
SaveMappingToFile = false,
BlackListedHeaders = new[] { "dnt", "Content-Length" }
ExcludedHeaders = new[] { "dnt", "Content-Length" }
}
});

View File

@@ -22,7 +22,7 @@ namespace WireMock.Net.Console.Proxy.Net452
//ClientX509Certificate2ThumbprintOrSubjectName = "www.yourclientcertname.com OR yourcertificatethumbprint (only if the service you're proxying to requires it)",
SaveMapping = true,
SaveMappingToFile = false,
BlackListedHeaders = new[] { "dnt", "Content-Length" }
ExcludedHeaders = new[] { "dnt", "Content-Length" }
}
});

View File

@@ -19,7 +19,7 @@ namespace WireMock.Net.Console.Proxy.NETCoreApp
//ClientX509Certificate2ThumbprintOrSubjectName = "www.yourclientcertname.com OR yourcertificatethumbprint (only if the service you're proxying to requires it)",
SaveMapping = true,
SaveMappingToFile = false,
BlackListedHeaders = new [] { "dnt", "Content-Length" }
ExcludedHeaders = new [] { "dnt", "Content-Length" }
}
});

View File

@@ -14,7 +14,7 @@ namespace WireMock.Net.Console.RequestLogTest
{
static async Task Main(string[] args)
{
var server = StandAloneApp.Start(new FluentMockServerSettings
var server = StandAloneApp.Start(new WireMockServerSettings
{
Port = 19019,
StartAdminInterface = true,

View File

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

View File

@@ -13,5 +13,5 @@
<package id="Owin" version="1.0" targetFramework="net452" />
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net452" />
<package id="System.Net.Http" version="4.3.3" targetFramework="net452" />
<package id="XPath2" version="1.0.10" targetFramework="net452" />
<package id="XPath2" version="1.1.0" targetFramework="net452" />
</packages>

View File

@@ -280,8 +280,8 @@
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="XPath2, Version=1.0.7.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
<HintPath>..\..\packages\XPath2.1.0.6.1\lib\net40\XPath2.dll</HintPath>
<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>
</ItemGroup>
<ItemGroup>

View File

@@ -78,5 +78,5 @@
<package id="System.Security.Principal.Windows" version="4.5.1" targetFramework="net461" />
<package id="System.Text.Encodings.Web" version="4.5.0" targetFramework="net461" />
<package id="System.Threading.Tasks.Extensions" version="4.5.1" targetFramework="net461" />
<package id="XPath2" version="1.0.6.1" targetFramework="net461" />
<package id="XPath2" version="1.1.0" targetFramework="net461" />
</packages>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

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

View File

@@ -0,0 +1,28 @@
using Microsoft.Extensions.Hosting;
using System.Threading;
using System.Threading.Tasks;
namespace WireMock.Net.WebApplication
{
public class App : IHostedService
{
private readonly IWireMockService _service;
public App(IWireMockService service)
{
_service = service;
}
public Task StartAsync(CancellationToken cancellationToken)
{
_service.Start();
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
_service.Stop();
return Task.CompletedTask;
}
}
}

View File

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

View File

@@ -0,0 +1,30 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using WireMock.Settings;
namespace WireMock.Net.WebApplication
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
private static IHostBuilder CreateHostBuilder(string[] args)
=> Host.CreateDefaultBuilder(args)
.ConfigureServices((host, services) => ConfigureServices(services, host.Configuration));
private static void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddLogging(logging => logging.AddConsole().AddDebug());
services.AddTransient<IWireMockService, WireMockService>();
services.Configure<WireMockServerSettings>(configuration.GetSection("WireMockServerSettings"));
services.AddHostedService<App>();
}
}
}

View File

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

View File

@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<StartupObject>WireMock.Net.WebApplication.Program</StartupObject>
<AssemblyName>WireMock.Net.WebApplication</AssemblyName>
<RootNamespace>WireMock.Net.WebApplication</RootNamespace>
<UserSecretsId>efcf4a18-fd7c-4622-1111-336d65290599</UserSecretsId>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>
<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>
<ItemGroup>
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,82 @@
using System;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using WireMock.Admin.Requests;
using WireMock.Logging;
using WireMock.Server;
using WireMock.Settings;
namespace WireMock.Net.WebApplication
{
public class WireMockService : IWireMockService
{
private WireMockServer _server;
private readonly ILogger _logger;
private readonly WireMockServerSettings _settings;
private class Logger : IWireMockLogger
{
private readonly ILogger _logger;
public Logger(ILogger logger)
{
_logger = logger;
}
public void Debug(string formatString, params object[] args)
{
_logger.LogDebug(formatString, args);
}
public void Info(string formatString, params object[] args)
{
_logger.LogInformation(formatString, args);
}
public void Warn(string formatString, params object[] args)
{
_logger.LogWarning(formatString, args);
}
public void Error(string formatString, params object[] args)
{
_logger.LogError(formatString, args);
}
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminrequest)
{
string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented);
_logger.LogDebug("Admin[{0}] {1}", isAdminrequest, message);
}
public void Error(string formatString, Exception exception)
{
_logger.LogError(formatString, exception.Message);
}
}
public WireMockService(ILogger<WireMockService> logger, IOptions<WireMockServerSettings> settings)
{
_logger = logger;
_settings = settings.Value;
_settings.Logger = new Logger(logger);
}
public void Start()
{
_logger.LogInformation("WireMock.Net server starting");
_server = WireMockServer.Start(_settings);
_logger.LogInformation($"WireMock.Net server settings {JsonConvert.SerializeObject(_settings)}");
}
public void Stop()
{
_logger.LogInformation("WireMock.Net server stopping");
_server?.Stop();
}
}
}

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

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

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<ProjectGuid>049539c1-7a66-4559-ad7a-b1c73b97cbb0</ProjectGuid>
<SelfContained>true</SelfContained>
<_IsPortable>false</_IsPortable>
<MSDeployServiceURL>localhost</MSDeployServiceURL>
<DeployIisAppPath>Default Web Site/wiremock1</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>InProc</MSDeployPublishMethod>
<EnableMSDeployBackup>False</EnableMSDeployBackup>
<UserName />
<_SavePWD>False</_SavePWD>
<PublishDatabaseSettings>
<Objects xmlns="" />
</PublishDatabaseSettings>
</PropertyGroup>
</Project>

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<ProjectGuid>049539c1-7a66-4559-ad7a-b1c73b97cbb1</ProjectGuid>
<SelfContained>true</SelfContained>
<_IsPortable>false</_IsPortable>
<MSDeployServiceURL>localhost</MSDeployServiceURL>
<DeployIisAppPath>Default Web Site/wiremock2</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>InProc</MSDeployPublishMethod>
<EnableMSDeployBackup>False</EnableMSDeployBackup>
<UserName />
<_SavePWD>False</_SavePWD>
<PublishDatabaseSettings>
<Objects xmlns="" />
</PublishDatabaseSettings>
</PropertyGroup>
</Project>

View File

@@ -45,7 +45,18 @@ namespace WireMock
/// </summary>
object StatusCode { get; }
//void AddHeader(string name, params string[] values);
//void AddHeader(string name, string value);
/// <summary>
/// Adds the header.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="value">The value.</param>
void AddHeader(string name, string value);
/// <summary>
/// Adds the header.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="values">The values.</param>
void AddHeader(string name, params string[] values);
}
}

View File

@@ -3,78 +3,54 @@ using WireMock.Matchers.Request;
namespace WireMock.Logging
{
/// <summary>
/// ILogEntry
/// </summary>
public interface ILogEntry
{
/// <summary>
/// Gets the unique identifier.
/// </summary>
/// <value>
/// The unique identifier.
/// </value>
Guid Guid { get; }
/// <summary>
/// Gets the mapping unique identifier.
/// </summary>
/// <value>
/// The mapping unique identifier.
/// </value>
Guid? MappingGuid { get; }
/// <summary>
/// Gets the mapping unique title.
/// </summary>
/// <value>
/// The mapping unique title.
/// </value>
string MappingTitle { get; }
/// <summary>
/// Gets the partial mapping unique identifier.
/// </summary>
/// <value>
/// The mapping unique identifier.
/// </value>
Guid? PartialMappingGuid { get; }
/// <summary>
/// Gets the partial mapping unique title.
/// </summary>
/// <value>
/// The mapping unique title.
/// </value>
string PartialMappingTitle { get; }
/// <summary>
/// Gets the partial match result.
/// </summary>
/// <value>
/// The request match result.
/// </value>
IRequestMatchResult PartialMatchResult { get; }
/// <summary>
/// Gets the request match result.
/// </summary>
/// <value>
/// The request match result.
/// </value>
IRequestMatchResult RequestMatchResult { get; }
/// <summary>
/// Gets the request message.
/// </summary>
/// <value>
/// The request message.
/// </value>
IRequestMessage RequestMessage { get; }
/// <summary>
/// Gets the response message.
/// </summary>
/// <value>
/// The response message.
/// </value>
IResponseMessage ResponseMessage { get; }
}
}

View File

@@ -2,10 +2,19 @@
namespace WireMock.Matchers.Request
{
/// <summary>
/// MatchDetail
/// </summary>
public class MatchDetail
{
/// <summary>
/// Gets or sets the type of the matcher.
/// </summary>
public Type MatcherType { get; set; }
/// <summary>
/// Gets or sets the score between 0.0 and 1.0
/// </summary>
public double Score { get; set; }
}
}

View File

@@ -62,9 +62,9 @@ namespace WireMock.Server
void AddGlobalProcessingDelay(TimeSpan delay);
/// <summary>
/// Allows the partial mapping.
/// Set the partial mapping to allowed (if true, you can also provide 'enforceHttpMethod').
/// </summary>
void AllowPartialMapping(bool allow = true);
void AllowPartialMapping(bool allow = true, bool enforceHttpMethod = false);
/// <summary>
/// Deletes a LogEntry.

View File

@@ -4,7 +4,7 @@
<Description>Commonly used interfaces, models, enumerations and types.</Description>
<AssemblyTitle>WireMock.Net.Abstractions</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>netstandard1.0;netstandard2.0;netstandard2.1;net45</TargetFrameworks>
<TargetFrameworks>net45;netstandard1.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.Abstractions</AssemblyName>
<PackageId>WireMock.Net.Abstractions</PackageId>

View File

@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!--<Version>1.2.13-preview-01</Version>-->
<Description>FluentAssertions extensions for WireMock.Net</Description>
<AssemblyTitle>WireMock.Net.FluentAssertions</AssemblyTitle>
<Authors>Mahmoud Ali;Stef Heyenrath</Authors>
<TargetFrameworks>netstandard1.3;netstandard2.0;netstandard2.1;net451</TargetFrameworks>
<TargetFrameworks>net451;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.FluentAssertions</AssemblyName>
<PackageId>WireMock.Net.FluentAssertions</PackageId>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<Description>An OpenApi (swagger) parser to generate MappingModel or mapping.json file.</Description>
<TargetFrameworks>net46;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net46;netstandard2.0;netstandard2.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>wiremock;openapi;OAS;converter;parser;openapiparser</PackageTags>
<ProjectGuid>{D3804228-91F4-4502-9595-39584E5AADAD}</ProjectGuid>
@@ -19,7 +19,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.2.0" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.2.3" />
<PackageReference Include="RamlToOpenApiConverter" Version="0.1.1" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />

View File

@@ -4,7 +4,7 @@
<Description>A RestClient using RestEase to access the admin interface.</Description>
<AssemblyTitle>WireMock.Net.RestClient</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>netstandard1.1;netstandard2.0;netstandard2.1;net45</TargetFrameworks>
<TargetFrameworks>net45;netstandard1.1;netstandard2.0;netstandard2.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.RestClient</AssemblyName>
<PackageId>WireMock.Net.RestClient</PackageId>

View File

@@ -3,7 +3,7 @@
<Description>Lightweight StandAlone Http Mocking Server for .Net.</Description>
<AssemblyTitle>WireMock.Net.StandAlone</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.StandAlone</AssemblyName>
<PackageId>WireMock.Net.StandAlone</PackageId>

View File

@@ -13,7 +13,7 @@ namespace WireMock.Http
{
public static HttpClient CreateHttpClient(IProxyAndRecordSettings settings)
{
#if NETSTANDARD
#if NETSTANDARD || NETCOREAPP3_1
var handler = new HttpClientHandler
{
CheckCertificateRevocationList = false,

View File

@@ -151,7 +151,7 @@ namespace WireMock.Matchers
throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper", ex);
}
#elif (NETSTANDARD2_0 || NETSTANDARD2_1)
#elif (NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP3_1)
dynamic script;
try
{

View File

@@ -4,6 +4,7 @@ using WireMock.Handlers;
using WireMock.Logging;
using WireMock.Matchers;
using WireMock.Util;
using WireMock.Settings;
#if !USE_ASPNETCORE
using Owin;
#else
@@ -22,6 +23,8 @@ namespace WireMock.Owin
bool? AllowPartialMapping { get; set; }
IPartialMappingSettings PartialMappingSettings { get; set; }
ConcurrentDictionary<Guid, IMapping> Mappings { get; }
ConcurrentDictionary<string, ScenarioState> Scenarios { get; }

View File

@@ -7,8 +7,6 @@ using System.Threading.Tasks;
using Newtonsoft.Json;
using RandomDataGenerator.FieldOptions;
using RandomDataGenerator.Randomizers;
using WireMock.Exceptions;
using WireMock.Handlers;
using WireMock.Http;
using WireMock.ResponseBuilders;
using WireMock.Types;

View File

@@ -42,6 +42,16 @@ namespace WireMock.Owin
.OrderBy(m => m.RequestMatchResult)
.ThenBy(m => m.Mapping.Priority)
.ToList();
if (_options.PartialMappingSettings?.EnforceHttpMethod == true)
{
// Check if any partialMappings contain a HttpMethodMatcher, and check if this returns a 0
foreach (var partialMapping in partialMappings)
{
}
}
var partialMatch = partialMappings.FirstOrDefault(pm => pm.RequestMatchResult.AverageTotalScore > 0.0);
if (_options.AllowPartialMapping == true)

View File

@@ -2,9 +2,7 @@ using System;
using System.Threading.Tasks;
using WireMock.Logging;
using System.Linq;
using System.Text.RegularExpressions;
using WireMock.Matchers;
using Newtonsoft.Json;
using WireMock.Http;
using WireMock.Owin.Mappers;
using WireMock.Serialization;

View File

@@ -1,10 +1,10 @@
using System;
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using WireMock.Handlers;
using WireMock.Logging;
using WireMock.Matchers;
using WireMock.Util;
using WireMock.Settings;
#if !USE_ASPNETCORE
using Owin;
#else
@@ -23,6 +23,8 @@ namespace WireMock.Owin
public bool? AllowPartialMapping { get; set; }
public IPartialMappingSettings PartialMappingSettings { get; set; }
public ConcurrentDictionary<Guid, IMapping> Mappings { get; } = new ConcurrentDictionary<Guid, IMapping>();
public ConcurrentDictionary<string, ScenarioState> Scenarios { get; } = new ConcurrentDictionary<string, ScenarioState>();

View File

@@ -60,7 +60,7 @@ namespace WireMock.ResponseBuilders
[PublicAPI]
public static IResponseBuilder Create([CanBeNull] ResponseMessage responseMessage = null)
{
var message = responseMessage ?? new ResponseMessage(); // { StatusCode = (int)HttpStatusCode.OK };
var message = responseMessage ?? new ResponseMessage();
return new Response(message);
}

View File

@@ -35,21 +35,13 @@ namespace WireMock
/// <inheritdoc cref="IResponseMessage.FaultPercentage" />
public double? FaultPercentage { get; set; }
/// <summary>
/// Adds the header.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="value">The value.</param>
/// <inheritdoc cref="IResponseMessage.AddHeader(string, string)" />
public void AddHeader(string name, string value)
{
Headers.Add(name, new WireMockList<string>(value));
}
/// <summary>
/// Adds the header.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="values">The values.</param>
/// <inheritdoc cref="IResponseMessage.AddHeader(string, string[])" />
public void AddHeader(string name, params string[] values)
{
Check.NotNullOrEmpty(values, nameof(values));

View File

@@ -95,21 +95,6 @@ namespace WireMock.Serialization
}
}
private ExactObjectMatcher CreateExactObjectMatcher(MatchBehaviour matchBehaviour, string stringPattern, bool throwException)
{
byte[] bytePattern;
try
{
bytePattern = Convert.FromBase64String(stringPattern);
}
catch
{
throw new ArgumentException($"Matcher 'ExactObjectMatcher' has invalid pattern. The pattern value '{stringPattern}' is not a Base64String.", nameof(stringPattern));
}
return new ExactObjectMatcher(matchBehaviour, bytePattern, throwException);
}
public MatcherModel[] Map([CanBeNull] IEnumerable<IMatcher> matchers)
{
return matchers?.Select(Map).Where(m => m != null).ToArray();
@@ -154,5 +139,20 @@ namespace WireMock.Serialization
Patterns = patterns.Length > 1 ? patterns : null
};
}
private ExactObjectMatcher CreateExactObjectMatcher(MatchBehaviour matchBehaviour, string stringPattern, bool throwException)
{
byte[] bytePattern;
try
{
bytePattern = Convert.FromBase64String(stringPattern);
}
catch
{
throw new ArgumentException($"Matcher 'ExactObjectMatcher' has invalid pattern. The pattern value '{stringPattern}' is not a Base64String.", nameof(stringPattern));
}
return new ExactObjectMatcher(matchBehaviour, bytePattern, throwException);
}
}
}

View File

@@ -1,13 +0,0 @@
using System;
using WireMock.Settings;
namespace WireMock.Server
{
[Obsolete("Use WireMockServer. This will removed in next version (1.3.x)")]
public class FluentMockServer : WireMockServer
{
public FluentMockServer(IFluentMockServerSettings settings) : base((IWireMockServerSettings) settings)
{
}
}
}

View File

@@ -277,8 +277,8 @@ namespace WireMock.Server
var mapping = ToMapping(
requestMessage,
responseMessage,
settings.ProxyAndRecordSettings.BlackListedHeaders ?? new string[] { },
settings.ProxyAndRecordSettings.BlackListedCookies ?? new string[] { }
settings.ProxyAndRecordSettings.ExcludedHeaders ?? new string[] { },
settings.ProxyAndRecordSettings.ExcludedCookies ?? new string[] { }
);
if (settings.ProxyAndRecordSettings.SaveMapping)
@@ -367,6 +367,7 @@ namespace WireMock.Server
if (settings.AllowPartialMapping != null)
{
_options.AllowPartialMapping = settings.AllowPartialMapping.Value;
// TODO stef _options.PartialMappingSettings = settings.
}
if (settings.GlobalProcessingDelay != null)
@@ -833,9 +834,9 @@ namespace WireMock.Server
if (requestModel.Params != null)
{
foreach (var paramModel in requestModel.Params.Where(c => c.Matchers != null))
foreach (var paramModel in requestModel.Params.Where(p => p != null && p.Matchers != null))
{
bool ignoreCase = paramModel?.IgnoreCase ?? false;
bool ignoreCase = paramModel.IgnoreCase == true;
requestBuilder = requestBuilder.WithParam(paramModel.Name, ignoreCase, paramModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray());
}
}

View File

@@ -184,6 +184,17 @@ namespace WireMock.Server
ReadStaticMappings = true
});
}
/// <summary>
/// Initializes a new instance of the <see cref="WireMockServer"/> class.
/// </summary>
/// <param name="settings">The settings.</param>
/// <exception cref="WireMockException">
/// Service start failed with error: {_httpServer.RunningException.Message}
/// or
/// Service start failed with error: {startTask.Exception.Message}
/// </exception>
/// <exception cref="TimeoutException">Service start timed out after {TimeSpan.FromMilliseconds(settings.StartTimeout)}</exception>
protected WireMockServer(IWireMockServerSettings settings)
{
_settings = settings;
@@ -272,7 +283,7 @@ namespace WireMock.Server
if (settings.AllowPartialMapping == true)
{
AllowPartialMapping();
AllowPartialMapping(true, settings.PartialMappingSettings);
}
if (settings.StartAdminInterface == true)
@@ -378,10 +389,21 @@ namespace WireMock.Server
/// <inheritdoc cref="IWireMockServer.AllowPartialMapping" />
[PublicAPI]
public void AllowPartialMapping(bool allow = true)
public void AllowPartialMapping(bool allow = true, bool enforceHttpMethod = false)
{
AllowPartialMapping(allow, new PartialMappingSettings
{
EnforceHttpMethod = enforceHttpMethod
});
}
/// <inheritdoc cref="IWireMockServer.AllowPartialMapping" />
[PublicAPI]
public void AllowPartialMapping(bool allow = true, IPartialMappingSettings partialMappingSettings = null)
{
_settings.Logger.Info("AllowPartialMapping is set to {0}", allow);
_options.AllowPartialMapping = allow;
_options.PartialMappingSettings = partialMappingSettings;
}
/// <inheritdoc cref="IWireMockServer.SetBasicAuthentication" />
@@ -422,7 +444,7 @@ namespace WireMock.Server
{
_options.Scenarios.Clear();
}
/// <inheritdoc cref="IWireMockServer.WithMapping(MappingModel[])" />
[PublicAPI]
public IWireMockServer WithMapping(params MappingModel[] mappings)

View File

@@ -1,12 +0,0 @@
using System;
namespace WireMock.Settings
{
/// <summary>
/// FluentMockServerSettings
/// </summary>
[Obsolete("Use WireMockServerSettings. This will removed in next version (1.3.x)")]
public class FluentMockServerSettings : WireMockServerSettings
{
}
}

View File

@@ -1,12 +0,0 @@
using System;
namespace WireMock.Settings
{
/// <summary>
/// IFluentMockServerSettings
/// </summary>
[Obsolete("Use IWireMockServerSettings. This will removed in next version (1.3.x)")]
public interface IFluentMockServerSettings : IWireMockServerSettings
{
}
}

View File

@@ -0,0 +1,13 @@
namespace WireMock.Settings
{
/// <summary>
/// IPartialMappingSettings
/// </summary>
public interface IPartialMappingSettings
{
/// <summary>
/// ...
/// </summary>
bool EnforceHttpMethod { get; set; }
}
}

View File

@@ -1,5 +1,4 @@
using System;
using JetBrains.Annotations;
using JetBrains.Annotations;
namespace WireMock.Settings
{
@@ -39,14 +38,12 @@ namespace WireMock.Settings
/// <summary>
/// Defines a list from headers which will be excluded from the saved mappings.
/// </summary>
[Obsolete("Will be renamed to ExcludedHeaders in next version (1.3.x)")]
string[] BlackListedHeaders { get; set; }
string[] ExcludedHeaders { get; set; }
/// <summary>
/// Defines a list of cookies which will be excluded from the saved mappings.
/// </summary>
[Obsolete("Will be renamed to ExcludedCookies in next version (1.3.x)")]
string[] BlackListedCookies { get; set; }
string[] ExcludedCookies { get; set; }
/// <summary>
/// Defines the WebProxySettings.

View File

@@ -1,5 +1,8 @@
namespace WireMock.Settings
{
/// <summary>
/// IWebProxySettings
/// </summary>
public interface IWebProxySettings
{
/// <summary>

View File

@@ -73,6 +73,12 @@ namespace WireMock.Settings
[PublicAPI]
bool? AllowPartialMapping { get; set; }
/// <summary>
/// Gets or sets the partial mapping settings (optional).
/// </summary>
[PublicAPI]
IPartialMappingSettings PartialMappingSettings { get; set; }
/// <summary>
/// The username needed for __admin access.
/// </summary>

View File

@@ -0,0 +1,15 @@
using JetBrains.Annotations;
namespace WireMock.Settings
{
/// <summary>
/// PartialMappingSettings
/// </summary>
/// <seealso cref="IPartialMappingSettings" />
public class PartialMappingSettings : IPartialMappingSettings
{
/// <inheritdoc cref="IPartialMappingSettings.EnforceHttpMethod"/>
[PublicAPI]
public bool EnforceHttpMethod { get; set; }
}
}

View File

@@ -1,5 +1,4 @@
using System;
using JetBrains.Annotations;
using JetBrains.Annotations;
namespace WireMock.Settings
{
@@ -40,15 +39,13 @@ namespace WireMock.Settings
[PublicAPI]
public string ClientX509Certificate2ThumbprintOrSubjectName { get; set; }
/// <inheritdoc cref="IProxyAndRecordSettings.BlackListedHeaders"/>
/// <inheritdoc cref="IProxyAndRecordSettings.ExcludedHeaders"/>
[PublicAPI]
[Obsolete("Will be renamed to ExcludedHeaders in next version (1.3.x)")]
public string[] BlackListedHeaders { get; set; }
public string[] ExcludedHeaders { get; set; }
/// <inheritdoc cref="IProxyAndRecordSettings.BlackListedCookies"/>
/// <inheritdoc cref="IProxyAndRecordSettings.ExcludedCookies"/>
[PublicAPI]
[Obsolete("Will be renamed to ExcludedCookies in next version (1.3.x)")]
public string[] BlackListedCookies { get; set; }
public string[] ExcludedCookies { get; set; }
/// <inheritdoc cref="IProxyAndRecordSettings.WebProxySettings"/>
[PublicAPI]

View File

@@ -2,6 +2,7 @@
namespace WireMock.Settings
{
/// <seealso cref="IWebProxySettings" />
public class WebProxySettings : IWebProxySettings
{
/// <inheritdoc cref="IWebProxySettings.Address"/>

View File

@@ -53,6 +53,10 @@ namespace WireMock.Settings
[PublicAPI]
public bool? AllowPartialMapping { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.PartialMappingSettings"/>
[PublicAPI]
public IPartialMappingSettings PartialMappingSettings { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.AdminUsername"/>
[PublicAPI]
public string AdminUsername { get; set; }

View File

@@ -70,8 +70,8 @@ namespace WireMock.Settings
SaveMappingToFile = parser.GetBoolValue("SaveMappingToFile"),
SaveMappingForStatusCodePattern = parser.GetStringValue("SaveMappingForStatusCodePattern"),
ClientX509Certificate2ThumbprintOrSubjectName = parser.GetStringValue("ClientX509Certificate2ThumbprintOrSubjectName"),
BlackListedHeaders = parser.GetValues("BlackListedHeaders"),
BlackListedCookies = parser.GetValues("BlackListedCookies"),
ExcludedHeaders = parser.GetValues("ExcludedHeaders"),
ExcludedCookies = parser.GetValues("ExcludedCookies"),
AllowAutoRedirect = parser.GetBoolValue("AllowAutoRedirect")
};

View File

@@ -1,9 +1,7 @@
using HandlebarsDotNet;
namespace WireMock.Transformers
namespace WireMock.Transformers
{
interface IHandlebarsContextFactory
{
IHandlebarsContext Create();
}
}
}

View File

@@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using JetBrains.Annotations;
// Copied from https://github.com/aspnet/EntityFramework/blob/dev/src/Shared/Check.cs
@@ -96,19 +95,6 @@ namespace WireMock.Validation
return value;
}
//public static string NullButNotEmpty(string value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName)
//{
// if (!ReferenceEquals(value, null)
// && (value.Length == 0))
// {
// NotNullOrEmpty(parameterName, nameof(parameterName));
// throw new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName));
// }
// return value;
//}
public static IList<T> HasNoNulls<T>(IList<T> value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName)
where T : class
{
@@ -123,17 +109,5 @@ namespace WireMock.Validation
return value;
}
//public static Type ValidEntityType(Type value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName)
//{
// if (!value.GetTypeInfo().IsClass)
// {
// NotNullOrEmpty(parameterName, nameof(parameterName));
// throw new ArgumentException(CoreStrings.InvalidEntityType(value, parameterName));
// }
// return value;
//}
}
}

View File

@@ -3,7 +3,7 @@
<Description>Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape.</Description>
<AssemblyTitle>WireMock.Net</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net</AssemblyName>
<PackageId>WireMock.Net</PackageId>
@@ -42,7 +42,7 @@
<DefineConstants>NETSTANDARD;USE_ASPNETCORE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' or '$(TargetFramework)' == 'netcoreapp2.2'">
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' or '$(TargetFramework)' == 'netcoreapp2.2' or '$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>USE_ASPNETCORE</DefineConstants>
</PropertyGroup>
@@ -56,7 +56,7 @@
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="SimMetrics.Net" Version="1.0.5" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.12" />
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.10" />
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.12" />
<PackageReference Include="JmesPath.Net" Version="1.0.125" />
<PackageReference Include="Handlebars.Net.Helpers" Version="1.0.0" />
</ItemGroup>
@@ -69,7 +69,7 @@
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard1.3' ">
<PackageReference Include="XPath2.Extensions" Version="1.0.6.1" />
<PackageReference Include="XPath2.Extensions" Version="1.1.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
@@ -101,7 +101,11 @@
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.2" />
<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" />
<PackageReference Include="CS-Script" Version="3.29.0" />
</ItemGroup>
@@ -114,17 +118,29 @@
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.4" />
<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" />
<PackageReference Include="CS-Script.Core" Version="1.1.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.4" />
<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" />
<!-- https://github.com/WireMock-Net/WireMock.Net/issues/448 -->
<PackageReference Include="CS-Script.Core" Version="1.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
</ItemGroup>

View File

@@ -1,5 +1,6 @@
using NFluent;
using System.Collections.Generic;
using System.Collections.Generic;
using FluentAssertions;
using NFluent;
using WireMock.Matchers.Request;
using WireMock.Models;
using WireMock.RequestBuilders;
@@ -13,6 +14,34 @@ namespace WireMock.Net.Tests
{
private const string ClientIp = "::1";
[Fact]
public void Should_Match_When_Verb_Does_Match()
{
// Arrange
var requestPut = Request.Create().WithPath("/bar").UsingPut();
// Act
var request = new RequestMessage(new UrlDetails("http://localhost/bar"), "PUT", ClientIp);
// Assert
var requestMatchResult = new RequestMatchResult();
requestPut.GetMatchingScore(request, requestMatchResult).Should().Be(1.0);
}
[Fact]
public void Should_NotMatch_When_Verb_Does_Not_Match()
{
// Arrange
var requestGet = Request.Create().WithPath("/bar").UsingGet();
// Act
var request = new RequestMessage(new UrlDetails("http://localhost/bar"), "PUT", ClientIp);
// Assert
var requestMatchResult = new RequestMatchResult();
requestGet.GetMatchingScore(request, requestMatchResult).Should().Be(0.0);
}
[Fact]
public void Should_exclude_requests_matching_given_http_method_but_not_url()
{

View File

@@ -44,17 +44,17 @@
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="RestEase" Version="1.4.10" />
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.10" />
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Moq" Version="4.14.5" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="NFluent" Version="2.7.0" />
<PackageReference Include="OpenCover" Version="4.7.922" />
<PackageReference Include="ReportGenerator" Version="4.5.4" />
<PackageReference Include="ReportGenerator" Version="4.6.7" />
<PackageReference Include="SimMetrics.Net" Version="1.0.5" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.12" />
<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>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
@@ -80,6 +80,9 @@
<None Update="__admin\mappings\00000002-ee28-4f29-ae63-1ac9b0802d87.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="__admin\mappings\351f0240-bba0-4bcb-93c6-1feba0fe8799.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="__admin\mappings\array.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View File

@@ -48,8 +48,8 @@ namespace WireMock.Net.Tests
string folder = Path.Combine(GetCurrentFolder(), "__admin", "mappings");
server.ReadStaticMappings(folder);
Check.That(server.Mappings).HasSize(5);
Check.That(server.MappingModels).HasSize(5);
Check.That(server.Mappings).HasSize(6);
Check.That(server.MappingModels).HasSize(6);
// Act
server.ResetMappings();
@@ -218,7 +218,7 @@ namespace WireMock.Net.Tests
server.ReadStaticMappings(folder);
var mappings = server.Mappings.ToArray();
Check.That(mappings).HasSize(5);
Check.That(mappings).HasSize(6);
}
[Fact]

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
{
"Guid": "351f0240-bba0-4bcb-93c6-1feba0fe8799",
"Title": "Playground",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/playground",
"IgnoreCase": false
}
]
},
"Methods": [
"POST"
],
"Headers": [
{
"Name": "Content-Type",
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "application/json; charset=utf-8",
"IgnoreCase": true
}
]
},
{
"Name": "Accept",
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "application/json",
"IgnoreCase": true
}
]
},
{
"Name": "Authorization",
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "Bearer 4d911614-fa48-484f-b8e6-98674fd73964",
"IgnoreCase": true
}
]
},
{
"Name": "Content-Length",
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "*",
"IgnoreCase": true
}
]
}
],
"Body": {
"Matcher": {
"Name": "JsonMatcher",
"Pattern": {},
"IgnoreCase": false
}
}
},
"Response": {
"StatusCode": 201,
"BodyAsJson": {},
"Headers": {
"Content-Type": "application/json",
"Connection": "keep-alive"
}
}
}