mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-25 02:05:04 +01:00
Compare commits
66 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c94113308d | ||
|
|
1b1ddeab83 | ||
|
|
d9e3f38fee | ||
|
|
c42c2d5d7a | ||
|
|
d67a160144 | ||
|
|
7033d85e3a | ||
|
|
7d873611ee | ||
|
|
f26bf62a13 | ||
|
|
6938b6f73c | ||
|
|
5b2cd061a6 | ||
|
|
80993c7740 | ||
|
|
d4d0f8becd | ||
|
|
cd613d1c76 | ||
|
|
5f4c688e49 | ||
|
|
e7949a47d9 | ||
|
|
a6cf7a48dc | ||
|
|
bf5afef7a1 | ||
|
|
a8934ec7f9 | ||
|
|
d2ac56e49a | ||
|
|
e8a4d52797 | ||
|
|
dac73b6fe0 | ||
|
|
e91be0a4d1 | ||
|
|
a9974a4874 | ||
|
|
1ddd8ff58f | ||
|
|
5174f9823c | ||
|
|
79da7d042b | ||
|
|
e041e78bc7 | ||
|
|
5809fae602 | ||
|
|
8a295e806c | ||
|
|
d5d9d4bd1b | ||
|
|
5f274f1179 | ||
|
|
8c1cd41df9 | ||
|
|
fe4ad50119 | ||
|
|
bde981b522 | ||
|
|
a1d2deb6a9 | ||
|
|
10dbff2c02 | ||
|
|
68ffcda53b | ||
|
|
aeb95b02d2 | ||
|
|
2dbb984a1e | ||
|
|
88dd1b9aa4 | ||
|
|
87c4344d65 | ||
|
|
2851c820e0 | ||
|
|
13ab37dd3e | ||
|
|
f49046374a | ||
|
|
69488ced5f | ||
|
|
e6bcd625f7 | ||
|
|
d1b42bf436 | ||
|
|
f4861d9bab | ||
|
|
4c01ef4838 | ||
|
|
83866f5719 | ||
|
|
f72c3c33ef | ||
|
|
32248b6585 | ||
|
|
1df4502631 | ||
|
|
5e76a82a21 | ||
|
|
06ae9d72c3 | ||
|
|
307a89d324 | ||
|
|
6ae7fc1d75 | ||
|
|
29e86abe12 | ||
|
|
710fc8dcf6 | ||
|
|
dfbfa5fd35 | ||
|
|
69bbd76ca4 | ||
|
|
bd0c5a83c9 | ||
|
|
a08efe2f78 | ||
|
|
6e151098e5 | ||
|
|
43d481435c | ||
|
|
ea1be6641a |
31
.vscode/launch.json
vendored
31
.vscode/launch.json
vendored
@@ -1,22 +1,11 @@
|
|||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": ".NET Core Launch (WireMock.Net.StandAlone.NETCoreApp)",
|
"name": ".NET Core Attach",
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "attach",
|
||||||
"preLaunchTask": "build_WireMock.Net.StandAlone.NETCoreApp",
|
"processId": "${command:pickProcess}"
|
||||||
"program": "${workspaceRoot}/examples/WireMock.Net.StandAlone.NETCoreApp/bin/Debug/netcoreapp2.0/WireMock.Net.StandAlone.NETCoreApp.dll",
|
}
|
||||||
"args": [],
|
]
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"console": "internalConsole"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": ".NET Core Attach",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "attach",
|
|
||||||
"processId": "${command:pickProcess}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
96
CHANGELOG.md
96
CHANGELOG.md
@@ -1,3 +1,97 @@
|
|||||||
|
# 1.2.12.0 (23 May 2020)
|
||||||
|
- [#472](https://github.com/WireMock-Net/WireMock.Net/pull/472) - Create new .sln contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#473](https://github.com/WireMock-Net/WireMock.Net/pull/473) - Fixed Proxy when using MultipartForm with byte[] [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#468](https://github.com/WireMock-Net/WireMock.Net/issues/468) - Proxy mode: Incorrect handling of multipart requests [bug]
|
||||||
|
|
||||||
|
# 1.2.11.0 (18 May 2020)
|
||||||
|
- [#469](https://github.com/WireMock-Net/WireMock.Net/pull/469) - Fix unhandled exception when target is unavailable [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#467](https://github.com/WireMock-Net/WireMock.Net/issues/467) - Proxy mode: Unhandled exception when target is not working [bug]
|
||||||
|
|
||||||
|
# 1.2.10 (17 May 2020)
|
||||||
|
- [#456](https://github.com/WireMock-Net/WireMock.Net/pull/456) - Include Handlebars.Net.Helpers project [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#457](https://github.com/WireMock-Net/WireMock.Net/pull/457) - Kestrel Options Limits [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#455](https://github.com/WireMock-Net/WireMock.Net/issues/455) - There is no option to increase body size while proxying [bug]
|
||||||
|
|
||||||
|
# 1.2.9.0 (14 May 2020)
|
||||||
|
- [#465](https://github.com/WireMock-Net/WireMock.Net/pull/465) - Fix method ResetMappingsAsync in the RestEase-AdminApi [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#464](https://github.com/WireMock-Net/WireMock.Net/issues/464) - RestClient Admin API Metadata Base Path Duplication [bug]
|
||||||
|
|
||||||
|
# 1.2.8.0 (04 May 2020)
|
||||||
|
- [#463](https://github.com/WireMock-Net/WireMock.Net/pull/463) - GH161: Fix SourceLink support [bug] contributed by [gitfool](https://github.com/gitfool)
|
||||||
|
|
||||||
|
# 1.2.7.0 (30 April 2020)
|
||||||
|
- [#461](https://github.com/WireMock-Net/WireMock.Net/pull/461) - Support Path in ProxyUrl contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#459](https://github.com/WireMock-Net/WireMock.Net/issues/459) - When respond with proxy requestMessage.Url is used, not AbsoluteUrl [bug]
|
||||||
|
|
||||||
|
# 1.2.6.0 (29 April 2020)
|
||||||
|
- [#460](https://github.com/WireMock-Net/WireMock.Net/pull/460) - When using ResponseMessageTransformer : keep BodyEncoding [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#458](https://github.com/WireMock-Net/WireMock.Net/issues/458) - Response BodyAsString loses BodyData.Encoding when UseTransformer = true [bug]
|
||||||
|
|
||||||
|
# 1.2.5.0 (17 April 2020)
|
||||||
|
- [#454](https://github.com/WireMock-Net/WireMock.Net/pull/454) - Fix port = 0 for net452 [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#453](https://github.com/WireMock-Net/WireMock.Net/issues/453) - MockServer not starting [bug]
|
||||||
|
|
||||||
|
# 1.2.4.0 (10 April 2020)
|
||||||
|
- [#439](https://github.com/WireMock-Net/WireMock.Net/pull/439) - Add support for GZip and Deflate [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#444](https://github.com/WireMock-Net/WireMock.Net/pull/444) - Add readme.md + license from mock4net [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#451](https://github.com/WireMock-Net/WireMock.Net/pull/451) - Update NuGet dependencies (e.g. coverage related) to fix CI-build [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#452](https://github.com/WireMock-Net/WireMock.Net/pull/452) - Add ValidatedNotNullAttribute (for SonarQube) [refactor] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#426](https://github.com/WireMock-Net/WireMock.Net/issues/426) - Add support for compressed requests, such as GZIP or DEFLATE [feature]
|
||||||
|
|
||||||
|
# 1.2.3.0 (01 April 2020)
|
||||||
|
- [#449](https://github.com/WireMock-Net/WireMock.Net/pull/449) - Netstandard21 [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#447](https://github.com/WireMock-Net/WireMock.Net/issues/447) - Add support for .NET Standard 2.1 / .NET Core 3.1 [feature]
|
||||||
|
- [#448](https://github.com/WireMock-Net/WireMock.Net/issues/448) - WireMock.Net is not compatible with Microsoft.VisualStudio.Web.CodeGeneration.Design 3.1.1 [bug]
|
||||||
|
|
||||||
|
# 1.2.2.0 (25 March 2020)
|
||||||
|
- [#446](https://github.com/WireMock-Net/WireMock.Net/pull/446) - When port is provided: WireMockServer still takes a random port [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#445](https://github.com/WireMock-Net/WireMock.Net/issues/445) - Port where WireMockServer listens to - v1.2x [bug]
|
||||||
|
|
||||||
|
# 1.2.1.0 (17 March 2020)
|
||||||
|
- [#442](https://github.com/WireMock-Net/WireMock.Net/pull/442) - Fix Null body in handlebars transformation [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
|
||||||
|
# 1.2.0.0 (14 March 2020)
|
||||||
|
- [#417](https://github.com/WireMock-Net/WireMock.Net/pull/417) - Let the .NET core/standard WebHostBuilder use a random port [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#422](https://github.com/WireMock-Net/WireMock.Net/pull/422) - AllowOnlyDefinedHttpStatusCodeInResponse [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#379](https://github.com/WireMock-Net/WireMock.Net/issues/379) - Trusting the self signed certificate to enable SSL on dotnet core [bug]
|
||||||
|
- [#420](https://github.com/WireMock-Net/WireMock.Net/issues/420) - Updating to 1.1.6+ breaks tests because new AllowAnyHttpStatusCodeInResponse option defaults to false [bug]
|
||||||
|
|
||||||
|
# 1.1.10 (05 March 2020)
|
||||||
|
- [#427](https://github.com/WireMock-Net/WireMock.Net/pull/427) - Add UsingOptions, UsingConnect and UsingTrace [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#434](https://github.com/WireMock-Net/WireMock.Net/pull/434) - Option to disable JSON deserialization [feature] contributed by [sebastianmattar](https://github.com/sebastianmattar)
|
||||||
|
- [#435](https://github.com/WireMock-Net/WireMock.Net/pull/435) - Also call HandlebarsRegistrationCallback when using WithCallback(..) [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#408](https://github.com/WireMock-Net/WireMock.Net/issues/408) - Intermittent threading errors with FindLogEntries [bug]
|
||||||
|
- [#433](https://github.com/WireMock-Net/WireMock.Net/issues/433) - HandlebarsRegistrationCallback not fired [feature]
|
||||||
|
|
||||||
|
# 1.1.9.0 (25 February 2020)
|
||||||
|
- [#431](https://github.com/WireMock-Net/WireMock.Net/pull/431) - Fix LinqMatcher for JSON int64 [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#425](https://github.com/WireMock-Net/WireMock.Net/issues/425) - Allow 64 bit numbers in JSON [bug]
|
||||||
|
|
||||||
|
# 1.1.8.0 (22 February 2020)
|
||||||
|
- [#419](https://github.com/WireMock-Net/WireMock.Net/pull/419) - Support multi line wild card matching [bug] contributed by [NoahLerner](https://github.com/NoahLerner)
|
||||||
|
- [#421](https://github.com/WireMock-Net/WireMock.Net/pull/421) - Fix: do not return empty matchers array when Func has been used [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#423](https://github.com/WireMock-Net/WireMock.Net/pull/423) - Fixes for Cookie and Header Reject on Match [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#424](https://github.com/WireMock-Net/WireMock.Net/pull/424) - Don't return empty dictionary object for response headers in JSON mapping [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#418](https://github.com/WireMock-Net/WireMock.Net/issues/418) - Body matching fails if body has newline [bug]
|
||||||
|
|
||||||
|
# 1.1.7.0 (06 February 2020)
|
||||||
|
- [#409](https://github.com/WireMock-Net/WireMock.Net/pull/409) - Admin Delete with mappings in body [feature] contributed by [NoahLerner](https://github.com/NoahLerner)
|
||||||
|
- [#411](https://github.com/WireMock-Net/WireMock.Net/pull/411) - Improved relative path checking based on file existence [feature] contributed by [NoahLerner](https://github.com/NoahLerner)
|
||||||
|
- [#413](https://github.com/WireMock-Net/WireMock.Net/pull/413) - Fix new Delete with body missing from IWireMockAdminApi interface contributed by [NoahLerner](https://github.com/NoahLerner)
|
||||||
|
- [#414](https://github.com/WireMock-Net/WireMock.Net/pull/414) - Fix logger in StandAlone [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#412](https://github.com/WireMock-Net/WireMock.Net/issues/412) - WireMock Standalone - null reference exception since settings.Logger [bug]
|
||||||
|
|
||||||
|
# 1.1.6.0 (27 January 2020)
|
||||||
|
- [#407](https://github.com/WireMock-Net/WireMock.Net/pull/407) - AllowAnyHttpStatusCodeInResponse [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
|
|
||||||
|
# 1.1.5.0 (25 January 2020)
|
||||||
|
- [#405](https://github.com/WireMock-Net/WireMock.Net/pull/405) - Fix logging an Exception Message (linux docker on azure) [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
- [#406](https://github.com/WireMock-Net/WireMock.Net/pull/406) - Fixed StatusCode = null or < 0 [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
|
|
||||||
|
# 1.1.3.0 (22 January 2020)
|
||||||
|
- [#403](https://github.com/WireMock-Net/WireMock.Net/pull/403) - Fix for invalid cast exception contributed by [kashifsoofi](https://github.com/kashifsoofi)
|
||||||
|
- [#402](https://github.com/WireMock-Net/WireMock.Net/issues/402) - Invalid Cast Exception [bug]
|
||||||
|
|
||||||
# 1.1.2.0 (09 January 2020)
|
# 1.1.2.0 (09 January 2020)
|
||||||
- [#399](https://github.com/WireMock-Net/WireMock.Net/pull/399) - ResponseModel.StatusCode is deserialized as either string or long. [bug] contributed by [vitaliydavydiak](https://github.com/vitaliydavydiak)
|
- [#399](https://github.com/WireMock-Net/WireMock.Net/pull/399) - ResponseModel.StatusCode is deserialized as either string or long. [bug] contributed by [vitaliydavydiak](https://github.com/vitaliydavydiak)
|
||||||
- [#400](https://github.com/WireMock-Net/WireMock.Net/issues/400) - StatusCode not built correctly when loaded from mapping file. [bug]
|
- [#400](https://github.com/WireMock-Net/WireMock.Net/issues/400) - StatusCode not built correctly when loaded from mapping file. [bug]
|
||||||
@@ -34,7 +128,7 @@
|
|||||||
- [#386](https://github.com/WireMock-Net/WireMock.Net/issues/386) - Is transforming contents of XML file supported.? [bug]
|
- [#386](https://github.com/WireMock-Net/WireMock.Net/issues/386) - Is transforming contents of XML file supported.? [bug]
|
||||||
|
|
||||||
# 1.0.38.0 (30 November 2019)
|
# 1.0.38.0 (30 November 2019)
|
||||||
- [#376](https://github.com/WireMock-Net/WireMock.Net/pull/376) - Support int values for states and scenario naming [feature] contributed by [thewholuver94](https://github.com/thewholuver94)
|
- [#376](https://github.com/WireMock-Net/WireMock.Net/pull/376) - Support int values for states and scenario naming [feature] contributed by [NoahLerner](https://github.com/NoahLerner)
|
||||||
- [#378](https://github.com/WireMock-Net/WireMock.Net/pull/378) - Set handlebars dependency for .net 4.5.1 to fixed value [bug] contributed by [StefH](https://github.com/StefH)
|
- [#378](https://github.com/WireMock-Net/WireMock.Net/pull/378) - Set handlebars dependency for .net 4.5.1 to fixed value [bug] contributed by [StefH](https://github.com/StefH)
|
||||||
- [#381](https://github.com/WireMock-Net/WireMock.Net/pull/381) - Use dotnet default development certificate for .NET Core 2.x [feature] contributed by [StefH](https://github.com/StefH)
|
- [#381](https://github.com/WireMock-Net/WireMock.Net/pull/381) - Use dotnet default development certificate for .NET Core 2.x [feature] contributed by [StefH](https://github.com/StefH)
|
||||||
- [#377](https://github.com/WireMock-Net/WireMock.Net/issues/377) - Unable to build against .NET 4.5.1 because of Handlebars [bug]
|
- [#377](https://github.com/WireMock-Net/WireMock.Net/issues/377) - Unable to build against .NET 4.5.1 because of Handlebars [bug]
|
||||||
|
|||||||
@@ -4,7 +4,14 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VersionPrefix>1.1.2</VersionPrefix>
|
<VersionPrefix>1.2.12</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>
|
||||||
|
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||||
|
<RepositoryType>git</RepositoryType>
|
||||||
|
<RepositoryUrl>https://github.com/WireMock-Net/WireMock.Net</RepositoryUrl>
|
||||||
|
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Choose>
|
<Choose>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
https://github.com/StefH/GitHubReleaseNotes
|
https://github.com/StefH/GitHubReleaseNotes
|
||||||
|
|
||||||
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.1.2.0
|
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.2.12.0
|
||||||
10
README.md
10
README.md
@@ -21,13 +21,9 @@ A C# .NET version based on [mock4net](https://github.com/alexvictoor/mock4net) w
|
|||||||
| | |
|
| | |
|
||||||
| ***Quality*** | |
|
| ***Quality*** | |
|
||||||
| **Build Azure** | [](https://stef.visualstudio.com/WireMock.Net/_build/latest?definitionId=7) |
|
| **Build Azure** | [](https://stef.visualstudio.com/WireMock.Net/_build/latest?definitionId=7) |
|
||||||
| **CodeFactor** | [](https://www.codefactor.io/repository/github/wiremock-net/wiremock.net)
|
| **Quality** | [](https://sonarcloud.io/project/issues?id=wiremock) [](https://www.codefactor.io/repository/github/wiremock-net/wiremock.net) |
|
||||||
| **Sonar Quality Gate** | [](https://sonarcloud.io/project/issues?id=wiremock) |
|
| **Sonar Bugs** | [](https://sonarcloud.io/project/issues?id=wiremock&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=wiremock&resolved=false&types=CODE_SMELL) |
|
||||||
| **Sonar Bugs** | [](https://sonarcloud.io/project/issues?id=wiremock&resolved=false&types=BUG) |
|
| **Coverage** | [](https://sonarcloud.io/component_measures?id=wiremock&metric=coverage) [](https://codecov.io/gh/WireMock-Net/WireMock.Net) [](https://coveralls.io/github/WireMock-Net/WireMock.Net?branch=master) |
|
||||||
| **Sonar Code Smells** | [](https://sonarcloud.io/project/issues?id=wiremock&resolved=false&types=CODE_SMELL) |
|
|
||||||
| **Sonar Coverage** | [](https://sonarcloud.io/component_measures?id=wiremock&metric=coverage) |
|
|
||||||
| **Codecov** | [](https://codecov.io/gh/WireMock-Net/WireMock.Net) |
|
|
||||||
| **Coveralls** | [](https://coveralls.io/github/WireMock-Net/WireMock.Net?branch=master) |
|
|
||||||
|
|
||||||
### NuGet packages
|
### NuGet packages
|
||||||
|
|
||||||
|
|||||||
@@ -1,255 +1,97 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 15.0.28307.902
|
VisualStudioVersion = 16.0.30114.105
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EF242EDF-7133-4277-9A0C-18744DE08707}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8F890C6F-9ACC-438D-928A-AD61CDA862F2}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{197A0EE3-94E5-4807-BBCF-2F1BCA28A6AE}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0BB8B634-407A-4610-A91F-11586990767A}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net", "src\WireMock.Net\WireMock.Net.csproj", "{D3804228-91F4-4502-9595-39584E5A01AD}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Abstractions", "src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj", "{B6269AAC-170A-4346-8B9A-579DED3D9A94}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.RestClient", "src\WireMock.Net.RestClient\WireMock.Net.RestClient.csproj", "{B6269AAC-170A-43D6-8B9A-579DED3D9A96}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.StandAlone", "src\WireMock.Net.StandAlone\WireMock.Net.StandAlone.csproj", "{B6269AAC-170A-43D5-8B9A-579DED3D9A95}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Tests", "test\WireMock.Net.Tests\WireMock.Net.Tests.csproj", "{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{985E0ADB-D4B4-473A-AA40-567E279B7946}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7EFB2C5B-1BB2-4AAF-BC9F-216ED80C594D}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.runsettings = .runsettings
|
.gitignore = .gitignore
|
||||||
|
azure-pipelines-ci-linux.yml = azure-pipelines-ci-linux.yml
|
||||||
|
azure-pipelines-ci.yml = azure-pipelines-ci.yml
|
||||||
azure-pipelines-linux.yml = azure-pipelines-linux.yml
|
azure-pipelines-linux.yml = azure-pipelines-linux.yml
|
||||||
azure-pipelines-nuget.yml = azure-pipelines-nuget.yml
|
azure-pipelines-nuget.yml = azure-pipelines-nuget.yml
|
||||||
azure-pipelines.yml = azure-pipelines.yml
|
|
||||||
build-info.md = build-info.md
|
build-info.md = build-info.md
|
||||||
CHANGELOG.md = CHANGELOG.md
|
CHANGELOG.md = CHANGELOG.md
|
||||||
Directory.Build.props = Directory.Build.props
|
Directory.Build.props = Directory.Build.props
|
||||||
GitHubReleaseNotes.txt = GitHubReleaseNotes.txt
|
GitHubReleaseNotes.txt = GitHubReleaseNotes.txt
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
ReSharper_WireMock.DotSettings = ReSharper_WireMock.DotSettings
|
|
||||||
report\run-codecov-local.cmd = report\run-codecov-local.cmd
|
|
||||||
report\run-coverlet-local.cmd = report\run-coverlet-local.cmd
|
|
||||||
WireMock.Net Solution.sln.DotSettings = WireMock.Net Solution.sln.DotSettings
|
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{F0C22C47-DF71-463C-9B04-B4E0F3B8708A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp3", "examples\WireMock.Net.Console.NETCoreApp3\WireMock.Net.Console.NETCoreApp3.csproj", "{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{890A1DED-C229-4FA1-969E-AAC3BBFC05E5}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.Proxy.NETCoreApp2", "examples\WireMock.Net.Console.Proxy.NETCoreApp2\WireMock.Net.Console.Proxy.NETCoreApp2.csproj", "{41C19451-E980-4ED4-A011-DA7A1C23FC05}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net", "src\WireMock.Net\WireMock.Net.csproj", "{D3804228-91F4-4502-9595-39584E5A01AD}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Client", "examples\WireMock.Net.Client\WireMock.Net.Client.csproj", "{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}"
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Tests", "test\WireMock.Net.Tests\WireMock.Net.Tests.csproj", "{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp", "examples\WireMock.Net.Console.NETCoreApp\WireMock.Net.Console.NETCoreApp.csproj", "{FE281639-B014-4C8A-96FA-141164A74713}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.Proxy.NETCoreApp", "examples\WireMock.Net.Console.Record.NETCoreApp\WireMock.Net.Console.Proxy.NETCoreApp.csproj", "{1995E414-F197-4AB4-90C2-68D806B5AF59}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Client", "examples\WireMock.Net.Client\WireMock.Net.Client.csproj", "{058D4B6C-C03E-49D0-91DB-A535B058FA0D}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.StandAlone.NETCoreApp", "examples\WireMock.Net.StandAlone.NETCoreApp\WireMock.Net.StandAlone.NETCoreApp.csproj", "{10E16614-61CA-48D8-8BDD-664C13913DED}"
|
|
||||||
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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.Proxy.NETCoreApp2", "examples\WireMock.Net.Console.Proxy.NETCoreApp2\WireMock.Net.Console.Proxy.NETCoreApp2.csproj", "{23A9AA3C-40FC-42AA-8A5E-05899795A1C6}"
|
|
||||||
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}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Service", "examples\Wiremock.Net.Service\WireMock.Net.Service.csproj", "{7F0B2446-0363-4720-AF46-F47F83B557DC}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Net461.Classic", "examples\WireMock.Net.Console.Net461.Classic\WireMock.Net.Console.Net461.Classic.csproj", "{1261BB9B-A7D4-456C-8985-3CE560361B8E}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Net452.Classic", "examples\WireMock.Net.Console.Net452.Classic\WireMock.Net.Console.Net452.Classic.csproj", "{668F689E-57B4-422E-8846-C0FF643CA268}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp2", "examples\WireMock.Net.Console.NETCoreApp2\WireMock.Net.Console.NETCoreApp2.csproj", "{83645809-9E01-4E81-8733-BA9497554ABF}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.RestClient", "src\WireMock.Net.RestClient\WireMock.Net.RestClient.csproj", "{B6269AAC-170A-43D6-8B9A-579DED3D9A96}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Abstractions", "src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj", "{B6269AAC-170A-4346-8B9A-579DED3D9A94}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.StandAlone", "src\WireMock.Net.StandAlone\WireMock.Net.StandAlone.csproj", "{B6269AAC-170A-43D5-8B9A-579DED3D9A95}"
|
|
||||||
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
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
Release|x64 = Release|x64
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{D3804228-91F4-4502-9595-39584E5A01AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{D3804228-91F4-4502-9595-39584E5A01AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{D3804228-91F4-4502-9595-39584E5A01AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D3804228-91F4-4502-9595-39584E5A01AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{D3804228-91F4-4502-9595-39584E5A01AD}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{D3804228-91F4-4502-9595-39584E5A01AD}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{D3804228-91F4-4502-9595-39584E5A01AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D3804228-91F4-4502-9595-39584E5A01AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{D3804228-91F4-4502-9595-39584E5A01AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
{D3804228-91F4-4502-9595-39584E5A01AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{D3804228-91F4-4502-9595-39584E5A01AD}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{D3804228-91F4-4502-9595-39584E5A01AD}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{FE281639-B014-4C8A-96FA-141164A74713}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{FE281639-B014-4C8A-96FA-141164A74713}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{FE281639-B014-4C8A-96FA-141164A74713}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{FE281639-B014-4C8A-96FA-141164A74713}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{FE281639-B014-4C8A-96FA-141164A74713}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{FE281639-B014-4C8A-96FA-141164A74713}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{FE281639-B014-4C8A-96FA-141164A74713}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{FE281639-B014-4C8A-96FA-141164A74713}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{058D4B6C-C03E-49D0-91DB-A535B058FA0D}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{10E16614-61CA-48D8-8BDD-664C13913DED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{10E16614-61CA-48D8-8BDD-664C13913DED}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{10E16614-61CA-48D8-8BDD-664C13913DED}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{10E16614-61CA-48D8-8BDD-664C13913DED}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{10E16614-61CA-48D8-8BDD-664C13913DED}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{10E16614-61CA-48D8-8BDD-664C13913DED}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{10E16614-61CA-48D8-8BDD-664C13913DED}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{10E16614-61CA-48D8-8BDD-664C13913DED}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA999}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA999}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA999}.Debug|x64.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
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA999}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA999}.Release|x64.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}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Debug|x64.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
|
|
||||||
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Release|x64.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}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Release|x64.Build.0 = Release|x64
|
|
||||||
{23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{1261BB9B-A7D4-456C-8985-3CE560361B8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{1261BB9B-A7D4-456C-8985-3CE560361B8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{1261BB9B-A7D4-456C-8985-3CE560361B8E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{1261BB9B-A7D4-456C-8985-3CE560361B8E}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{1261BB9B-A7D4-456C-8985-3CE560361B8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{1261BB9B-A7D4-456C-8985-3CE560361B8E}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{1261BB9B-A7D4-456C-8985-3CE560361B8E}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{1261BB9B-A7D4-456C-8985-3CE560361B8E}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA268}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA268}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA268}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA268}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA268}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA268}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA268}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA268}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{83645809-9E01-4E81-8733-BA9497554ABF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{83645809-9E01-4E81-8733-BA9497554ABF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{83645809-9E01-4E81-8733-BA9497554ABF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{83645809-9E01-4E81-8733-BA9497554ABF}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{83645809-9E01-4E81-8733-BA9497554ABF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{83645809-9E01-4E81-8733-BA9497554ABF}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{83645809-9E01-4E81-8733-BA9497554ABF}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{83645809-9E01-4E81-8733-BA9497554ABF}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Release|x64.ActiveCfg = Release|Any CPU
|
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A94}.Release|x64.Build.0 = Release|Any CPU
|
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B6269AAC-170A-43D6-8B9A-579DED3D9A96}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Release|x64.ActiveCfg = Release|Any CPU
|
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{B6269AAC-170A-43D5-8B9A-579DED3D9A95}.Release|x64.Build.0 = Release|Any CPU
|
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Debug|x64.ActiveCfg = Debug|Any CPU
|
{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Debug|x64.Build.0 = Debug|Any CPU
|
{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Release|Any CPU.Build.0 = Release|Any CPU
|
{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Release|x64.ActiveCfg = Release|Any CPU
|
{41C19451-E980-4ED4-A011-DA7A1C23FC05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{A9D039B9-7509-4CF1-9EFD-87EB82998575}.Release|x64.Build.0 = Release|Any CPU
|
{41C19451-E980-4ED4-A011-DA7A1C23FC05}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{41C19451-E980-4ED4-A011-DA7A1C23FC05}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{41C19451-E980-4ED4-A011-DA7A1C23FC05}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{D3804228-91F4-4502-9595-39584E5A01AD} = {EF242EDF-7133-4277-9A0C-18744DE08707}
|
{D3804228-91F4-4502-9595-39584E5A01AD} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||||
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E} = {890A1DED-C229-4FA1-969E-AAC3BBFC05E5}
|
{B6269AAC-170A-4346-8B9A-579DED3D9A94} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||||
{FE281639-B014-4C8A-96FA-141164A74713} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
{B6269AAC-170A-43D6-8B9A-579DED3D9A96} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
{B6269AAC-170A-43D5-8B9A-579DED3D9A95} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||||
{058D4B6C-C03E-49D0-91DB-A535B058FA0D} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
{31DC2EF8-C3FE-467D-84BE-FB5D956E612E} = {0BB8B634-407A-4610-A91F-11586990767A}
|
||||||
{10E16614-61CA-48D8-8BDD-664C13913DED} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
{8C424EAF-8269-46A2-9FF1-F6D4EADB5CD5} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA999} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
{41C19451-E980-4ED4-A011-DA7A1C23FC05} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
{049539C1-7A66-4559-AD7A-B1C73B97CBB0} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
{74D91AD0-D96D-4FD2-AEC5-CC49D38346C0} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
{26433A8F-BF01-4962-97EB-81BFFBB61096} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
|
||||||
{23A9AA3C-40FC-42AA-8A5E-05899795A1C6} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
|
||||||
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
|
||||||
{7F0B2446-0363-4720-AF46-F47F83B557DC} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
|
||||||
{1261BB9B-A7D4-456C-8985-3CE560361B8E} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA268} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
|
||||||
{83645809-9E01-4E81-8733-BA9497554ABF} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
|
||||||
{B6269AAC-170A-43D6-8B9A-579DED3D9A96} = {EF242EDF-7133-4277-9A0C-18744DE08707}
|
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A94} = {EF242EDF-7133-4277-9A0C-18744DE08707}
|
|
||||||
{B6269AAC-170A-43D5-8B9A-579DED3D9A95} = {EF242EDF-7133-4277-9A0C-18744DE08707}
|
|
||||||
{A9D039B9-7509-4CF1-9EFD-87EB82998575} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {BF428BCC-C837-433B-87D2-15C7014B73E9}
|
SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WWW/@EntryIndexedValue">WWW</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WWW/@EntryIndexedValue">WWW</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XMS/@EntryIndexedValue">XMS</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XMS/@EntryIndexedValue">XMS</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XUA/@EntryIndexedValue">XUA</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XUA/@EntryIndexedValue">XUA</s:String>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Flurl/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=funcs/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=funcs/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Heyenrath/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Heyenrath/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Jmes/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Jmes/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
|||||||
13
azure-pipelines-ci-linux.yml
Normal file
13
azure-pipelines-ci-linux.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
pool:
|
||||||
|
vmImage: 'Ubuntu 16.04'
|
||||||
|
|
||||||
|
variables:
|
||||||
|
buildConfiguration: 'Release'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- script: |
|
||||||
|
dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration $(buildConfiguration) --framework netcoreapp3.1 --logger trx
|
||||||
|
- task: PublishTestResults@2
|
||||||
|
inputs:
|
||||||
|
testRunner: VSTest
|
||||||
|
testResultsFiles: '**/*.trx'
|
||||||
@@ -28,11 +28,11 @@ steps:
|
|||||||
displayName: Begin SonarScanner
|
displayName: Begin SonarScanner
|
||||||
condition: and(succeeded(), eq(variables['RUN_SONAR'], 'yes'))
|
condition: and(succeeded(), eq(variables['RUN_SONAR'], 'yes'))
|
||||||
|
|
||||||
# Build source, tests and run tests for net452 and netcoreapp2.1 (with coverage)
|
# Build source, tests and run tests for net452 and netcoreapp3.1 (with coverage)
|
||||||
- script: |
|
- script: |
|
||||||
dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --framework net452
|
dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --framework net452
|
||||||
dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --framework netcoreapp2.1 --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
|
dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --framework netcoreapp3.1 --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
|
||||||
displayName: 'Build source, tests and run tests for net452 and netcoreapp2.1 (with coverage)'
|
displayName: 'Build source, tests and run tests for net452 and netcoreapp3.1 (with coverage)'
|
||||||
|
|
||||||
# End SonarScanner
|
# End SonarScanner
|
||||||
- script: |
|
- script: |
|
||||||
@@ -46,10 +46,12 @@ steps:
|
|||||||
|
|
||||||
# Upload coverage to codecov.io
|
# Upload coverage to codecov.io
|
||||||
- script: |
|
- script: |
|
||||||
%USERPROFILE%\.nuget\packages\codecov\1.1.0\tools\codecov.exe -f "./test/WireMock.Net.Tests/coverage.opencover.xml" -t $(CODECOV_TOKEN)
|
%USERPROFILE%\.nuget\packages\codecov\1.10.0\tools\codecov.exe -f "./test/WireMock.Net.Tests/coverage.opencover.xml" -t $(CODECOV_TOKEN)
|
||||||
displayName: Upload coverage to codecov.io
|
displayName: Upload coverage to codecov.io
|
||||||
|
|
||||||
|
# https://github.com/microsoft/azure-pipelines-tasks/issues/12212
|
||||||
- task: PublishTestResults@2
|
- task: PublishTestResults@2
|
||||||
|
condition: and(succeeded(), eq(variables['PUBLISH_TESTRESULTS'], 'yes'))
|
||||||
inputs:
|
inputs:
|
||||||
testRunner: VSTest
|
testRunner: VSTest
|
||||||
testResultsFiles: '**/*.trx'
|
testResultsFiles: '**/*.trx'
|
||||||
@@ -1,13 +1,23 @@
|
|||||||
|
trigger:
|
||||||
|
- none
|
||||||
|
|
||||||
pool:
|
pool:
|
||||||
vmImage: 'Ubuntu 16.04'
|
vmImage: 'Ubuntu 16.04'
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
|
buildProjects: '**/src/**/*.csproj'
|
||||||
buildConfiguration: 'Release'
|
buildConfiguration: 'Release'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- script: |
|
- task: DotNetCoreCLI@2
|
||||||
dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration $(buildConfiguration) --framework netcoreapp2.1 --logger trx
|
displayName: Build Release
|
||||||
- task: PublishTestResults@2
|
|
||||||
inputs:
|
inputs:
|
||||||
testRunner: VSTest
|
command: 'build'
|
||||||
testResultsFiles: '**/*.trx'
|
arguments: /p:Configuration=$(buildConfiguration)
|
||||||
|
projects: $(buildProjects)
|
||||||
|
|
||||||
|
- task: PublishBuildArtifacts@1
|
||||||
|
displayName: Publish Artifacts
|
||||||
|
condition: succeeded()
|
||||||
|
inputs:
|
||||||
|
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
|
||||||
6
examples/WireMock.Net.Client.Net472/App.config
Normal file
6
examples/WireMock.Net.Client.Net472/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
35
examples/WireMock.Net.Client.Net472/Program.cs
Normal file
35
examples/WireMock.Net.Client.Net472/Program.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WireMock.Client;
|
||||||
|
|
||||||
|
namespace WireMock.Net.Client.Net472
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static async Task Main(string[] args)
|
||||||
|
{
|
||||||
|
// Create an implementation of the IWireMockAdminApi and pass in the base URL for the API.
|
||||||
|
var api = RestClient.For<IWireMockAdminApi>("http://localhost:9091");
|
||||||
|
|
||||||
|
// Set BASIC Auth
|
||||||
|
var value = Convert.ToBase64String(Encoding.ASCII.GetBytes("a:b"));
|
||||||
|
api.Authorization = new AuthenticationHeaderValue("Basic", value);
|
||||||
|
|
||||||
|
var settings1 = await api.GetSettingsAsync();
|
||||||
|
Console.WriteLine($"settings1 = {JsonConvert.SerializeObject(settings1)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//public interface IWireMockAdminApi
|
||||||
|
//{
|
||||||
|
// /// <summary>
|
||||||
|
// /// Authentication header
|
||||||
|
// /// </summary>
|
||||||
|
// [Header("Authorization")]
|
||||||
|
// AuthenticationHeaderValue Authorization { get; set; }
|
||||||
|
//}
|
||||||
|
}
|
||||||
@@ -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.Client.Net472")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("mStack.nl")]
|
||||||
|
[assembly: AssemblyProduct("WireMock.Net.Client.Net472")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © mStack.nl 2020")]
|
||||||
|
[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("02082e34-def2-47d0-af0b-3326faa908ce")]
|
||||||
|
|
||||||
|
// 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,83 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<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>{02082E34-DEF2-47D0-AF0B-3326FAA908CE}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>WireMock.Net.Client.Net472</RootNamespace>
|
||||||
|
<AssemblyName>WireMock.Net.Client.Net472</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
<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>
|
||||||
|
<SignAssembly>false</SignAssembly>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<AssemblyOriginatorKeyFile>
|
||||||
|
</AssemblyOriginatorKeyFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="RestEase, Version=1.4.10.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\RestEase.1.4.10\lib\net45\RestEase.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<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="WireMock.Net.Abstractions, Version=1.2.0.0, Culture=neutral, PublicKeyToken=c8d65537854e1f03, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\WireMock.Net.Abstractions.1.2.0\lib\net45\WireMock.Net.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="WireMock.Net.RestClient">
|
||||||
|
<HintPath>..\..\packages\WireMock.Net.RestClient.1.2.0\lib\net45\WireMock.Net.RestClient.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Import Project="..\..\packages\Brutal.Dev.StrongNameSigner.2.7.1\build\Brutal.Dev.StrongNameSigner.targets" Condition="Exists('..\..\packages\Brutal.Dev.StrongNameSigner.2.7.1\build\Brutal.Dev.StrongNameSigner.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\Brutal.Dev.StrongNameSigner.2.7.1\build\Brutal.Dev.StrongNameSigner.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Brutal.Dev.StrongNameSigner.2.7.1\build\Brutal.Dev.StrongNameSigner.targets'))" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
||||||
8
examples/WireMock.Net.Client.Net472/packages.config
Normal file
8
examples/WireMock.Net.Client.Net472/packages.config
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Brutal.Dev.StrongNameSigner" version="2.7.1" targetFramework="net472" />
|
||||||
|
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net472" />
|
||||||
|
<package id="RestEase" version="1.4.10" targetFramework="net472" />
|
||||||
|
<package id="WireMock.Net.Abstractions" version="1.2.0" targetFramework="net472" />
|
||||||
|
<package id="WireMock.Net.RestClient" version="1.2.0" targetFramework="net472" />
|
||||||
|
</packages>
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<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.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>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\WireMock.Net.Console.Net452.Classic\MainApp.cs" Link="MainApp.cs" />
|
||||||
|
<Compile Include="..\WireMock.Net.Console.Net452.Classic\CustomFileSystemFileHandler.cs" Link="CustomFileSystemFileHandler.cs" />
|
||||||
|
<Compile Include="..\WireMock.Net.Console.NETCoreApp\Program.cs" Link="Program.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="__admin\mappings\*.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="__admin\mappings\1.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="__admin\mappings\array.json" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||||
|
<PackageReference Include="Handlebars.Net.Helpers" Version="1.0.0" />
|
||||||
|
<PackageReference Include="log4net" Version="2.0.8" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
|
<!--<PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="3.4.0" />-->
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="log4net.config">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="nlog.config">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="__admin\mappings\791a3f31-6946-4ce7-8e6f-0237c7443275.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="__admin\mappings\791a3f31-6946-4ce7-8e6f-0237c7443275.json">
|
||||||
|
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="__admin\mappings\MyXmlResponse.xml">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
// C# Hello
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"Request": {
|
||||||
|
"Path": {
|
||||||
|
"Matchers": [
|
||||||
|
{
|
||||||
|
"Name": "WildcardMatcher",
|
||||||
|
"Pattern": "/static/mapping"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Methods": [
|
||||||
|
"get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Response": {
|
||||||
|
"BodyAsJson": { "body": "static mapping" },
|
||||||
|
"Headers": {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Test-X": [ "test 1", "test 2" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"Guid": "791a3f31-6946-4ce7-8e6f-0237c7443275",
|
||||||
|
"Title": "",
|
||||||
|
"Priority": 0,
|
||||||
|
"Request": {
|
||||||
|
"Path": "/proxy-google-test-post",
|
||||||
|
"Methods": [
|
||||||
|
"post"
|
||||||
|
],
|
||||||
|
"Body": {}
|
||||||
|
},
|
||||||
|
"Response": {
|
||||||
|
"StatusCode": 404,
|
||||||
|
"Body": "<!DOCTYPE html>\n<html lang=en>\n <meta charset=utf-8>\n <meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\">\n <title>Error 404 (Not Found)!!1</title>\n <style>\n *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\n </style>\n <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\n <p><b>404.</b> <ins>That’s an error.</ins>\n <p>The requested URL <code>/proxy-google-test-post</code> was not found on this server. <ins>That’s all we know.</ins>\n",
|
||||||
|
"BodyAsBytes": "PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ZW4+CiAgPG1ldGEgY2hhcnNldD11dGYtOD4KICA8bWV0YSBuYW1lPXZpZXdwb3J0IGNvbnRlbnQ9ImluaXRpYWwtc2NhbGU9MSwgbWluaW11bS1zY2FsZT0xLCB3aWR0aD1kZXZpY2Utd2lkdGgiPgogIDx0aXRsZT5FcnJvciA0MDQgKE5vdCBGb3VuZCkhITE8L3RpdGxlPgogIDxzdHlsZT4KICAgICp7bWFyZ2luOjA7cGFkZGluZzowfWh0bWwsY29kZXtmb250OjE1cHgvMjJweCBhcmlhbCxzYW5zLXNlcmlmfWh0bWx7YmFja2dyb3VuZDojZmZmO2NvbG9yOiMyMjI7cGFkZGluZzoxNXB4fWJvZHl7bWFyZ2luOjclIGF1dG8gMDttYXgtd2lkdGg6MzkwcHg7bWluLWhlaWdodDoxODBweDtwYWRkaW5nOjMwcHggMCAxNXB4fSogPiBib2R5e2JhY2tncm91bmQ6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2Vycm9ycy9yb2JvdC5wbmcpIDEwMCUgNXB4IG5vLXJlcGVhdDtwYWRkaW5nLXJpZ2h0OjIwNXB4fXB7bWFyZ2luOjExcHggMCAyMnB4O292ZXJmbG93OmhpZGRlbn1pbnN7Y29sb3I6Izc3Nzt0ZXh0LWRlY29yYXRpb246bm9uZX1hIGltZ3tib3JkZXI6MH1AbWVkaWEgc2NyZWVuIGFuZCAobWF4LXdpZHRoOjc3MnB4KXtib2R5e2JhY2tncm91bmQ6bm9uZTttYXJnaW4tdG9wOjA7bWF4LXdpZHRoOm5vbmU7cGFkZGluZy1yaWdodDowfX0jbG9nb3tiYWNrZ3JvdW5kOnVybCgvL3d3dy5nb29nbGUuY29tL2ltYWdlcy9icmFuZGluZy9nb29nbGVsb2dvLzF4L2dvb2dsZWxvZ29fY29sb3JfMTUweDU0ZHAucG5nKSBuby1yZXBlYXQ7bWFyZ2luLWxlZnQ6LTVweH1AbWVkaWEgb25seSBzY3JlZW4gYW5kIChtaW4tcmVzb2x1dGlvbjoxOTJkcGkpeyNsb2dve2JhY2tncm91bmQ6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2JyYW5kaW5nL2dvb2dsZWxvZ28vMngvZ29vZ2xlbG9nb19jb2xvcl8xNTB4NTRkcC5wbmcpIG5vLXJlcGVhdCAwJSAwJS8xMDAlIDEwMCU7LW1vei1ib3JkZXItaW1hZ2U6dXJsKC8vd3d3Lmdvb2dsZS5jb20vaW1hZ2VzL2JyYW5kaW5nL2dvb2dsZWxvZ28vMngvZ29vZ2xlbG9nb19jb2xvcl8xNTB4NTRkcC5wbmcpIDB9fUBtZWRpYSBvbmx5IHNjcmVlbiBhbmQgKC13ZWJraXQtbWluLWRldmljZS1waXhlbC1yYXRpbzoyKXsjbG9nb3tiYWNrZ3JvdW5kOnVybCgvL3d3dy5nb29nbGUuY29tL2ltYWdlcy9icmFuZGluZy9nb29nbGVsb2dvLzJ4L2dvb2dsZWxvZ29fY29sb3JfMTUweDU0ZHAucG5nKSBuby1yZXBlYXQ7LXdlYmtpdC1iYWNrZ3JvdW5kLXNpemU6MTAwJSAxMDAlfX0jbG9nb3tkaXNwbGF5OmlubGluZS1ibG9jaztoZWlnaHQ6NTRweDt3aWR0aDoxNTBweH0KICA8L3N0eWxlPgogIDxhIGhyZWY9Ly93d3cuZ29vZ2xlLmNvbS8+PHNwYW4gaWQ9bG9nbyBhcmlhLWxhYmVsPUdvb2dsZT48L3NwYW4+PC9hPgogIDxwPjxiPjQwNC48L2I+IDxpbnM+VGhhdOKAmXMgYW4gZXJyb3IuPC9pbnM+CiAgPHA+VGhlIHJlcXVlc3RlZCBVUkwgPGNvZGU+L3Byb3h5LWdvb2dsZS10ZXN0LXBvc3Q8L2NvZGU+IHdhcyBub3QgZm91bmQgb24gdGhpcyBzZXJ2ZXIuICA8aW5zPlRoYXTigJlzIGFsbCB3ZSBrbm93LjwvaW5zPgo=",
|
||||||
|
"BodyEncoding": {
|
||||||
|
"CodePage": 65001,
|
||||||
|
"EncodingName": "Unicode (UTF-8)",
|
||||||
|
"WebName": "utf-8"
|
||||||
|
},
|
||||||
|
"UseTransformer": false,
|
||||||
|
"Headers": {
|
||||||
|
"Date": "Wed, 27 Oct 2017 18:57:40 GMT",
|
||||||
|
"Alt-Svc": "quic=\":443\"; ma=2592000; v=\"39,38,37,35\"",
|
||||||
|
"Referrer-Policy": "no-referrer",
|
||||||
|
"Connection": "close"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"Guid": "873d495f-940e-4b86-a1f4-4f0fc7be8b8b",
|
||||||
|
"Priority": 4,
|
||||||
|
"Request": {
|
||||||
|
"Path": {},
|
||||||
|
"Methods": [
|
||||||
|
"get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Response": {
|
||||||
|
"StatusCode": 200,
|
||||||
|
"BodyDestination": "SameAsSource",
|
||||||
|
"Body": "NO PATH OR URL",
|
||||||
|
"UseTransformer": false,
|
||||||
|
"Headers": {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"Request": {
|
||||||
|
"Path": {
|
||||||
|
"Matchers": [
|
||||||
|
{
|
||||||
|
"Name": "WildcardMatcher",
|
||||||
|
"Pattern": "/bodyasfilexmltest",
|
||||||
|
"IgnoreCase": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Methods": [
|
||||||
|
"get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Response": {
|
||||||
|
"StatusCode": 200,
|
||||||
|
"Headers": {"Content-Type": "application/xml"},
|
||||||
|
"BodyAsFile": "MyXmlResponse.xml",
|
||||||
|
"UseTransformer": false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<xml>
|
||||||
|
<hello>world</hello>
|
||||||
|
</xml>
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"Title": "1",
|
||||||
|
"Request": {
|
||||||
|
"Path": {
|
||||||
|
"Matchers": [
|
||||||
|
{
|
||||||
|
"Name": "WildcardMatcher",
|
||||||
|
"Pattern": "/mappings_static_1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Methods": [
|
||||||
|
"get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Response": {
|
||||||
|
"BodyAsJson": { "result": "mappings static_1" },
|
||||||
|
"Headers": {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "2",
|
||||||
|
"Request": {
|
||||||
|
"Path": {
|
||||||
|
"Matchers": [
|
||||||
|
{
|
||||||
|
"Name": "WildcardMatcher",
|
||||||
|
"Pattern": "/mappings_static_2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Methods": [
|
||||||
|
"get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Response": {
|
||||||
|
"BodyAsJson": { "result": "mappings static_2" },
|
||||||
|
"Headers": {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -47,18 +47,12 @@
|
|||||||
<Reference Include="Microsoft.Owin.Hosting, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Owin.Hosting, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
|
<HintPath>..\..\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MimeKitLite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\packages\MimeKitLite.2.0.1\lib\net45\MimeKitLite.dll</HintPath>
|
|
||||||
</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>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
<HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="RestEase, Version=1.4.10.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\packages\RestEase.1.4.10\lib\net45\RestEase.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="SimMetrics.Net, Version=1.0.5.0, Culture=neutral, PublicKeyToken=c58dc06d59f3391b, processorArchitecture=MSIL">
|
<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>
|
<HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -86,8 +80,8 @@
|
|||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="XPath2, Version=1.0.7.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
|
<Reference Include="XPath2, Version=1.0.9.0, Culture=neutral, PublicKeyToken=463c6d7fb740c7e5, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\XPath2.1.0.6.1\lib\net40\XPath2.dll</HintPath>
|
<HintPath>..\..\packages\XPath2.1.0.10\lib\net40\XPath2.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
using log4net;
|
using System;
|
||||||
|
using log4net;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Wiremock.Net.Service;
|
using Wiremock.Net.Service;
|
||||||
|
using WireMock.Admin.Requests;
|
||||||
using WireMock.Logging;
|
using WireMock.Logging;
|
||||||
using WireMock.Models.Requests;
|
|
||||||
|
|
||||||
namespace WireMock.Net.Service
|
namespace WireMock.Net.Service
|
||||||
{
|
{
|
||||||
@@ -30,6 +31,11 @@ namespace WireMock.Net.Service
|
|||||||
Log.ErrorFormat(formatString, args);
|
Log.ErrorFormat(formatString, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Error(string message, Exception exception)
|
||||||
|
{
|
||||||
|
Log.Error(message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
|
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
|
||||||
{
|
{
|
||||||
string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented);
|
string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented);
|
||||||
|
|||||||
@@ -9,11 +9,9 @@
|
|||||||
<package id="Microsoft.Owin" version="2.0.2" targetFramework="net452" />
|
<package id="Microsoft.Owin" version="2.0.2" targetFramework="net452" />
|
||||||
<package id="Microsoft.Owin.Host.HttpListener" version="2.0.2" targetFramework="net452" />
|
<package id="Microsoft.Owin.Host.HttpListener" version="2.0.2" targetFramework="net452" />
|
||||||
<package id="Microsoft.Owin.Hosting" version="2.0.2" targetFramework="net452" />
|
<package id="Microsoft.Owin.Hosting" version="2.0.2" targetFramework="net452" />
|
||||||
<package id="MimeKitLite" version="2.0.1" targetFramework="net452" />
|
|
||||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
|
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
|
||||||
<package id="Owin" version="1.0" targetFramework="net452" />
|
<package id="Owin" version="1.0" targetFramework="net452" />
|
||||||
<package id="RestEase" version="1.4.10" 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.Net.Http" version="4.3.3" targetFramework="net452" />
|
<package id="System.Net.Http" version="4.3.3" targetFramework="net452" />
|
||||||
<package id="XPath2" version="1.0.6.1" targetFramework="net452" />
|
<package id="XPath2" version="1.0.10" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"WireMock.Net.StandAlone.NETCoreApp": {
|
"WireMock.Net.StandAlone.NETCoreApp": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"commandLineArgs": "--Urls http://*:9091 --WireMockLogger WireMockConsoleLogger"
|
"commandLineArgs": "--Port 9091 --WireMockLogger WireMockConsoleLogger"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFrameworks>netcoreapp2.1;netcoreapp2.0;netcoreapp1.1</TargetFrameworks>
|
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||||
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
|
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
|
||||||
<StartupObject>WireMock.Net.StandAlone.NETCoreApp.Program</StartupObject>
|
<StartupObject>WireMock.Net.StandAlone.NETCoreApp.Program</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
using log4net;
|
using System;
|
||||||
|
using log4net;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using WireMock.Admin.Requests;
|
||||||
using WireMock.Logging;
|
using WireMock.Logging;
|
||||||
using WireMock.Models.Requests;
|
|
||||||
|
|
||||||
namespace WireMock.Net.StandAlone.NETCoreApp
|
namespace WireMock.Net.StandAlone.NETCoreApp
|
||||||
{
|
{
|
||||||
@@ -29,6 +30,11 @@ namespace WireMock.Net.StandAlone.NETCoreApp
|
|||||||
Log.ErrorFormat(formatString, args);
|
Log.ErrorFormat(formatString, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Error(string message, Exception exception)
|
||||||
|
{
|
||||||
|
Log.Error(message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
|
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
|
||||||
{
|
{
|
||||||
string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented);
|
string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
|
<TargetFramework>netcoreapp2.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>
|
||||||
|
|||||||
177
mock4net/LICENSE.txt
Normal file
177
mock4net/LICENSE.txt
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
3
mock4net/readme.md
Normal file
3
mock4net/readme.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
WireMock.Net is based on the source-code from https://github.com/alexvictoor/mock4net
|
||||||
|
|
||||||
|
The license in this folder is copied from https://github.com/alexvictoor/mock4net/blob/master/LICENSE.txt
|
||||||
@@ -16,5 +16,15 @@ namespace WireMock.Admin.Mappings
|
|||||||
/// Gets or sets the matchers.
|
/// Gets or sets the matchers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<MatcherModel> Matchers { get; set; }
|
public IList<MatcherModel> Matchers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ignore case.
|
||||||
|
/// </summary>
|
||||||
|
public bool? IgnoreCase { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reject on match.
|
||||||
|
/// </summary>
|
||||||
|
public bool? RejectOnMatch { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,5 +16,15 @@ namespace WireMock.Admin.Mappings
|
|||||||
/// Gets or sets the matchers.
|
/// Gets or sets the matchers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<MatcherModel> Matchers { get; set; }
|
public IList<MatcherModel> Matchers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ignore case.
|
||||||
|
/// </summary>
|
||||||
|
public bool? IgnoreCase { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reject on match.
|
||||||
|
/// </summary>
|
||||||
|
public bool? RejectOnMatch { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,11 @@ namespace WireMock.Admin.Requests
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string AbsoluteUrl { get; set; }
|
public string AbsoluteUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The ProxyUrl (if a proxy is used).
|
||||||
|
/// </summary>
|
||||||
|
public string ProxyUrl { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The query.
|
/// The query.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using JetBrains.Annotations;
|
using System;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using WireMock.Admin.Requests;
|
using WireMock.Admin.Requests;
|
||||||
|
|
||||||
namespace WireMock.Logging
|
namespace WireMock.Logging
|
||||||
@@ -45,6 +46,15 @@ namespace WireMock.Logging
|
|||||||
[StringFormatMethod("formatString")]
|
[StringFormatMethod("formatString")]
|
||||||
void Error([NotNull] string formatString, [NotNull] params object[] args);
|
void Error([NotNull] string formatString, [NotNull] params object[] args);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the message at the Error level using the specified exception.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="formatString">The format string.</param>
|
||||||
|
/// <param name="exception">The exception.</param>
|
||||||
|
[PublicAPI]
|
||||||
|
[StringFormatMethod("formatString")]
|
||||||
|
void Error([NotNull] string formatString, [NotNull] Exception exception);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more).
|
/// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -4,25 +4,16 @@
|
|||||||
<Description>Commonly used interfaces, models, enumerations and types.</Description>
|
<Description>Commonly used interfaces, models, enumerations and types.</Description>
|
||||||
<AssemblyTitle>WireMock.Net.Abstractions</AssemblyTitle>
|
<AssemblyTitle>WireMock.Net.Abstractions</AssemblyTitle>
|
||||||
<Authors>Stef Heyenrath</Authors>
|
<Authors>Stef Heyenrath</Authors>
|
||||||
<TargetFrameworks>netstandard1.0;netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard1.0;netstandard2.0;netstandard2.1;net45</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<AssemblyName>WireMock.Net.Abstractions</AssemblyName>
|
<AssemblyName>WireMock.Net.Abstractions</AssemblyName>
|
||||||
<PackageId>WireMock.Net.Abstractions</PackageId>
|
<PackageId>WireMock.Net.Abstractions</PackageId>
|
||||||
<PackageTags>wiremock;interfaces;models;classes;enumerations;types</PackageTags>
|
<PackageTags>wiremock;interfaces;models;classes;enumerations;types</PackageTags>
|
||||||
<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>
|
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
|
||||||
<RepositoryType>git</RepositoryType>
|
|
||||||
<RepositoryUrl>https://github.com/WireMock-Net/WireMock.Net</RepositoryUrl>
|
|
||||||
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
|
|
||||||
<RootNamespace>WireMock</RootNamespace>
|
<RootNamespace>WireMock</RootNamespace>
|
||||||
<!--<DebugType>full</DebugType>
|
|
||||||
<IncludeSource>True</IncludeSource>
|
|
||||||
<IncludeSymbols>True</IncludeSymbols>-->
|
|
||||||
<ProjectGuid>{B6269AAC-170A-4346-8B9A-579DED3D9A94}</ProjectGuid>
|
<ProjectGuid>{B6269AAC-170A-4346-8B9A-579DED3D9A94}</ProjectGuid>
|
||||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||||
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
||||||
<CodeAnalysisRuleSet>../WireMock.Net/WireMock.Net.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>../WireMock.Net/WireMock.Net.ruleset</CodeAnalysisRuleSet>
|
||||||
@@ -33,14 +24,13 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<PathMap>$(MSBuildProjectDirectory)=/</PathMap>
|
<!--<PathMap>$(MSBuildProjectDirectory)=/</PathMap>-->
|
||||||
<!--<GeneratePackageOnBuild>true</GeneratePackageOnBuild>-->
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3">
|
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" PrivateAssets="All" />
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -74,11 +74,19 @@ namespace WireMock.Client
|
|||||||
[Delete("mappings")]
|
[Delete("mappings")]
|
||||||
Task<StatusModel> DeleteMappingsAsync();
|
Task<StatusModel> DeleteMappingsAsync();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete mappings according to GUIDs
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mappings">MappingModels</param>
|
||||||
|
[Delete("mappings")]
|
||||||
|
[Header("Content-Type", "application/json")]
|
||||||
|
Task<StatusModel> DeleteMappingsAsync([Body] IList<MappingModel> mappings);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete (reset) all mappings.
|
/// Delete (reset) all mappings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="reloadStaticMappings">A value indicating whether to reload the static mappings after the reset.</param>
|
/// <param name="reloadStaticMappings">A value indicating whether to reload the static mappings after the reset.</param>
|
||||||
[Post("__admin/mappings/reset")]
|
[Post("mappings/reset")]
|
||||||
Task<StatusModel> ResetMappingsAsync(bool? reloadStaticMappings = false);
|
Task<StatusModel> ResetMappingsAsync(bool? reloadStaticMappings = false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -4,25 +4,16 @@
|
|||||||
<Description>A RestClient using RestEase to access the admin interface.</Description>
|
<Description>A RestClient using RestEase to access the admin interface.</Description>
|
||||||
<AssemblyTitle>WireMock.Net.RestClient</AssemblyTitle>
|
<AssemblyTitle>WireMock.Net.RestClient</AssemblyTitle>
|
||||||
<Authors>Stef Heyenrath</Authors>
|
<Authors>Stef Heyenrath</Authors>
|
||||||
<TargetFrameworks>netstandard1.1;netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard1.1;netstandard2.0;netstandard2.1;net45</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<AssemblyName>WireMock.Net.RestClient</AssemblyName>
|
<AssemblyName>WireMock.Net.RestClient</AssemblyName>
|
||||||
<PackageId>WireMock.Net.RestClient</PackageId>
|
<PackageId>WireMock.Net.RestClient</PackageId>
|
||||||
<PackageTags>wiremock;rest;client;restclient;restease;rest;json</PackageTags>
|
<PackageTags>wiremock;rest;client;restclient;restease;rest;json</PackageTags>
|
||||||
<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>
|
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
|
||||||
<RepositoryType>git</RepositoryType>
|
|
||||||
<RepositoryUrl>https://github.com/WireMock-Net/WireMock.Net</RepositoryUrl>
|
|
||||||
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
|
|
||||||
<RootNamespace>WireMock.Client</RootNamespace>
|
<RootNamespace>WireMock.Client</RootNamespace>
|
||||||
<!--<DebugType>full</DebugType>
|
|
||||||
<IncludeSource>True</IncludeSource>
|
|
||||||
<IncludeSymbols>True</IncludeSymbols>-->
|
|
||||||
<ProjectGuid>{B6269AAC-170A-43D6-8B9A-579DED3D9A96}</ProjectGuid>
|
<ProjectGuid>{B6269AAC-170A-43D6-8B9A-579DED3D9A96}</ProjectGuid>
|
||||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||||
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
||||||
<CodeAnalysisRuleSet>../WireMock.Net/WireMock.Net.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>../WireMock.Net/WireMock.Net.ruleset</CodeAnalysisRuleSet>
|
||||||
@@ -33,11 +24,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<PathMap>$(MSBuildProjectDirectory)=/</PathMap>
|
<!--<PathMap>$(MSBuildProjectDirectory)=/</PathMap>-->
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||||
<PackageReference Include="RestEase" Version="1.4.10" />
|
<PackageReference Include="RestEase" Version="1.4.10" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ namespace WireMock.Net.StandAlone
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="settings">The FluentMockServerSettings</param>
|
/// <param name="settings">The FluentMockServerSettings</param>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static WireMockServer Start([NotNull] FluentMockServerSettings settings)
|
public static WireMockServer Start([NotNull] IWireMockServerSettings settings)
|
||||||
{
|
{
|
||||||
Check.NotNull(settings, nameof(settings));
|
Check.NotNull(settings, nameof(settings));
|
||||||
|
|
||||||
var server = WireMockServer.Start(settings);
|
var server = WireMockServer.Start(settings);
|
||||||
|
|
||||||
settings.Logger.Info("WireMock.Net server listening at {0}", string.Join(",", server.Urls));
|
settings.Logger?.Info("WireMock.Net server listening at {0}", string.Join(",", server.Urls));
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
@@ -38,9 +38,9 @@ namespace WireMock.Net.StandAlone
|
|||||||
{
|
{
|
||||||
Check.NotNull(args, nameof(args));
|
Check.NotNull(args, nameof(args));
|
||||||
|
|
||||||
var settings = (FluentMockServerSettings) WireMockServerSettingsParser.ParseArguments(args);
|
var settings = WireMockServerSettingsParser.ParseArguments(args, logger);
|
||||||
|
|
||||||
settings.Logger.Debug("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));
|
settings.Logger?.Debug("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));
|
||||||
|
|
||||||
return Start(settings);
|
return Start(settings);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,25 +3,16 @@
|
|||||||
<Description>Lightweight StandAlone Http Mocking Server for .Net.</Description>
|
<Description>Lightweight StandAlone Http Mocking Server for .Net.</Description>
|
||||||
<AssemblyTitle>WireMock.Net.StandAlone</AssemblyTitle>
|
<AssemblyTitle>WireMock.Net.StandAlone</AssemblyTitle>
|
||||||
<Authors>Stef Heyenrath</Authors>
|
<Authors>Stef Heyenrath</Authors>
|
||||||
<TargetFrameworks>net451;net452;net46;net461;netstandard1.3;netstandard2.0</TargetFrameworks>
|
<TargetFrameworks>net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1</TargetFrameworks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<AssemblyName>WireMock.Net.StandAlone</AssemblyName>
|
<AssemblyName>WireMock.Net.StandAlone</AssemblyName>
|
||||||
<PackageId>WireMock.Net.StandAlone</PackageId>
|
<PackageId>WireMock.Net.StandAlone</PackageId>
|
||||||
<PackageTags>tdd;mock;http;wiremock;test;server;unittest</PackageTags>
|
<PackageTags>tdd;mock;http;wiremock;test;server;unittest</PackageTags>
|
||||||
<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>
|
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
|
||||||
<RepositoryType>git</RepositoryType>
|
|
||||||
<RepositoryUrl>https://github.com/WireMock-Net/WireMock.Net</RepositoryUrl>
|
|
||||||
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
|
|
||||||
<RootNamespace>WireMock.Net.StandAlone</RootNamespace>
|
<RootNamespace>WireMock.Net.StandAlone</RootNamespace>
|
||||||
<!--<DebugType>full</DebugType>
|
|
||||||
<IncludeSource>True</IncludeSource>
|
|
||||||
<IncludeSymbols>True</IncludeSymbols>-->
|
|
||||||
<ProjectGuid>{B6269AAC-170A-43D5-8B9A-579DED3D9A95}</ProjectGuid>
|
<ProjectGuid>{B6269AAC-170A-43D5-8B9A-579DED3D9A95}</ProjectGuid>
|
||||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||||
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
||||||
<CodeAnalysisRuleSet>WireMock.Net.StandAlone.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>WireMock.Net.StandAlone.ruleset</CodeAnalysisRuleSet>
|
||||||
@@ -30,13 +21,13 @@
|
|||||||
<!--<DelaySign>true</DelaySign>-->
|
<!--<DelaySign>true</DelaySign>-->
|
||||||
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
|
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<PathMap>$(MSBuildProjectDirectory)=/</PathMap>
|
<!--<PathMap>$(MSBuildProjectDirectory)=/</PathMap>-->
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' or '$(TargetFramework)' == 'netstandard2.0' ">
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1' ">
|
||||||
<DefineConstants>NETSTANDARD;USE_ASPNETCORE</DefineConstants>
|
<DefineConstants>NETSTANDARD;USE_ASPNETCORE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
@@ -45,9 +36,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="JetBrains.Annotations" Version="2018.2.1">
|
<PackageReference Include="JetBrains.Annotations" Version="2018.2.1" PrivateAssets="All" />
|
||||||
<PrivateAssets>All</PrivateAssets>
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="SonarAnalyzer.CSharp" Version="7.8.0.7320">
|
<PackageReference Include="SonarAnalyzer.CSharp" Version="7.8.0.7320">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using WireMock.Util;
|
||||||
using WireMock.Validation;
|
using WireMock.Validation;
|
||||||
|
|
||||||
namespace WireMock.Handlers
|
namespace WireMock.Handlers
|
||||||
@@ -80,20 +81,20 @@ namespace WireMock.Handlers
|
|||||||
public byte[] ReadResponseBodyAsFile(string path)
|
public byte[] ReadResponseBodyAsFile(string path)
|
||||||
{
|
{
|
||||||
Check.NotNullOrEmpty(path, nameof(path));
|
Check.NotNullOrEmpty(path, nameof(path));
|
||||||
|
path = PathUtils.CleanPath(path);
|
||||||
// In case the path is a filename, the path will be adjusted to the MappingFolder.
|
// If the file exists at the given path relative to the MappingsFolder, then return that.
|
||||||
// Else the path will just be as-is.
|
// Else the path will just be as-is.
|
||||||
return File.ReadAllBytes(Path.GetFileName(path) == path ? Path.Combine(GetMappingFolder(), path) : path);
|
return File.ReadAllBytes(File.Exists(PathUtils.Combine(GetMappingFolder(), path)) ? PathUtils.Combine(GetMappingFolder(), path) : path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IFileSystemHandler.ReadResponseBodyAsString"/>
|
/// <inheritdoc cref="IFileSystemHandler.ReadResponseBodyAsString"/>
|
||||||
public string ReadResponseBodyAsString(string path)
|
public string ReadResponseBodyAsString(string path)
|
||||||
{
|
{
|
||||||
Check.NotNullOrEmpty(path, nameof(path));
|
Check.NotNullOrEmpty(path, nameof(path));
|
||||||
|
path = PathUtils.CleanPath(path);
|
||||||
// In case the path is a filename, the path will be adjusted to the MappingFolder.
|
// In case the path is a filename, the path will be adjusted to the MappingFolder.
|
||||||
// Else the path will just be as-is.
|
// Else the path will just be as-is.
|
||||||
return File.ReadAllText(Path.GetFileName(path) == path ? Path.Combine(GetMappingFolder(), path) : path);
|
return File.ReadAllText(File.Exists(PathUtils.Combine(GetMappingFolder(), path)) ? PathUtils.Combine(GetMappingFolder(), path) : path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IFileSystemHandler.FileExists"/>
|
/// <inheritdoc cref="IFileSystemHandler.FileExists"/>
|
||||||
|
|||||||
30
src/WireMock.Net/Http/ByteArrayContentHelper.cs
Normal file
30
src/WireMock.Net/Http/ByteArrayContentHelper.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using WireMock.Validation;
|
||||||
|
|
||||||
|
namespace WireMock.Http
|
||||||
|
{
|
||||||
|
internal static class ByteArrayContentHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a ByteArrayContent object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="content">The byte[] content (cannot be null)</param>
|
||||||
|
/// <param name="contentType">The ContentType (can be null)</param>
|
||||||
|
/// <returns>ByteArrayContent</returns>
|
||||||
|
internal static ByteArrayContent Create([NotNull] byte[] content, [CanBeNull] MediaTypeHeaderValue contentType)
|
||||||
|
{
|
||||||
|
Check.NotNull(content, nameof(content));
|
||||||
|
|
||||||
|
var byteContent = new ByteArrayContent(content);
|
||||||
|
if (contentType != null)
|
||||||
|
{
|
||||||
|
byteContent.Headers.Remove(HttpKnownHeaderNames.ContentType);
|
||||||
|
byteContent.Headers.ContentType = contentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return byteContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -68,7 +68,7 @@ namespace WireMock.Http
|
|||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<ResponseMessage> SendAsync([NotNull] HttpClient client, [NotNull] RequestMessage requestMessage, string url)
|
public static async Task<ResponseMessage> SendAsync([NotNull] HttpClient client, [NotNull] RequestMessage requestMessage, string url, bool deserializeJson, bool decompressGzipAndDeflate)
|
||||||
{
|
{
|
||||||
Check.NotNull(client, nameof(client));
|
Check.NotNull(client, nameof(client));
|
||||||
Check.NotNull(requestMessage, nameof(requestMessage));
|
Check.NotNull(requestMessage, nameof(requestMessage));
|
||||||
@@ -83,7 +83,7 @@ namespace WireMock.Http
|
|||||||
var httpResponseMessage = await client.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead);
|
var httpResponseMessage = await client.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead);
|
||||||
|
|
||||||
// Create ResponseMessage
|
// Create ResponseMessage
|
||||||
return await HttpResponseMessageHelper.CreateAsync(httpResponseMessage, requiredUri, originalUri);
|
return await HttpResponseMessageHelper.CreateAsync(httpResponseMessage, requiredUri, originalUri, deserializeJson, decompressGzipAndDeflate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using JetBrains.Annotations;
|
using System;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using WireMock.Types;
|
using WireMock.Types;
|
||||||
using WireMock.Validation;
|
using WireMock.Validation;
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ namespace WireMock.Http
|
|||||||
switch (requestMessage.BodyData?.DetectedBodyType)
|
switch (requestMessage.BodyData?.DetectedBodyType)
|
||||||
{
|
{
|
||||||
case BodyType.Bytes:
|
case BodyType.Bytes:
|
||||||
httpRequestMessage.Content = new ByteArrayContent(requestMessage.BodyData.BodyAsBytes);
|
httpRequestMessage.Content = ByteArrayContentHelper.Create(requestMessage.BodyData.BodyAsBytes, contentType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BodyType.Json:
|
case BodyType.Json:
|
||||||
|
|||||||
18
src/WireMock.Net/Http/HttpRequestMethods.cs
Normal file
18
src/WireMock.Net/Http/HttpRequestMethods.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace WireMock.Http
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
|
||||||
|
/// </summary>
|
||||||
|
internal static class HttpRequestMethods
|
||||||
|
{
|
||||||
|
public const string CONNECT = "CONNECT";
|
||||||
|
public const string DELETE = "DELETE";
|
||||||
|
public const string GET = "GET";
|
||||||
|
public const string HEAD = "HEAD";
|
||||||
|
public const string OPTIONS = "OPTIONS";
|
||||||
|
public const string PATCH = "PATCH";
|
||||||
|
public const string POST = "POST";
|
||||||
|
public const string PUT = "PUT";
|
||||||
|
public const string TRACE = "TRACE";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ namespace WireMock.Http
|
|||||||
{
|
{
|
||||||
internal static class HttpResponseMessageHelper
|
internal static class HttpResponseMessageHelper
|
||||||
{
|
{
|
||||||
public static async Task<ResponseMessage> CreateAsync(HttpResponseMessage httpResponseMessage, Uri requiredUri, Uri originalUri)
|
public static async Task<ResponseMessage> CreateAsync(HttpResponseMessage httpResponseMessage, Uri requiredUri, Uri originalUri, bool deserializeJson, bool decompressGzipAndDeflate)
|
||||||
{
|
{
|
||||||
var responseMessage = new ResponseMessage { StatusCode = (int)httpResponseMessage.StatusCode };
|
var responseMessage = new ResponseMessage { StatusCode = (int)httpResponseMessage.StatusCode };
|
||||||
|
|
||||||
@@ -24,7 +24,21 @@ namespace WireMock.Http
|
|||||||
contentTypeHeader = headers.First(header => string.Equals(header.Key, HttpKnownHeaderNames.ContentType, StringComparison.OrdinalIgnoreCase)).Value;
|
contentTypeHeader = headers.First(header => string.Equals(header.Key, HttpKnownHeaderNames.ContentType, StringComparison.OrdinalIgnoreCase)).Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
responseMessage.BodyData = await BodyParser.Parse(stream, contentTypeHeader?.FirstOrDefault());
|
IEnumerable<string> contentEncodingHeader = null;
|
||||||
|
if (headers.Any(header => string.Equals(header.Key, HttpKnownHeaderNames.ContentEncoding, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
contentEncodingHeader = headers.First(header => string.Equals(header.Key, HttpKnownHeaderNames.ContentEncoding, StringComparison.OrdinalIgnoreCase)).Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bodyParserSettings = new BodyParserSettings
|
||||||
|
{
|
||||||
|
Stream = stream,
|
||||||
|
ContentType = contentTypeHeader?.FirstOrDefault(),
|
||||||
|
DeserializeJson = deserializeJson,
|
||||||
|
ContentEncoding = contentEncodingHeader?.FirstOrDefault(),
|
||||||
|
DecompressGZipAndDeflate = decompressGzipAndDeflate
|
||||||
|
};
|
||||||
|
responseMessage.BodyData = await BodyParser.Parse(bodyParserSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var header in headers)
|
foreach (var header in headers)
|
||||||
|
|||||||
@@ -36,12 +36,27 @@ namespace WireMock.Logging
|
|||||||
Console.WriteLine(Format("Warn", formatString, args));
|
Console.WriteLine(Format("Warn", formatString, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <see cref="IWireMockLogger.Error"/>
|
/// <see cref="IWireMockLogger.Error(string, object[])"/>
|
||||||
public void Error(string formatString, params object[] args)
|
public void Error(string formatString, params object[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine(Format("Error", formatString, args));
|
Console.WriteLine(Format("Error", formatString, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <see cref="IWireMockLogger.Error(string, Exception)"/>
|
||||||
|
public void Error(string formatString, Exception exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine(Format("Error", formatString, exception.Message));
|
||||||
|
|
||||||
|
if (exception is AggregateException ae)
|
||||||
|
{
|
||||||
|
ae.Handle(ex =>
|
||||||
|
{
|
||||||
|
Console.WriteLine(Format("Error", "Exception {0}", exception.Message));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <see cref="IWireMockLogger.DebugRequestResponse"/>
|
/// <see cref="IWireMockLogger.DebugRequestResponse"/>
|
||||||
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
|
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using WireMock.Admin.Requests;
|
using System;
|
||||||
|
using WireMock.Admin.Requests;
|
||||||
|
|
||||||
namespace WireMock.Logging
|
namespace WireMock.Logging
|
||||||
{
|
{
|
||||||
@@ -26,12 +27,18 @@ namespace WireMock.Logging
|
|||||||
// Log nothing
|
// Log nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <see cref="IWireMockLogger.Error"/>
|
/// <see cref="IWireMockLogger.Error(string, object[])"/>
|
||||||
public void Error(string formatString, params object[] args)
|
public void Error(string formatString, params object[] args)
|
||||||
{
|
{
|
||||||
// Log nothing
|
// Log nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <see cref="IWireMockLogger.Error(string, Exception)"/>
|
||||||
|
public void Error(string formatString, Exception exception)
|
||||||
|
{
|
||||||
|
// Log nothing
|
||||||
|
}
|
||||||
|
|
||||||
/// <see cref="IWireMockLogger.DebugRequestResponse"/>
|
/// <see cref="IWireMockLogger.DebugRequestResponse"/>
|
||||||
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
|
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace WireMock.Matchers
|
|||||||
|
|
||||||
object result = null;
|
object result = null;
|
||||||
|
|
||||||
#if NET451 || NET452
|
#if (NET451 || NET452)
|
||||||
var compilerParams = new System.CodeDom.Compiler.CompilerParameters
|
var compilerParams = new System.CodeDom.Compiler.CompilerParameters
|
||||||
{
|
{
|
||||||
GenerateInMemory = true,
|
GenerateInMemory = true,
|
||||||
@@ -122,36 +122,42 @@ namespace WireMock.Matchers
|
|||||||
{
|
{
|
||||||
result = methodInfo.Invoke(helper, new[] { inputValue });
|
result = methodInfo.Invoke(helper, new[] { inputValue });
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new WireMockException("CSharpCodeMatcher: Unable to call method 'IsMatch' in WireMock.CodeHelper");
|
throw new WireMockException("CSharpCodeMatcher: Unable to call method 'IsMatch' in WireMock.CodeHelper", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif NET46 || NET461
|
#elif (NET46 || NET461)
|
||||||
dynamic script;
|
dynamic script;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
script = CSScriptLibrary.CSScript.Evaluator.CompileCode(source).CreateObject("*");
|
script = CSScriptLibrary.CSScript.Evaluator.CompileCode(source).CreateObject("*");
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new WireMockException("CSharpCodeMatcher: Unable to create compiler for WireMock.CodeHelper");
|
throw new WireMockException("CSharpCodeMatcher: Unable to create compiler for WireMock.CodeHelper", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = script.IsMatch(inputValue);
|
result = script.IsMatch(inputValue);
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper");
|
throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper", ex);
|
||||||
}
|
}
|
||||||
#elif NETSTANDARD2_0
|
|
||||||
|
#elif (NETSTANDARD2_0 || NETSTANDARD2_1)
|
||||||
dynamic script;
|
dynamic script;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var assembly = CSScriptLib.CSScript.Evaluator.CompileCode(source);
|
var assembly = CSScriptLib.CSScript.Evaluator.CompileCode(source);
|
||||||
|
|
||||||
|
#if NETSTANDARD2_0
|
||||||
script = csscript.GenericExtensions.CreateObject(assembly, "*");
|
script = csscript.GenericExtensions.CreateObject(assembly, "*");
|
||||||
|
#else
|
||||||
|
script = CSScriptLib.ReflectionExtensions.CreateObject(assembly,"*");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -164,10 +170,10 @@ namespace WireMock.Matchers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper");
|
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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ namespace WireMock.Matchers
|
|||||||
IgnoreCase = ignoreCase;
|
IgnoreCase = ignoreCase;
|
||||||
MatchBehaviour = matchBehaviour;
|
MatchBehaviour = matchBehaviour;
|
||||||
|
|
||||||
RegexOptions options = RegexOptions.Compiled;
|
RegexOptions options = RegexOptions.Compiled | RegexOptions.Multiline;
|
||||||
|
|
||||||
if (ignoreCase)
|
if (ignoreCase)
|
||||||
{
|
{
|
||||||
options |= RegexOptions.IgnoreCase;
|
options |= RegexOptions.IgnoreCase;
|
||||||
|
|||||||
@@ -9,14 +9,15 @@ namespace WireMock.Matchers.Request
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The request cookie matcher.
|
/// The request cookie matcher.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <inheritdoc cref="IRequestMatcher"/>
|
||||||
public class RequestMessageCookieMatcher : IRequestMatcher
|
public class RequestMessageCookieMatcher : IRequestMatcher
|
||||||
{
|
{
|
||||||
private readonly MatchBehaviour _matchBehaviour;
|
private readonly MatchBehaviour _matchBehaviour;
|
||||||
private readonly bool _ignoreCase;
|
private readonly bool _ignoreCase;
|
||||||
|
|
||||||
/// <value>
|
/// <summary>
|
||||||
/// The funcs.
|
/// The functions
|
||||||
/// </value>
|
/// </summary>
|
||||||
public Func<IDictionary<string, string>, bool>[] Funcs { get; }
|
public Func<IDictionary<string, string>, bool>[] Funcs { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -32,11 +33,11 @@ namespace WireMock.Matchers.Request
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="matchBehaviour">The match behaviour.</param>
|
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="pattern">The pattern.</param>
|
/// <param name="pattern">The pattern.</param>
|
||||||
/// <param name="ignoreCase">The ignoreCase.</param>
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, [NotNull] string pattern, bool ignoreCase = true)
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, [NotNull] string pattern, bool ignoreCase)
|
||||||
{
|
{
|
||||||
Check.NotNull(name, nameof(name));
|
Check.NotNull(name, nameof(name));
|
||||||
Check.NotNull(pattern, nameof(pattern));
|
Check.NotNull(pattern, nameof(pattern));
|
||||||
@@ -50,15 +51,32 @@ namespace WireMock.Matchers.Request
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="patterns">The patterns.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
|
public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params string[] patterns) :
|
||||||
|
this(matchBehaviour, name, ignoreCase, patterns.Select(pattern => new WildcardMatcher(matchBehaviour, pattern, ignoreCase)).Cast<IStringMatcher>().ToArray())
|
||||||
|
{
|
||||||
|
Check.NotNull(patterns, nameof(patterns));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="matchers">The matchers.</param>
|
/// <param name="matchers">The matchers.</param>
|
||||||
public RequestMessageCookieMatcher([NotNull] string name, [NotNull] params IStringMatcher[] matchers)
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
|
public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params IStringMatcher[] matchers)
|
||||||
{
|
{
|
||||||
Check.NotNull(name, nameof(name));
|
Check.NotNull(name, nameof(name));
|
||||||
Check.NotNull(matchers, nameof(matchers));
|
Check.NotNull(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_matchBehaviour = matchBehaviour;
|
||||||
Name = name;
|
Name = name;
|
||||||
Matchers = matchers;
|
Matchers = matchers;
|
||||||
|
_ignoreCase = ignoreCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -52,33 +52,32 @@ namespace WireMock.Matchers.Request
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="RequestMessageHeaderMatcher"/> class.
|
/// Initializes a new instance of the <see cref="RequestMessageHeaderMatcher"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="patterns">The patterns.</param>
|
/// <param name="patterns">The patterns.</param>
|
||||||
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
/// <param name="matchBehaviour">The match behaviour.</param>
|
public RequestMessageHeaderMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params string[] patterns) :
|
||||||
public RequestMessageHeaderMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, [NotNull] string[] patterns, bool ignoreCase)
|
this(matchBehaviour, name, ignoreCase, patterns.Select(pattern => new WildcardMatcher(matchBehaviour, pattern, ignoreCase)).Cast<IStringMatcher>().ToArray())
|
||||||
{
|
{
|
||||||
Check.NotNull(name, nameof(name));
|
|
||||||
Check.NotNull(patterns, nameof(patterns));
|
Check.NotNull(patterns, nameof(patterns));
|
||||||
|
|
||||||
_matchBehaviour = matchBehaviour;
|
|
||||||
_ignoreCase = ignoreCase;
|
|
||||||
Name = name;
|
|
||||||
Matchers = patterns.Select(pattern => new WildcardMatcher(matchBehaviour, pattern, ignoreCase)).Cast<IStringMatcher>().ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="RequestMessageHeaderMatcher"/> class.
|
/// Initializes a new instance of the <see cref="RequestMessageHeaderMatcher"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="matchers">The matchers.</param>
|
/// <param name="matchers">The matchers.</param>
|
||||||
public RequestMessageHeaderMatcher([NotNull] string name, [NotNull] params IStringMatcher[] matchers)
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
|
public RequestMessageHeaderMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params IStringMatcher[] matchers)
|
||||||
{
|
{
|
||||||
Check.NotNull(name, nameof(name));
|
Check.NotNull(name, nameof(name));
|
||||||
Check.NotNull(matchers, nameof(matchers));
|
Check.NotNull(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_matchBehaviour = matchBehaviour;
|
||||||
Name = name;
|
Name = name;
|
||||||
Matchers = matchers;
|
Matchers = matchers;
|
||||||
|
_ignoreCase = ignoreCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -125,7 +124,7 @@ namespace WireMock.Matchers.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
WireMockList<string> list = headers[Name];
|
WireMockList<string> list = headers[Name];
|
||||||
return Matchers.Max(m => list.Max(value => m.IsMatch(value))); // TODO : is this correct ?
|
return Matchers.Max(m => list.Max(m.IsMatch)); // TODO : is this correct ?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
2
src/WireMock.Net/Matchers/Request/_mock4net-license.txt
Normal file
2
src/WireMock.Net/Matchers/Request/_mock4net-license.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Some source files in this folder are based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
|
For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
40
src/WireMock.Net/Owin/AspNetCoreSelfHost.NETStandard.cs
Normal file
40
src/WireMock.Net/Owin/AspNetCoreSelfHost.NETStandard.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#if USE_ASPNETCORE && !NETSTANDARD1_3
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
|
|
||||||
|
namespace WireMock.Owin
|
||||||
|
{
|
||||||
|
internal partial class AspNetCoreSelfHost
|
||||||
|
{
|
||||||
|
private static void SetKestrelOptionsLimits(KestrelServerOptions options)
|
||||||
|
{
|
||||||
|
options.Limits.KeepAliveTimeout = TimeSpan.MaxValue;
|
||||||
|
options.Limits.MaxRequestBodySize = null; // https://stackoverflow.com/questions/46738364/increase-upload-request-length-limit-in-kestrel
|
||||||
|
options.Limits.MaxRequestBufferSize = null;
|
||||||
|
options.Limits.MaxRequestHeaderCount = 100;
|
||||||
|
options.Limits.MaxResponseBufferSize = null;
|
||||||
|
options.Limits.RequestHeadersTimeout = TimeSpan.MaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetHttpsAndUrls(KestrelServerOptions options, ICollection<(string Url, int Port)> urlDetails)
|
||||||
|
{
|
||||||
|
foreach (var detail in urlDetails)
|
||||||
|
{
|
||||||
|
if (detail.Url.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
options.Listen(System.Net.IPAddress.Any, detail.Port, listenOptions =>
|
||||||
|
{
|
||||||
|
listenOptions.UseHttps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
options.Listen(System.Net.IPAddress.Any, detail.Port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
32
src/WireMock.Net/Owin/AspNetCoreSelfHost.NETStandard13.cs
Normal file
32
src/WireMock.Net/Owin/AspNetCoreSelfHost.NETStandard13.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#if USE_ASPNETCORE && NETSTANDARD1_3
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Server.Kestrel;
|
||||||
|
using WireMock.HttpsCertificate;
|
||||||
|
|
||||||
|
namespace WireMock.Owin
|
||||||
|
{
|
||||||
|
internal partial class AspNetCoreSelfHost
|
||||||
|
{
|
||||||
|
private static void SetKestrelOptionsLimits(KestrelServerOptions options)
|
||||||
|
{
|
||||||
|
options.Limits.KeepAliveTimeout = TimeSpan.MaxValue;
|
||||||
|
options.Limits.MaxRequestBufferSize = null;
|
||||||
|
options.Limits.MaxRequestHeaderCount = 100;
|
||||||
|
options.Limits.MaxResponseBufferSize = null;
|
||||||
|
options.Limits.RequestHeadersTimeout = TimeSpan.MaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetHttpsAndUrls(KestrelServerOptions options, ICollection<(string Url, int Port)> urlDetails)
|
||||||
|
{
|
||||||
|
var urls = urlDetails.Select(u => u.Url);
|
||||||
|
if (urls.Any(u => u.StartsWith("https://", StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
options.UseHttps(PublicCertificateHelper.GetX509Certificate2());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -1,172 +1,158 @@
|
|||||||
#if USE_ASPNETCORE
|
#if USE_ASPNETCORE
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using WireMock.Handlers;
|
using WireMock.Logging;
|
||||||
using WireMock.HttpsCertificate;
|
using WireMock.Owin.Mappers;
|
||||||
using WireMock.Logging;
|
using WireMock.Util;
|
||||||
using WireMock.Owin.Mappers;
|
using WireMock.Validation;
|
||||||
using WireMock.Util;
|
|
||||||
using WireMock.Validation;
|
namespace WireMock.Owin
|
||||||
|
{
|
||||||
namespace WireMock.Owin
|
internal partial class AspNetCoreSelfHost : IOwinSelfHost
|
||||||
{
|
{
|
||||||
internal class AspNetCoreSelfHost : IOwinSelfHost
|
private readonly CancellationTokenSource _cts = new CancellationTokenSource();
|
||||||
{
|
private readonly IWireMockMiddlewareOptions _options;
|
||||||
private readonly CancellationTokenSource _cts = new CancellationTokenSource();
|
private readonly IWireMockLogger _logger;
|
||||||
private readonly IWireMockMiddlewareOptions _options;
|
private readonly HostUrlOptions _urlOptions;
|
||||||
private readonly string[] _urls;
|
|
||||||
private readonly IWireMockLogger _logger;
|
private Exception _runningException;
|
||||||
private Exception _runningException;
|
private IWebHost _host;
|
||||||
|
|
||||||
private IWebHost _host;
|
public bool IsStarted { get; private set; }
|
||||||
|
|
||||||
public bool IsStarted { get; private set; }
|
public List<string> Urls { get; } = new List<string>();
|
||||||
|
|
||||||
public List<string> Urls { get; } = new List<string>();
|
public List<int> Ports { get; } = new List<int>();
|
||||||
|
|
||||||
public List<int> Ports { get; } = new List<int>();
|
public Exception RunningException => _runningException;
|
||||||
|
|
||||||
public Exception RunningException => _runningException;
|
public AspNetCoreSelfHost([NotNull] IWireMockMiddlewareOptions options, [NotNull] HostUrlOptions urlOptions)
|
||||||
|
{
|
||||||
public AspNetCoreSelfHost([NotNull] IWireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes)
|
Check.NotNull(options, nameof(options));
|
||||||
{
|
Check.NotNull(urlOptions, nameof(urlOptions));
|
||||||
Check.NotNull(options, nameof(options));
|
|
||||||
Check.NotNullOrEmpty(uriPrefixes, nameof(uriPrefixes));
|
_logger = options.Logger ?? new WireMockConsoleLogger();
|
||||||
|
|
||||||
_logger = options.Logger ?? new WireMockConsoleLogger();
|
_options = options;
|
||||||
|
_urlOptions = urlOptions;
|
||||||
foreach (string uriPrefix in uriPrefixes)
|
}
|
||||||
{
|
|
||||||
Urls.Add(uriPrefix);
|
public Task StartAsync()
|
||||||
|
{
|
||||||
PortUtils.TryExtract(uriPrefix, out string protocol, out string host, out int port);
|
var builder = new WebHostBuilder();
|
||||||
Ports.Add(port);
|
|
||||||
}
|
// Workaround for https://github.com/WireMock-Net/WireMock.Net/issues/292
|
||||||
|
// On some platforms, AppContext.BaseDirectory is null, which causes WebHostBuilder to fail if ContentRoot is not
|
||||||
_options = options;
|
// specified (even though we don't actually use that base path mechanism, since we have our own way of configuring
|
||||||
_urls = uriPrefixes;
|
// a filesystem handler).
|
||||||
}
|
if (string.IsNullOrEmpty(AppContext.BaseDirectory))
|
||||||
|
{
|
||||||
public Task StartAsync()
|
builder.UseContentRoot(System.IO.Directory.GetCurrentDirectory());
|
||||||
{
|
}
|
||||||
var builder = new WebHostBuilder();
|
|
||||||
|
_host = builder
|
||||||
// Workaround for https://github.com/WireMock-Net/WireMock.Net/issues/292
|
.ConfigureServices(services =>
|
||||||
// On some platforms, AppContext.BaseDirectory is null, which causes WebHostBuilder to fail if ContentRoot is not
|
{
|
||||||
// specified (even though we don't actually use that base path mechanism, since we have our own way of configuring
|
services.AddSingleton(_options);
|
||||||
// a filesystem handler).
|
services.AddSingleton<IMappingMatcher, MappingMatcher>();
|
||||||
if (string.IsNullOrEmpty(AppContext.BaseDirectory))
|
services.AddSingleton<IOwinRequestMapper, OwinRequestMapper>();
|
||||||
{
|
services.AddSingleton<IOwinResponseMapper, OwinResponseMapper>();
|
||||||
builder.UseContentRoot(System.IO.Directory.GetCurrentDirectory());
|
})
|
||||||
}
|
.Configure(appBuilder =>
|
||||||
|
{
|
||||||
_host = builder
|
appBuilder.UseMiddleware<GlobalExceptionMiddleware>();
|
||||||
.ConfigureServices(services =>
|
|
||||||
{
|
_options.PreWireMockMiddlewareInit?.Invoke(appBuilder);
|
||||||
services.AddSingleton(_options.FileSystemHandler);
|
|
||||||
services.AddSingleton(_options);
|
appBuilder.UseMiddleware<WireMockMiddleware>();
|
||||||
services.AddSingleton<IMappingMatcher, MappingMatcher>();
|
|
||||||
services.AddSingleton<IOwinRequestMapper, OwinRequestMapper>();
|
_options.PostWireMockMiddlewareInit?.Invoke(appBuilder);
|
||||||
services.AddSingleton<IOwinResponseMapper, OwinResponseMapper>();
|
})
|
||||||
})
|
.UseKestrel(options =>
|
||||||
.Configure(appBuilder =>
|
{
|
||||||
{
|
SetKestrelOptionsLimits(options);
|
||||||
appBuilder.UseMiddleware<GlobalExceptionMiddleware>();
|
|
||||||
|
SetHttpsAndUrls(options, _urlOptions.GetDetails());
|
||||||
_options.PreWireMockMiddlewareInit?.Invoke(appBuilder);
|
})
|
||||||
|
|
||||||
appBuilder.UseMiddleware<WireMockMiddleware>();
|
#if NETSTANDARD1_3
|
||||||
|
.UseUrls(_urlOptions.GetDetails().Select(u => u.Url).ToArray())
|
||||||
_options.PostWireMockMiddlewareInit?.Invoke(appBuilder);
|
#endif
|
||||||
})
|
.Build();
|
||||||
.UseKestrel(options =>
|
|
||||||
{
|
return RunHost(_cts.Token);
|
||||||
#if NETSTANDARD1_3
|
}
|
||||||
if (_urls.Any(u => u.StartsWith("https://", StringComparison.OrdinalIgnoreCase)))
|
|
||||||
{
|
private Task RunHost(CancellationToken token)
|
||||||
options.UseHttps(PublicCertificateHelper.GetX509Certificate2());
|
{
|
||||||
}
|
try
|
||||||
#else
|
{
|
||||||
// https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?tabs=aspnetcore2x
|
var appLifetime = (IApplicationLifetime)_host.Services.GetService(typeof(IApplicationLifetime));
|
||||||
foreach (string url in _urls.Where(u => u.StartsWith("http://", StringComparison.OrdinalIgnoreCase)))
|
appLifetime.ApplicationStarted.Register(() =>
|
||||||
{
|
{
|
||||||
PortUtils.TryExtract(url, out string protocol, out string host, out int port);
|
var addresses = _host.ServerFeatures
|
||||||
options.Listen(System.Net.IPAddress.Any, port);
|
.Get<Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature>()
|
||||||
}
|
.Addresses;
|
||||||
|
|
||||||
foreach (string url in _urls.Where(u => u.StartsWith("https://", StringComparison.OrdinalIgnoreCase)))
|
foreach (string address in addresses)
|
||||||
{
|
{
|
||||||
PortUtils.TryExtract(url, out string protocol, out string host, out int port);
|
Urls.Add(address.Replace("0.0.0.0", "localhost"));
|
||||||
options.Listen(System.Net.IPAddress.Any, port, listenOptions =>
|
|
||||||
{
|
PortUtils.TryExtract(address, out string protocol, out string host, out int port);
|
||||||
listenOptions.UseHttps(); // PublicCertificateHelper.GetX509Certificate2()
|
Ports.Add(port);
|
||||||
});
|
}
|
||||||
}
|
|
||||||
#endif
|
IsStarted = true;
|
||||||
})
|
});
|
||||||
#if NETSTANDARD1_3
|
|
||||||
.UseUrls(_urls)
|
#if NETSTANDARD1_3
|
||||||
#endif
|
_logger.Info("WireMock.Net server using netstandard1.3");
|
||||||
.Build();
|
#elif NETSTANDARD2_0
|
||||||
|
_logger.Info("WireMock.Net server using netstandard2.0");
|
||||||
return RunHost(_cts.Token);
|
#elif NETSTANDARD2_1
|
||||||
}
|
_logger.Info("WireMock.Net server using netstandard2.1");
|
||||||
|
#elif NET46
|
||||||
private Task RunHost(CancellationToken token)
|
_logger.Info("WireMock.Net server using .net 4.6.1 or higher");
|
||||||
{
|
#endif
|
||||||
try
|
|
||||||
{
|
#if NETSTANDARD1_3
|
||||||
var appLifetime = (IApplicationLifetime)_host.Services.GetService(typeof(IApplicationLifetime));
|
return Task.Run(() =>
|
||||||
appLifetime.ApplicationStarted.Register(() =>
|
{
|
||||||
{
|
_host.Run(token);
|
||||||
IsStarted = true;
|
});
|
||||||
});
|
#else
|
||||||
|
return _host.RunAsync(token);
|
||||||
#if NETSTANDARD1_3
|
#endif
|
||||||
_logger.Info("WireMock.Net server using netstandard1.3");
|
}
|
||||||
#elif NETSTANDARD2_0
|
catch (Exception e)
|
||||||
_logger.Info("WireMock.Net server using netstandard2.0");
|
{
|
||||||
#elif NET46
|
_runningException = e;
|
||||||
_logger.Info("WireMock.Net server using .net 4.6.1 or higher");
|
_logger.Error(e.ToString());
|
||||||
#endif
|
|
||||||
#if NETSTANDARD1_3
|
IsStarted = false;
|
||||||
return Task.Run(() =>
|
|
||||||
{
|
return Task.CompletedTask;
|
||||||
_host.Run(token);
|
}
|
||||||
});
|
}
|
||||||
#else
|
|
||||||
return _host.RunAsync(token);
|
public Task StopAsync()
|
||||||
#endif
|
{
|
||||||
}
|
_cts.Cancel();
|
||||||
catch (Exception e)
|
|
||||||
{
|
IsStarted = false;
|
||||||
_runningException = e;
|
#if NETSTANDARD1_3
|
||||||
_logger.Error(e.ToString());
|
return Task.FromResult(true);
|
||||||
|
#else
|
||||||
IsStarted = false;
|
return _host.StopAsync();
|
||||||
|
#endif
|
||||||
return Task.CompletedTask;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task StopAsync()
|
|
||||||
{
|
|
||||||
_cts.Cancel();
|
|
||||||
|
|
||||||
IsStarted = false;
|
|
||||||
#if NETSTANDARD1_3
|
|
||||||
return Task.FromResult(true);
|
|
||||||
#else
|
|
||||||
return _host.StopAsync();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
43
src/WireMock.Net/Owin/HostUrlOptions.cs
Normal file
43
src/WireMock.Net/Owin/HostUrlOptions.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using WireMock.Util;
|
||||||
|
|
||||||
|
namespace WireMock.Owin
|
||||||
|
{
|
||||||
|
internal class HostUrlOptions
|
||||||
|
{
|
||||||
|
public ICollection<string> Urls { get; set; }
|
||||||
|
|
||||||
|
public int? Port { get; set; }
|
||||||
|
|
||||||
|
public bool UseSSL { get; set; }
|
||||||
|
|
||||||
|
public ICollection<(string Url, int Port)> GetDetails()
|
||||||
|
{
|
||||||
|
var list = new List<(string Url, int Port)>();
|
||||||
|
if (Urls == null)
|
||||||
|
{
|
||||||
|
int port = Port > 0 ? Port.Value : FindFreeTcpPort();
|
||||||
|
list.Add(($"{(UseSSL ? "https" : "http")}://localhost:{port}", port));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (string url in Urls)
|
||||||
|
{
|
||||||
|
PortUtils.TryExtract(url, out string protocol, out string host, out int port);
|
||||||
|
list.Add((url, port));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int FindFreeTcpPort()
|
||||||
|
{
|
||||||
|
#if USE_ASPNETCORE || NETSTANDARD2_0 || NETSTANDARD2_1
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return PortUtils.FindFreeTcpPort();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,5 +39,11 @@ namespace WireMock.Owin
|
|||||||
IFileSystemHandler FileSystemHandler { get; set; }
|
IFileSystemHandler FileSystemHandler { get; set; }
|
||||||
|
|
||||||
bool? AllowBodyForAllHttpMethods { get; set; }
|
bool? AllowBodyForAllHttpMethods { get; set; }
|
||||||
|
|
||||||
|
bool? AllowOnlyDefinedHttpStatusCodeInResponse { get; set; }
|
||||||
|
|
||||||
|
bool? DisableJsonBodyParsing { get; set; }
|
||||||
|
|
||||||
|
bool? DisableRequestBodyDecompressing { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using WireMock.Http;
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
#if !USE_ASPNETCORE
|
#if !USE_ASPNETCORE
|
||||||
@@ -27,12 +28,18 @@ namespace WireMock.Owin.Mappers
|
|||||||
string method = request.Method;
|
string method = request.Method;
|
||||||
|
|
||||||
Dictionary<string, string[]> headers = null;
|
Dictionary<string, string[]> headers = null;
|
||||||
|
IEnumerable<string> contentEncodingHeader = null;
|
||||||
if (request.Headers.Any())
|
if (request.Headers.Any())
|
||||||
{
|
{
|
||||||
headers = new Dictionary<string, string[]>();
|
headers = new Dictionary<string, string[]>();
|
||||||
foreach (var header in request.Headers)
|
foreach (var header in request.Headers)
|
||||||
{
|
{
|
||||||
headers.Add(header.Key, header.Value);
|
headers.Add(header.Key, header.Value);
|
||||||
|
|
||||||
|
if (string.Equals(header.Key, HttpKnownHeaderNames.ContentEncoding, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
contentEncodingHeader = header.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +56,16 @@ namespace WireMock.Owin.Mappers
|
|||||||
BodyData body = null;
|
BodyData body = null;
|
||||||
if (request.Body != null && BodyParser.ShouldParseBody(method, options.AllowBodyForAllHttpMethods == true))
|
if (request.Body != null && BodyParser.ShouldParseBody(method, options.AllowBodyForAllHttpMethods == true))
|
||||||
{
|
{
|
||||||
body = await BodyParser.Parse(request.Body, request.ContentType);
|
var bodyParserSettings = new BodyParserSettings
|
||||||
|
{
|
||||||
|
Stream = request.Body,
|
||||||
|
ContentType = request.ContentType,
|
||||||
|
DeserializeJson = !options.DisableJsonBodyParsing.GetValueOrDefault(false),
|
||||||
|
ContentEncoding = contentEncodingHeader?.FirstOrDefault(),
|
||||||
|
DecompressGZipAndDeflate = !options.DisableRequestBodyDecompressing.GetValueOrDefault(false)
|
||||||
|
};
|
||||||
|
|
||||||
|
body = await BodyParser.Parse(bodyParserSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RequestMessage(urldetails, method, clientIP, body, headers, cookies) { DateTime = DateTime.UtcNow };
|
return new RequestMessage(urldetails, method, clientIP, body, headers, cookies) { DateTime = DateTime.UtcNow };
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using RandomDataGenerator.FieldOptions;
|
using RandomDataGenerator.FieldOptions;
|
||||||
using RandomDataGenerator.Randomizers;
|
using RandomDataGenerator.Randomizers;
|
||||||
|
using WireMock.Exceptions;
|
||||||
using WireMock.Handlers;
|
using WireMock.Handlers;
|
||||||
using WireMock.Http;
|
using WireMock.Http;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Types;
|
using WireMock.Types;
|
||||||
using WireMock.Util;
|
|
||||||
using WireMock.Validation;
|
using WireMock.Validation;
|
||||||
#if !USE_ASPNETCORE
|
#if !USE_ASPNETCORE
|
||||||
using IResponse = Microsoft.Owin.IOwinResponse;
|
using IResponse = Microsoft.Owin.IOwinResponse;
|
||||||
@@ -24,11 +25,11 @@ namespace WireMock.Owin.Mappers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// OwinResponseMapper
|
/// OwinResponseMapper
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OwinResponseMapper : IOwinResponseMapper
|
internal class OwinResponseMapper : IOwinResponseMapper
|
||||||
{
|
{
|
||||||
private readonly IRandomizerNumber<double> _randomizerDouble = RandomizerFactory.GetRandomizer(new FieldOptionsDouble { Min = 0, Max = 1 });
|
private readonly IRandomizerNumber<double> _randomizerDouble = RandomizerFactory.GetRandomizer(new FieldOptionsDouble { Min = 0, Max = 1 });
|
||||||
private readonly IRandomizerBytes _randomizerBytes = RandomizerFactory.GetRandomizer(new FieldOptionsBytes { Min = 100, Max = 200 });
|
private readonly IRandomizerBytes _randomizerBytes = RandomizerFactory.GetRandomizer(new FieldOptionsBytes { Min = 100, Max = 200 });
|
||||||
private readonly IFileSystemHandler _fileSystemHandler;
|
private readonly IWireMockMiddlewareOptions _options;
|
||||||
private readonly Encoding _utf8NoBom = new UTF8Encoding(false);
|
private readonly Encoding _utf8NoBom = new UTF8Encoding(false);
|
||||||
|
|
||||||
// https://msdn.microsoft.com/en-us/library/78h415ay(v=vs.110).aspx
|
// https://msdn.microsoft.com/en-us/library/78h415ay(v=vs.110).aspx
|
||||||
@@ -43,12 +44,12 @@ namespace WireMock.Owin.Mappers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fileSystemHandler">The IFileSystemHandler.</param>
|
/// <param name="options">The IWireMockMiddlewareOptions.</param>
|
||||||
public OwinResponseMapper(IFileSystemHandler fileSystemHandler)
|
public OwinResponseMapper(IWireMockMiddlewareOptions options)
|
||||||
{
|
{
|
||||||
Check.NotNull(fileSystemHandler, nameof(fileSystemHandler));
|
Check.NotNull(options, nameof(options));
|
||||||
|
|
||||||
_fileSystemHandler = fileSystemHandler;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IOwinResponseMapper.MapAsync"/>
|
/// <inheritdoc cref="IOwinResponseMapper.MapAsync"/>
|
||||||
@@ -83,11 +84,13 @@ namespace WireMock.Owin.Mappers
|
|||||||
switch (responseMessage.StatusCode)
|
switch (responseMessage.StatusCode)
|
||||||
{
|
{
|
||||||
case int statusCodeAsInteger:
|
case int statusCodeAsInteger:
|
||||||
response.StatusCode = statusCodeAsInteger;
|
response.StatusCode = MapStatusCode(statusCodeAsInteger);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case string statusCodeAsString:
|
case string statusCodeAsString:
|
||||||
response.StatusCode = int.Parse(statusCodeAsString);
|
// Note: this case will also match on null
|
||||||
|
int.TryParse(statusCodeAsString, out int result);
|
||||||
|
response.StatusCode = MapStatusCode(result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +102,16 @@ namespace WireMock.Owin.Mappers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int MapStatusCode(int code)
|
||||||
|
{
|
||||||
|
if (_options.AllowOnlyDefinedHttpStatusCodeInResponse == true && !Enum.IsDefined(typeof(HttpStatusCode), code))
|
||||||
|
{
|
||||||
|
return (int)HttpStatusCode.OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
private bool IsFault(ResponseMessage responseMessage)
|
private bool IsFault(ResponseMessage responseMessage)
|
||||||
{
|
{
|
||||||
return responseMessage.FaultPercentage == null || _randomizerDouble.Generate() <= responseMessage.FaultPercentage;
|
return responseMessage.FaultPercentage == null || _randomizerDouble.Generate() <= responseMessage.FaultPercentage;
|
||||||
@@ -126,7 +139,7 @@ namespace WireMock.Owin.Mappers
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BodyType.File:
|
case BodyType.File:
|
||||||
bytes = _fileSystemHandler.ReadResponseBodyAsFile(responseMessage.BodyData.BodyAsFile);
|
bytes = _options.FileSystemHandler.ReadResponseBodyAsFile(responseMessage.BodyData.BodyAsFile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,8 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using WireMock.Handlers;
|
|
||||||
using WireMock.Logging;
|
using WireMock.Logging;
|
||||||
using WireMock.Owin.Mappers;
|
using WireMock.Owin.Mappers;
|
||||||
using WireMock.Util;
|
|
||||||
using WireMock.Validation;
|
using WireMock.Validation;
|
||||||
|
|
||||||
namespace WireMock.Owin
|
namespace WireMock.Owin
|
||||||
@@ -19,24 +17,22 @@ namespace WireMock.Owin
|
|||||||
private readonly IWireMockMiddlewareOptions _options;
|
private readonly IWireMockMiddlewareOptions _options;
|
||||||
private readonly CancellationTokenSource _cts = new CancellationTokenSource();
|
private readonly CancellationTokenSource _cts = new CancellationTokenSource();
|
||||||
private readonly IWireMockLogger _logger;
|
private readonly IWireMockLogger _logger;
|
||||||
|
|
||||||
private Exception _runningException;
|
private Exception _runningException;
|
||||||
|
|
||||||
public OwinSelfHost([NotNull] IWireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes)
|
public OwinSelfHost([NotNull] IWireMockMiddlewareOptions options, [NotNull] HostUrlOptions urlOptions)
|
||||||
{
|
{
|
||||||
Check.NotNull(options, nameof(options));
|
Check.NotNull(options, nameof(options));
|
||||||
Check.NotNullOrEmpty(uriPrefixes, nameof(uriPrefixes));
|
Check.NotNull(urlOptions, nameof(urlOptions));
|
||||||
|
|
||||||
_logger = options.Logger ?? new WireMockConsoleLogger();
|
|
||||||
|
|
||||||
foreach (string uriPrefix in uriPrefixes)
|
|
||||||
{
|
|
||||||
Urls.Add(uriPrefix);
|
|
||||||
|
|
||||||
PortUtils.TryExtract(uriPrefix, out string protocol, out string host, out int port);
|
|
||||||
Ports.Add(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
_options = options;
|
_options = options;
|
||||||
|
_logger = options.Logger ?? new WireMockConsoleLogger();
|
||||||
|
|
||||||
|
foreach (var detail in urlOptions.GetDetails())
|
||||||
|
{
|
||||||
|
Urls.Add(detail.Url);
|
||||||
|
Ports.Add(detail.Port);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsStarted { get; private set; }
|
public bool IsStarted { get; private set; }
|
||||||
@@ -76,7 +72,7 @@ namespace WireMock.Owin
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var requestMapper = new OwinRequestMapper();
|
var requestMapper = new OwinRequestMapper();
|
||||||
var responseMapper = new OwinResponseMapper(_options.FileSystemHandler);
|
var responseMapper = new OwinResponseMapper(_options);
|
||||||
var matcher = new MappingMatcher(_options);
|
var matcher = new MappingMatcher(_options);
|
||||||
|
|
||||||
Action<IAppBuilder> startup = app =>
|
Action<IAppBuilder> startup = app =>
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ namespace WireMock.Owin
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_options.Logger.Error($"Providing a Response for Mapping '{result?.Mapping?.Guid}' failed. HttpStatusCode set to 500. Exception: {ex}");
|
_options.Logger.Error($"Providing a Response for Mapping '{result?.Mapping?.Guid}' failed. HttpStatusCode set to 500. Exception: {ex}");
|
||||||
response = ResponseMessageBuilder.Create(JsonConvert.SerializeObject(ex), 500);
|
response = ResponseMessageBuilder.Create(ex.Message, 500);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,5 +42,14 @@ namespace WireMock.Owin
|
|||||||
|
|
||||||
/// <inheritdoc cref="IWireMockMiddlewareOptions.AllowBodyForAllHttpMethods"/>
|
/// <inheritdoc cref="IWireMockMiddlewareOptions.AllowBodyForAllHttpMethods"/>
|
||||||
public bool? AllowBodyForAllHttpMethods { get; set; }
|
public bool? AllowBodyForAllHttpMethods { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IWireMockMiddlewareOptions.AllowOnlyDefinedHttpStatusCodeInResponse"/>
|
||||||
|
public bool? AllowOnlyDefinedHttpStatusCodeInResponse { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IWireMockMiddlewareOptions.DisableJsonBodyParsing"/>
|
||||||
|
public bool? DisableJsonBodyParsing { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IWireMockMiddlewareOptions.DisableRequestBodyDecompressing"/>
|
||||||
|
public bool? DisableRequestBodyDecompressing { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
85
src/WireMock.Net/RequestBuilders/ICookiesRequestBuilder.cs
Normal file
85
src/WireMock.Net/RequestBuilders/ICookiesRequestBuilder.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using JetBrains.Annotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using WireMock.Matchers;
|
||||||
|
|
||||||
|
namespace WireMock.RequestBuilders
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The CookieRequestBuilder interface.
|
||||||
|
/// </summary>
|
||||||
|
public interface ICookiesRequestBuilder : IParamsRequestBuilder
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, pattern and matchBehaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="pattern">The pattern.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, string pattern, MatchBehaviour matchBehaviour);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, pattern, ignoreCase and matchBehaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="pattern">The pattern.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, patterns and matchBehaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="patterns">The patterns.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, string[] patterns, MatchBehaviour matchBehaviour);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, patterns, ignoreCase and matchBehaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="patterns">The patterns.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name and IStringMatcher[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="matchers">The matchers.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, ignoreCase and IStringMatcher[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the cookie-keys.</param>
|
||||||
|
/// <param name="matchers">The matchers.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, bool ignoreCase, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, ignoreCase, matchBehaviour and IStringMatcher[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the cookie-keys.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <param name="matchers">The matchers.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, bool ignoreCase, MatchBehaviour matchBehaviour, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on functions.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="funcs">The cookies funcs.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] params Func<IDictionary<string, string>, bool>[] funcs);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,9 @@ using WireMock.Matchers;
|
|||||||
namespace WireMock.RequestBuilders
|
namespace WireMock.RequestBuilders
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The HeadersAndCookieRequestBuilder interface.
|
/// The HeadersRequestBuilder interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IHeadersAndCookiesRequestBuilder : IParamsRequestBuilder
|
public interface IHeadersRequestBuilder : ICookiesRequestBuilder
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// WithHeader: matching based on name, pattern and matchBehaviour.
|
/// WithHeader: matching based on name, pattern and matchBehaviour.
|
||||||
@@ -56,36 +56,30 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
IRequestBuilder WithHeader([NotNull] string name, [NotNull] params IStringMatcher[] matchers);
|
IRequestBuilder WithHeader([NotNull] string name, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithHeader: matching based on name, ignoreCase and IStringMatcher[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the header-keys.</param>
|
||||||
|
/// <param name="matchers">The matchers.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithHeader([NotNull] string name, bool ignoreCase, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithHeader: matching based on name, ignoreCase, matchBehaviour and IStringMatcher[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the header-keys.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <param name="matchers">The matchers.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithHeader([NotNull] string name, bool ignoreCase, MatchBehaviour matchBehaviour, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// WithHeader: matching based on functions.
|
/// WithHeader: matching based on functions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="funcs">The headers funcs.</param>
|
/// <param name="funcs">The headers funcs.</param>
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
IRequestBuilder WithHeader([NotNull] params Func<IDictionary<string, string[]>, bool>[] funcs);
|
IRequestBuilder WithHeader([NotNull] params Func<IDictionary<string, string[]>, bool>[] funcs);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// WithCookie: cookie matching based on name, pattern, ignoreCase and matchBehaviour.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="pattern">The pattern.</param>
|
|
||||||
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
|
||||||
/// <param name="matchBehaviour">The match behaviour.</param>
|
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
|
||||||
IRequestBuilder WithCookie([NotNull] string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// WithCookie: matching based on name and IStringMatcher[].
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="matchers">The matchers.</param>
|
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
|
||||||
IRequestBuilder WithCookie([NotNull] string name, [NotNull] params IStringMatcher[] matchers);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// WithCookie: matching based on functions.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="funcs">The funcs.</param>
|
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
|
||||||
IRequestBuilder WithCookie([NotNull] params Func<IDictionary<string, string>, bool>[] funcs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,15 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The MethodRequestBuilder interface.
|
/// The MethodRequestBuilder interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMethodRequestBuilder : IHeadersAndCookiesRequestBuilder
|
public interface IMethodRequestBuilder : IHeadersRequestBuilder
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// UsingConnect: add HTTP Method matching on `CONNECT` and matchBehaviour (optional).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder UsingConnect(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// UsingDelete: add HTTP Method matching on `DELETE` and matchBehaviour (optional).
|
/// UsingDelete: add HTTP Method matching on `DELETE` and matchBehaviour (optional).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -24,7 +31,7 @@ namespace WireMock.RequestBuilders
|
|||||||
IRequestBuilder UsingGet(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
IRequestBuilder UsingGet(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add HTTP Method matching on `HEAD` and matchBehaviour (optional).
|
/// UsingHead: Add HTTP Method matching on `HEAD` and matchBehaviour (optional).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="matchBehaviour">The match behaviour.</param>
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
@@ -44,6 +51,13 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
IRequestBuilder UsingPatch(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
IRequestBuilder UsingPatch(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UsingPut: add HTTP Method matching on `OPTIONS` and matchBehaviour (optional).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder UsingOptions(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// UsingPut: add HTTP Method matching on `PUT` and matchBehaviour (optional).
|
/// UsingPut: add HTTP Method matching on `PUT` and matchBehaviour (optional).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -51,6 +65,13 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
IRequestBuilder UsingPut(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
IRequestBuilder UsingPut(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UsingTrace: add HTTP Method matching on `TRACE` and matchBehaviour (optional).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder UsingTrace(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// UsingAnyMethod: add HTTP Method matching on any method.
|
/// UsingAnyMethod: add HTTP Method matching on any method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
115
src/WireMock.Net/RequestBuilders/Request.UsingMethods.cs
Normal file
115
src/WireMock.Net/RequestBuilders/Request.UsingMethods.cs
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
|
using System.Linq;
|
||||||
|
using WireMock.Http;
|
||||||
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Matchers.Request;
|
||||||
|
using WireMock.Validation;
|
||||||
|
|
||||||
|
namespace WireMock.RequestBuilders
|
||||||
|
{
|
||||||
|
public partial class Request
|
||||||
|
{
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingConnect(MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder UsingConnect(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, HttpRequestMethods.CONNECT));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingDelete(MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder UsingDelete(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, HttpRequestMethods.DELETE));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingGet(MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder UsingGet(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, HttpRequestMethods.GET));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingHead(MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder UsingHead(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, HttpRequestMethods.HEAD));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingOptions(MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder UsingOptions(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, HttpRequestMethods.OPTIONS));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingPost(MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder UsingPost(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, HttpRequestMethods.POST));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingPatch(MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder UsingPatch(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, HttpRequestMethods.PATCH));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingPut(MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder UsingPut(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, HttpRequestMethods.PUT));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingTrace(MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder UsingTrace(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, HttpRequestMethods.TRACE));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingAnyMethod"/>
|
||||||
|
public IRequestBuilder UsingAnyMethod()
|
||||||
|
{
|
||||||
|
var matchers = _requestMatchers.Where(m => m is RequestMessageMethodMatcher).ToList();
|
||||||
|
foreach (var matcher in matchers)
|
||||||
|
{
|
||||||
|
_requestMatchers.Remove(matcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingAnyVerb"/>
|
||||||
|
public IRequestBuilder UsingAnyVerb()
|
||||||
|
{
|
||||||
|
return UsingAnyMethod();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingMethod(string[])"/>
|
||||||
|
public IRequestBuilder UsingMethod(params string[] methods)
|
||||||
|
{
|
||||||
|
return UsingMethod(MatchBehaviour.AcceptOnMatch, methods);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingVerb(string[])"/>
|
||||||
|
public IRequestBuilder UsingVerb(params string[] verbs)
|
||||||
|
{
|
||||||
|
return UsingMethod(verbs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IMethodRequestBuilder.UsingMethod(MatchBehaviour, string[])"/>
|
||||||
|
public IRequestBuilder UsingMethod(MatchBehaviour matchBehaviour, params string[] methods)
|
||||||
|
{
|
||||||
|
Check.NotNullOrEmpty(methods, nameof(methods));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, methods));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,73 +1,75 @@
|
|||||||
using System;
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
using WireMock.Matchers;
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
using WireMock.Matchers.Request;
|
using System;
|
||||||
using WireMock.Validation;
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Matchers.Request;
|
||||||
namespace WireMock.RequestBuilders
|
using WireMock.Validation;
|
||||||
{
|
|
||||||
public partial class Request
|
namespace WireMock.RequestBuilders
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(string, MatchBehaviour)"/>
|
public partial class Request
|
||||||
public IRequestBuilder WithBody(string body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
{
|
||||||
{
|
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(string, MatchBehaviour)"/>
|
||||||
_requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, body));
|
public IRequestBuilder WithBody(string body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
return this;
|
{
|
||||||
}
|
_requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, body));
|
||||||
|
return this;
|
||||||
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(byte[], MatchBehaviour)"/>
|
}
|
||||||
public IRequestBuilder WithBody(byte[] body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(byte[], MatchBehaviour)"/>
|
||||||
_requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, body));
|
public IRequestBuilder WithBody(byte[] body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
return this;
|
{
|
||||||
}
|
_requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, body));
|
||||||
|
return this;
|
||||||
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(object, MatchBehaviour)"/>
|
}
|
||||||
public IRequestBuilder WithBody(object body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(object, MatchBehaviour)"/>
|
||||||
_requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, body));
|
public IRequestBuilder WithBody(object body, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
return this;
|
{
|
||||||
}
|
_requestMatchers.Add(new RequestMessageBodyMatcher(matchBehaviour, body));
|
||||||
|
return this;
|
||||||
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(IMatcher[])"/>
|
}
|
||||||
public IRequestBuilder WithBody(IMatcher matcher)
|
|
||||||
{
|
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(IMatcher[])"/>
|
||||||
return WithBody(new[] { matcher });
|
public IRequestBuilder WithBody(IMatcher matcher)
|
||||||
}
|
{
|
||||||
|
return WithBody(new[] { matcher });
|
||||||
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(IMatcher[])"/>
|
}
|
||||||
public IRequestBuilder WithBody(IMatcher[] matchers)
|
|
||||||
{
|
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(IMatcher[])"/>
|
||||||
Check.NotNull(matchers, nameof(matchers));
|
public IRequestBuilder WithBody(IMatcher[] matchers)
|
||||||
|
{
|
||||||
_requestMatchers.Add(new RequestMessageBodyMatcher(matchers));
|
Check.NotNull(matchers, nameof(matchers));
|
||||||
return this;
|
|
||||||
}
|
_requestMatchers.Add(new RequestMessageBodyMatcher(matchers));
|
||||||
|
return this;
|
||||||
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(Func{string, bool})"/>
|
}
|
||||||
public IRequestBuilder WithBody(Func<string, bool> func)
|
|
||||||
{
|
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(Func{string, bool})"/>
|
||||||
Check.NotNull(func, nameof(func));
|
public IRequestBuilder WithBody(Func<string, bool> func)
|
||||||
|
{
|
||||||
_requestMatchers.Add(new RequestMessageBodyMatcher(func));
|
Check.NotNull(func, nameof(func));
|
||||||
return this;
|
|
||||||
}
|
_requestMatchers.Add(new RequestMessageBodyMatcher(func));
|
||||||
|
return this;
|
||||||
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(Func{byte[], bool})"/>
|
}
|
||||||
public IRequestBuilder WithBody(Func<byte[], bool> func)
|
|
||||||
{
|
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(Func{byte[], bool})"/>
|
||||||
Check.NotNull(func, nameof(func));
|
public IRequestBuilder WithBody(Func<byte[], bool> func)
|
||||||
|
{
|
||||||
_requestMatchers.Add(new RequestMessageBodyMatcher(func));
|
Check.NotNull(func, nameof(func));
|
||||||
return this;
|
|
||||||
}
|
_requestMatchers.Add(new RequestMessageBodyMatcher(func));
|
||||||
|
return this;
|
||||||
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(Func{object, bool})"/>
|
}
|
||||||
public IRequestBuilder WithBody(Func<object, bool> func)
|
|
||||||
{
|
/// <inheritdoc cref="IBodyRequestBuilder.WithBody(Func{object, bool})"/>
|
||||||
Check.NotNull(func, nameof(func));
|
public IRequestBuilder WithBody(Func<object, bool> func)
|
||||||
|
{
|
||||||
_requestMatchers.Add(new RequestMessageBodyMatcher(func));
|
Check.NotNull(func, nameof(func));
|
||||||
return this;
|
|
||||||
}
|
_requestMatchers.Add(new RequestMessageBodyMatcher(func));
|
||||||
}
|
return this;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
82
src/WireMock.Net/RequestBuilders/Request.WithCookies.cs
Normal file
82
src/WireMock.Net/RequestBuilders/Request.WithCookies.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Matchers.Request;
|
||||||
|
using WireMock.Validation;
|
||||||
|
|
||||||
|
namespace WireMock.RequestBuilders
|
||||||
|
{
|
||||||
|
public partial class Request
|
||||||
|
{
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, string pattern, MatchBehaviour matchBehaviour)
|
||||||
|
{
|
||||||
|
return WithCookie(name, pattern, true, matchBehaviour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string, bool, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNull(pattern, nameof(pattern));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, pattern, ignoreCase));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string[], MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, string[] patterns, MatchBehaviour matchBehaviour)
|
||||||
|
{
|
||||||
|
return WithCookie(name, patterns, true, matchBehaviour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string[], bool, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNull(patterns, nameof(patterns));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, ignoreCase, patterns));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, name, false, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, bool, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, bool ignoreCase, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, name, ignoreCase, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, bool ignoreCase, MatchBehaviour matchBehaviour, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, ignoreCase, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(Func{IDictionary{string, string}, bool}[])"/>
|
||||||
|
public IRequestBuilder WithCookie(params Func<IDictionary<string, string>, bool>[] funcs)
|
||||||
|
{
|
||||||
|
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(funcs));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
84
src/WireMock.Net/RequestBuilders/Request.WithHeaders.cs
Normal file
84
src/WireMock.Net/RequestBuilders/Request.WithHeaders.cs
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Matchers.Request;
|
||||||
|
using WireMock.Validation;
|
||||||
|
|
||||||
|
namespace WireMock.RequestBuilders
|
||||||
|
{
|
||||||
|
public partial class Request
|
||||||
|
{
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, string, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, string pattern, MatchBehaviour matchBehaviour)
|
||||||
|
{
|
||||||
|
return WithHeader(name, pattern, true, matchBehaviour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, string, bool, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNull(pattern, nameof(pattern));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, pattern, ignoreCase));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, string[], MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, string[] patterns, MatchBehaviour matchBehaviour)
|
||||||
|
{
|
||||||
|
return WithHeader(name, patterns, true, matchBehaviour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, string[], bool, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNull(patterns, nameof(patterns));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, ignoreCase, patterns));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(MatchBehaviour.AcceptOnMatch, name, false, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, bool, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, bool ignoreCase, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(MatchBehaviour.AcceptOnMatch, name, ignoreCase, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, bool ignoreCase, MatchBehaviour matchBehaviour, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, ignoreCase, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(Func{IDictionary{string, string[]}, bool}[])"/>
|
||||||
|
public IRequestBuilder WithHeader(params Func<IDictionary<string, string[]>, bool>[] funcs)
|
||||||
|
{
|
||||||
|
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(funcs));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using WireMock.Matchers;
|
using WireMock.Matchers;
|
||||||
using WireMock.Matchers.Request;
|
using WireMock.Matchers.Request;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -151,162 +153,5 @@ namespace WireMock.RequestBuilders
|
|||||||
_requestMatchers.Add(new RequestMessageUrlMatcher(funcs));
|
_requestMatchers.Add(new RequestMessageUrlMatcher(funcs));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingDelete(MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder UsingDelete(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "DELETE"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingGet(MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder UsingGet(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "GET"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingHead(MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder UsingHead(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "HEAD"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingPost(MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder UsingPost(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "POST"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingPatch(MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder UsingPatch(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "PATCH"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingPut(MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder UsingPut(MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, "PUT"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingAnyMethod"/>
|
|
||||||
public IRequestBuilder UsingAnyMethod()
|
|
||||||
{
|
|
||||||
var matchers = _requestMatchers.Where(m => m is RequestMessageMethodMatcher).ToList();
|
|
||||||
foreach (var matcher in matchers)
|
|
||||||
{
|
|
||||||
_requestMatchers.Remove(matcher);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingAnyVerb"/>
|
|
||||||
public IRequestBuilder UsingAnyVerb()
|
|
||||||
{
|
|
||||||
return UsingAnyMethod();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingMethod(string[])"/>
|
|
||||||
public IRequestBuilder UsingMethod(params string[] methods)
|
|
||||||
{
|
|
||||||
return UsingMethod(MatchBehaviour.AcceptOnMatch, methods);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingVerb(string[])"/>
|
|
||||||
public IRequestBuilder UsingVerb(params string[] verbs)
|
|
||||||
{
|
|
||||||
return UsingMethod(verbs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IMethodRequestBuilder.UsingMethod(MatchBehaviour, string[])"/>
|
|
||||||
public IRequestBuilder UsingMethod(MatchBehaviour matchBehaviour, params string[] methods)
|
|
||||||
{
|
|
||||||
Check.NotNullOrEmpty(methods, nameof(methods));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, methods));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string, MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder WithHeader(string name, string pattern, MatchBehaviour matchBehaviour)
|
|
||||||
{
|
|
||||||
return WithHeader(name, pattern, true, matchBehaviour);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string, bool, MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder WithHeader(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
Check.NotNull(name, nameof(name));
|
|
||||||
Check.NotNull(pattern, nameof(pattern));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, pattern, ignoreCase));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string[], MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder WithHeader(string name, string[] patterns, MatchBehaviour matchBehaviour)
|
|
||||||
{
|
|
||||||
return WithHeader(name, patterns, true, matchBehaviour);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string[], bool, MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder WithHeader(string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
Check.NotNull(name, nameof(name));
|
|
||||||
Check.NotNull(patterns, nameof(patterns));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, patterns, ignoreCase));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, IStringMatcher[])"/>
|
|
||||||
public IRequestBuilder WithHeader(string name, params IStringMatcher[] matchers)
|
|
||||||
{
|
|
||||||
Check.NotNull(name, nameof(name));
|
|
||||||
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageHeaderMatcher(name, matchers));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(Func{IDictionary{string, string[]}, bool}[])"/>
|
|
||||||
public IRequestBuilder WithHeader(params Func<IDictionary<string, string[]>, bool>[] funcs)
|
|
||||||
{
|
|
||||||
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageHeaderMatcher(funcs));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithCookie(string, string, bool, MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder WithCookie(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, pattern, ignoreCase));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithCookie(string, IStringMatcher[])"/>
|
|
||||||
public IRequestBuilder WithCookie(string name, params IStringMatcher[] matchers)
|
|
||||||
{
|
|
||||||
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageCookieMatcher(name, matchers));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithCookie(Func{IDictionary{string, string}, bool}[])"/>
|
|
||||||
public IRequestBuilder WithCookie(params Func<IDictionary<string, string>, bool>[] funcs)
|
|
||||||
{
|
|
||||||
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageCookieMatcher(funcs));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
using JetBrains.Annotations;
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
|
using JetBrains.Annotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -30,6 +32,11 @@ namespace WireMock
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string AbsoluteUrl { get; }
|
public string AbsoluteUrl { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The ProxyUrl (if a proxy is used).
|
||||||
|
/// </summary>
|
||||||
|
public string ProxyUrl { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the DateTime.
|
/// Gets the DateTime.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -110,6 +117,11 @@ namespace WireMock
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string DetectedBodyTypeFromContentType { get; }
|
public string DetectedBodyTypeFromContentType { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The detected compression from the Content-Encoding header. Convenience getter for Handlebars.
|
||||||
|
/// </summary>
|
||||||
|
public string DetectedCompression { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Host
|
/// Gets the Host
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -168,6 +180,7 @@ namespace WireMock
|
|||||||
BodyAsBytes = BodyData?.BodyAsBytes;
|
BodyAsBytes = BodyData?.BodyAsBytes;
|
||||||
DetectedBodyType = BodyData?.DetectedBodyType.ToString();
|
DetectedBodyType = BodyData?.DetectedBodyType.ToString();
|
||||||
DetectedBodyTypeFromContentType = BodyData?.DetectedBodyTypeFromContentType.ToString();
|
DetectedBodyTypeFromContentType = BodyData?.DetectedBodyTypeFromContentType.ToString();
|
||||||
|
DetectedCompression = BodyData?.DetectedCompression;
|
||||||
|
|
||||||
Headers = headers?.ToDictionary(header => header.Key, header => new WireMockList<string>(header.Value));
|
Headers = headers?.ToDictionary(header => header.Key, header => new WireMockList<string>(header.Value));
|
||||||
Cookies = cookies;
|
Cookies = cookies;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
|
using WireMock.Settings;
|
||||||
|
|
||||||
namespace WireMock.ResponseBuilders
|
namespace WireMock.ResponseBuilders
|
||||||
{
|
{
|
||||||
@@ -9,6 +10,7 @@ namespace WireMock.ResponseBuilders
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The with status code.
|
/// The with status code.
|
||||||
|
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="IWireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code">The code.</param>
|
/// <param name="code">The code.</param>
|
||||||
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
|
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
|
||||||
@@ -16,6 +18,7 @@ namespace WireMock.ResponseBuilders
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The with status code.
|
/// The with status code.
|
||||||
|
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="IWireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code">The code.</param>
|
/// <param name="code">The code.</param>
|
||||||
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
|
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
|
||||||
@@ -23,6 +26,7 @@ namespace WireMock.ResponseBuilders
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The with status code.
|
/// The with status code.
|
||||||
|
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="IWireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code">The code.</param>
|
/// <param name="code">The code.</param>
|
||||||
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
|
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
using JetBrains.Annotations;
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
using Newtonsoft.Json;
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using WireMock.Http;
|
using WireMock.Http;
|
||||||
using WireMock.ResponseProviders;
|
using WireMock.ResponseProviders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
@@ -60,7 +60,7 @@ namespace WireMock.ResponseBuilders
|
|||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static IResponseBuilder Create([CanBeNull] ResponseMessage responseMessage = null)
|
public static IResponseBuilder Create([CanBeNull] ResponseMessage responseMessage = null)
|
||||||
{
|
{
|
||||||
var message = responseMessage ?? new ResponseMessage { StatusCode = (int)HttpStatusCode.OK };
|
var message = responseMessage ?? new ResponseMessage(); // { StatusCode = (int)HttpStatusCode.OK };
|
||||||
return new Response(message);
|
return new Response(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,47 +341,64 @@ namespace WireMock.ResponseBuilders
|
|||||||
await Task.Delay(Delay.Value);
|
await Task.Delay(Delay.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Callback != null)
|
if (ProxyUrl != null && _httpClientForProxy != null)
|
||||||
{
|
{
|
||||||
var callbackResponseMessage = Callback(requestMessage);
|
string RemoveFirstOccurrence(string source, string find)
|
||||||
|
{
|
||||||
|
int place = source.IndexOf(find, StringComparison.OrdinalIgnoreCase);
|
||||||
|
return place >= 0 ? source.Remove(place, find.Length) : source;
|
||||||
|
}
|
||||||
|
|
||||||
|
var requestUri = new Uri(requestMessage.Url);
|
||||||
|
|
||||||
|
// Build the proxy url and skip duplicates
|
||||||
|
string extra = RemoveFirstOccurrence(requestUri.LocalPath.TrimEnd('/'), new Uri(ProxyUrl).LocalPath.TrimEnd('/'));
|
||||||
|
requestMessage.ProxyUrl = ProxyUrl + extra + requestUri.Query;
|
||||||
|
|
||||||
|
return await HttpClientHelper.SendAsync(
|
||||||
|
_httpClientForProxy,
|
||||||
|
requestMessage,
|
||||||
|
requestMessage.ProxyUrl,
|
||||||
|
!settings.DisableJsonBodyParsing.GetValueOrDefault(false),
|
||||||
|
!settings.DisableRequestBodyDecompressing.GetValueOrDefault(false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResponseMessage responseMessage;
|
||||||
|
if (Callback == null)
|
||||||
|
{
|
||||||
|
responseMessage = ResponseMessage;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
responseMessage = Callback(requestMessage);
|
||||||
|
|
||||||
if (!WithCallbackUsed)
|
if (!WithCallbackUsed)
|
||||||
{
|
{
|
||||||
// Copy StatusCode from ResponseMessage
|
// Copy StatusCode from ResponseMessage
|
||||||
callbackResponseMessage.StatusCode = ResponseMessage.StatusCode;
|
responseMessage.StatusCode = ResponseMessage.StatusCode;
|
||||||
|
|
||||||
// Copy Headers from ResponseMessage (if defined)
|
// Copy Headers from ResponseMessage (if defined)
|
||||||
if (ResponseMessage.Headers != null)
|
if (ResponseMessage.Headers != null)
|
||||||
{
|
{
|
||||||
callbackResponseMessage.Headers = ResponseMessage.Headers;
|
responseMessage.Headers = ResponseMessage.Headers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return callbackResponseMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ProxyUrl != null && _httpClientForProxy != null)
|
|
||||||
{
|
|
||||||
var requestUri = new Uri(requestMessage.Url);
|
|
||||||
var proxyUri = new Uri(ProxyUrl);
|
|
||||||
var proxyUriWithRequestPathAndQuery = new Uri(proxyUri, requestUri.PathAndQuery);
|
|
||||||
|
|
||||||
return await HttpClientHelper.SendAsync(_httpClientForProxy, requestMessage, proxyUriWithRequestPathAndQuery.AbsoluteUri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UseTransformer)
|
if (UseTransformer)
|
||||||
{
|
{
|
||||||
var factory = new HandlebarsContextFactory(settings.FileSystemHandler, settings.HandlebarsRegistrationCallback);
|
var factory = new HandlebarsContextFactory(settings.FileSystemHandler, settings.HandlebarsRegistrationCallback);
|
||||||
var responseMessageTransformer = new ResponseMessageTransformer(factory);
|
var responseMessageTransformer = new ResponseMessageTransformer(factory);
|
||||||
return responseMessageTransformer.Transform(requestMessage, ResponseMessage, UseTransformerForBodyAsFile);
|
return responseMessageTransformer.Transform(requestMessage, responseMessage, UseTransformerForBodyAsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UseTransformer && ResponseMessage.BodyData?.BodyAsFileIsCached == true)
|
if (!UseTransformer && ResponseMessage.BodyData?.BodyAsFileIsCached == true)
|
||||||
{
|
{
|
||||||
ResponseMessage.BodyData.BodyAsBytes = settings.FileSystemHandler.ReadResponseBodyAsFile(ResponseMessage.BodyData.BodyAsFile);
|
ResponseMessage.BodyData.BodyAsBytes = settings.FileSystemHandler.ReadResponseBodyAsFile(responseMessage.BodyData.BodyAsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseMessage;
|
return responseMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Types;
|
using WireMock.Types;
|
||||||
@@ -20,7 +22,7 @@ namespace WireMock
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the status code.
|
/// Gets or sets the status code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object StatusCode { get; set; } = 200;
|
public object StatusCode { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the body.
|
/// Gets or sets the body.
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using JetBrains.Annotations;
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
|
using JetBrains.Annotations;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
using WireMock.Admin.Mappings;
|
using WireMock.Admin.Mappings;
|
||||||
using WireMock.Admin.Requests;
|
using WireMock.Admin.Requests;
|
||||||
using WireMock.Logging;
|
using WireMock.Logging;
|
||||||
using WireMock.Types;
|
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Util;
|
using WireMock.Types;
|
||||||
|
|
||||||
namespace WireMock.Serialization
|
namespace WireMock.Serialization
|
||||||
{
|
{
|
||||||
@@ -20,6 +19,7 @@ namespace WireMock.Serialization
|
|||||||
AbsolutePath = logEntry.RequestMessage.AbsolutePath,
|
AbsolutePath = logEntry.RequestMessage.AbsolutePath,
|
||||||
Url = logEntry.RequestMessage.Url,
|
Url = logEntry.RequestMessage.Url,
|
||||||
AbsoluteUrl = logEntry.RequestMessage.AbsoluteUrl,
|
AbsoluteUrl = logEntry.RequestMessage.AbsoluteUrl,
|
||||||
|
ProxyUrl = logEntry.RequestMessage.ProxyUrl,
|
||||||
Query = logEntry.RequestMessage.Query,
|
Query = logEntry.RequestMessage.Query,
|
||||||
Method = logEntry.RequestMessage.Method,
|
Method = logEntry.RequestMessage.Method,
|
||||||
Headers = logEntry.RequestMessage.Headers,
|
Headers = logEntry.RequestMessage.Headers,
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ using WireMock.Matchers.Request;
|
|||||||
using WireMock.RequestBuilders;
|
using WireMock.RequestBuilders;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
using WireMock.Util;
|
|
||||||
using WireMock.Validation;
|
|
||||||
using WireMock.Types;
|
using WireMock.Types;
|
||||||
|
using WireMock.Validation;
|
||||||
|
|
||||||
namespace WireMock.Serialization
|
namespace WireMock.Serialization
|
||||||
{
|
{
|
||||||
@@ -27,9 +26,9 @@ namespace WireMock.Serialization
|
|||||||
var request = (Request)mapping.RequestMatcher;
|
var request = (Request)mapping.RequestMatcher;
|
||||||
var response = (Response)mapping.Provider;
|
var response = (Response)mapping.Provider;
|
||||||
|
|
||||||
var clientIPMatchers = request.GetRequestMessageMatchers<RequestMessageClientIPMatcher>();
|
var clientIPMatchers = request.GetRequestMessageMatchers<RequestMessageClientIPMatcher>().Where(m => m.Matchers != null).SelectMany(m => m.Matchers).ToList();
|
||||||
var pathMatchers = request.GetRequestMessageMatchers<RequestMessagePathMatcher>();
|
var pathMatchers = request.GetRequestMessageMatchers<RequestMessagePathMatcher>().Where(m => m.Matchers != null).SelectMany(m => m.Matchers).ToList();
|
||||||
var urlMatchers = request.GetRequestMessageMatchers<RequestMessageUrlMatcher>();
|
var urlMatchers = request.GetRequestMessageMatchers<RequestMessageUrlMatcher>().Where(m => m.Matchers != null).SelectMany(m => m.Matchers).ToList();
|
||||||
var headerMatchers = request.GetRequestMessageMatchers<RequestMessageHeaderMatcher>();
|
var headerMatchers = request.GetRequestMessageMatchers<RequestMessageHeaderMatcher>();
|
||||||
var cookieMatchers = request.GetRequestMessageMatchers<RequestMessageCookieMatcher>();
|
var cookieMatchers = request.GetRequestMessageMatchers<RequestMessageCookieMatcher>();
|
||||||
var paramsMatchers = request.GetRequestMessageMatchers<RequestMessageParamMatcher>();
|
var paramsMatchers = request.GetRequestMessageMatchers<RequestMessageParamMatcher>();
|
||||||
@@ -46,36 +45,36 @@ namespace WireMock.Serialization
|
|||||||
SetStateTo = mapping.NextState,
|
SetStateTo = mapping.NextState,
|
||||||
Request = new RequestModel
|
Request = new RequestModel
|
||||||
{
|
{
|
||||||
ClientIP = clientIPMatchers != null && clientIPMatchers.Any() ? new ClientIPModel
|
ClientIP = clientIPMatchers.Any() ? new ClientIPModel
|
||||||
{
|
{
|
||||||
Matchers = _mapper.Map(clientIPMatchers.Where(m => m.Matchers != null).SelectMany(m => m.Matchers))
|
Matchers = _mapper.Map(clientIPMatchers)
|
||||||
} : null,
|
} : null,
|
||||||
|
|
||||||
Path = pathMatchers != null && pathMatchers.Any() ? new PathModel
|
Path = pathMatchers.Any() ? new PathModel
|
||||||
{
|
{
|
||||||
Matchers = _mapper.Map(pathMatchers.Where(m => m.Matchers != null).SelectMany(m => m.Matchers))
|
Matchers = _mapper.Map(pathMatchers)
|
||||||
} : null,
|
} : null,
|
||||||
|
|
||||||
Url = urlMatchers != null && urlMatchers.Any() ? new UrlModel
|
Url = urlMatchers.Any() ? new UrlModel
|
||||||
{
|
{
|
||||||
Matchers = _mapper.Map(urlMatchers.Where(m => m.Matchers != null).SelectMany(m => m.Matchers))
|
Matchers = _mapper.Map(urlMatchers)
|
||||||
} : null,
|
} : null,
|
||||||
|
|
||||||
Methods = methodMatcher?.Methods,
|
Methods = methodMatcher?.Methods,
|
||||||
|
|
||||||
Headers = headerMatchers != null && headerMatchers.Any() ? headerMatchers.Select(hm => new HeaderModel
|
Headers = headerMatchers.Any() ? headerMatchers.Select(hm => new HeaderModel
|
||||||
{
|
{
|
||||||
Name = hm.Name,
|
Name = hm.Name,
|
||||||
Matchers = _mapper.Map(hm.Matchers)
|
Matchers = _mapper.Map(hm.Matchers)
|
||||||
}).ToList() : null,
|
}).ToList() : null,
|
||||||
|
|
||||||
Cookies = cookieMatchers != null && cookieMatchers.Any() ? cookieMatchers.Select(cm => new CookieModel
|
Cookies = cookieMatchers.Any() ? cookieMatchers.Select(cm => new CookieModel
|
||||||
{
|
{
|
||||||
Name = cm.Name,
|
Name = cm.Name,
|
||||||
Matchers = _mapper.Map(cm.Matchers)
|
Matchers = _mapper.Map(cm.Matchers)
|
||||||
}).ToList() : null,
|
}).ToList() : null,
|
||||||
|
|
||||||
Params = paramsMatchers != null && paramsMatchers.Any() ? paramsMatchers.Select(pm => new ParamModel
|
Params = paramsMatchers.Any() ? paramsMatchers.Select(pm => new ParamModel
|
||||||
{
|
{
|
||||||
Name = pm.Key,
|
Name = pm.Key,
|
||||||
IgnoreCase = pm.IgnoreCase == true ? true : (bool?)null,
|
IgnoreCase = pm.IgnoreCase == true ? true : (bool?)null,
|
||||||
@@ -125,11 +124,17 @@ namespace WireMock.Serialization
|
|||||||
mappingModel.Response.WebProxy = null;
|
mappingModel.Response.WebProxy = null;
|
||||||
mappingModel.Response.BodyDestination = response.ResponseMessage.BodyDestination;
|
mappingModel.Response.BodyDestination = response.ResponseMessage.BodyDestination;
|
||||||
mappingModel.Response.StatusCode = response.ResponseMessage.StatusCode;
|
mappingModel.Response.StatusCode = response.ResponseMessage.StatusCode;
|
||||||
mappingModel.Response.Headers = MapHeaders(response.ResponseMessage.Headers);
|
|
||||||
|
if (response.ResponseMessage.Headers != null && response.ResponseMessage.Headers.Count > 0)
|
||||||
|
{
|
||||||
|
mappingModel.Response.Headers = MapHeaders(response.ResponseMessage.Headers);
|
||||||
|
}
|
||||||
|
|
||||||
if (response.UseTransformer)
|
if (response.UseTransformer)
|
||||||
{
|
{
|
||||||
mappingModel.Response.UseTransformer = response.UseTransformer;
|
mappingModel.Response.UseTransformer = response.UseTransformer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.UseTransformerForBodyAsFile)
|
if (response.UseTransformerForBodyAsFile)
|
||||||
{
|
{
|
||||||
mappingModel.Response.UseTransformerForBodyAsFile = response.UseTransformerForBodyAsFile;
|
mappingModel.Response.UseTransformerForBodyAsFile = response.UseTransformerForBodyAsFile;
|
||||||
@@ -198,12 +203,6 @@ namespace WireMock.Serialization
|
|||||||
private static IDictionary<string, object> MapHeaders(IDictionary<string, WireMockList<string>> dictionary)
|
private static IDictionary<string, object> MapHeaders(IDictionary<string, WireMockList<string>> dictionary)
|
||||||
{
|
{
|
||||||
var newDictionary = new Dictionary<string, object>();
|
var newDictionary = new Dictionary<string, object>();
|
||||||
|
|
||||||
if (dictionary == null || dictionary.Count == 0)
|
|
||||||
{
|
|
||||||
return newDictionary;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var entry in dictionary)
|
foreach (var entry in dictionary)
|
||||||
{
|
{
|
||||||
object value = entry.Value.Count == 1 ? (object)entry.Value.ToString() : entry.Value;
|
object value = entry.Value.Count == 1 ? (object)entry.Value.ToString() : entry.Value;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
|
using System;
|
||||||
using WireMock.Matchers.Request;
|
using WireMock.Matchers.Request;
|
||||||
using WireMock.ResponseProviders;
|
using WireMock.ResponseProviders;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -274,7 +275,13 @@ namespace WireMock.Server
|
|||||||
var proxyUri = new Uri(settings.ProxyAndRecordSettings.Url);
|
var proxyUri = new Uri(settings.ProxyAndRecordSettings.Url);
|
||||||
var proxyUriWithRequestPathAndQuery = new Uri(proxyUri, requestUri.PathAndQuery);
|
var proxyUriWithRequestPathAndQuery = new Uri(proxyUri, requestUri.PathAndQuery);
|
||||||
|
|
||||||
var responseMessage = await HttpClientHelper.SendAsync(_httpClientForProxy, requestMessage, proxyUriWithRequestPathAndQuery.AbsoluteUri);
|
var responseMessage = await HttpClientHelper.SendAsync(
|
||||||
|
_httpClientForProxy,
|
||||||
|
requestMessage,
|
||||||
|
proxyUriWithRequestPathAndQuery.AbsoluteUri,
|
||||||
|
!settings.DisableJsonBodyParsing.GetValueOrDefault(false),
|
||||||
|
!settings.DisableRequestBodyDecompressing.GetValueOrDefault(false)
|
||||||
|
);
|
||||||
|
|
||||||
if (HttpStatusRangeParser.IsMatch(settings.ProxyAndRecordSettings.SaveMappingForStatusCodePattern, responseMessage.StatusCode) &&
|
if (HttpStatusRangeParser.IsMatch(settings.ProxyAndRecordSettings.SaveMappingForStatusCodePattern, responseMessage.StatusCode) &&
|
||||||
(settings.ProxyAndRecordSettings.SaveMapping || settings.ProxyAndRecordSettings.SaveMappingToFile))
|
(settings.ProxyAndRecordSettings.SaveMapping || settings.ProxyAndRecordSettings.SaveMappingToFile))
|
||||||
@@ -554,11 +561,63 @@ namespace WireMock.Server
|
|||||||
|
|
||||||
private ResponseMessage MappingsDelete(RequestMessage requestMessage)
|
private ResponseMessage MappingsDelete(RequestMessage requestMessage)
|
||||||
{
|
{
|
||||||
ResetMappings();
|
if (!string.IsNullOrEmpty(requestMessage.Body))
|
||||||
|
{
|
||||||
|
var deletedGuids = MappingsDeleteMappingFromBody(requestMessage);
|
||||||
|
if (deletedGuids != null)
|
||||||
|
{
|
||||||
|
return ResponseMessageBuilder.Create($"Mappings deleted. Affected GUIDs: [{string.Join(", ", deletedGuids.ToArray())}]");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// return bad request
|
||||||
|
return ResponseMessageBuilder.Create("Poorly formed mapping JSON.", 400);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ResetMappings();
|
||||||
|
|
||||||
ResetScenarios();
|
ResetScenarios();
|
||||||
|
|
||||||
return ResponseMessageBuilder.Create("Mappings deleted");
|
return ResponseMessageBuilder.Create("Mappings deleted");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<Guid> MappingsDeleteMappingFromBody(RequestMessage requestMessage)
|
||||||
|
{
|
||||||
|
var deletedGuids = new List<Guid>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var mappingModels = DeserializeRequestMessageToArray<MappingModel>(requestMessage);
|
||||||
|
foreach (var mappingModel in mappingModels)
|
||||||
|
{
|
||||||
|
if (mappingModel.Guid.HasValue)
|
||||||
|
{
|
||||||
|
if (DeleteMapping(mappingModel.Guid.Value))
|
||||||
|
{
|
||||||
|
deletedGuids.Add(mappingModel.Guid.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_settings.Logger.Debug($"Did not find/delete mapping with GUID: {mappingModel.Guid.Value}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ArgumentException a)
|
||||||
|
{
|
||||||
|
_settings.Logger.Error("ArgumentException: {0}", a);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_settings.Logger.Error("Exception: {0}", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return deletedGuids;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResponseMessage MappingsReset(RequestMessage requestMessage)
|
private ResponseMessage MappingsReset(RequestMessage requestMessage)
|
||||||
@@ -744,7 +803,12 @@ namespace WireMock.Server
|
|||||||
{
|
{
|
||||||
foreach (var headerModel in requestModel.Headers.Where(h => h.Matchers != null))
|
foreach (var headerModel in requestModel.Headers.Where(h => h.Matchers != null))
|
||||||
{
|
{
|
||||||
requestBuilder = requestBuilder.WithHeader(headerModel.Name, headerModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray());
|
requestBuilder = requestBuilder.WithHeader(
|
||||||
|
headerModel.Name,
|
||||||
|
headerModel.IgnoreCase == true,
|
||||||
|
headerModel.RejectOnMatch == true ? MatchBehaviour.RejectOnMatch : MatchBehaviour.AcceptOnMatch,
|
||||||
|
headerModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,7 +816,11 @@ namespace WireMock.Server
|
|||||||
{
|
{
|
||||||
foreach (var cookieModel in requestModel.Cookies.Where(c => c.Matchers != null))
|
foreach (var cookieModel in requestModel.Cookies.Where(c => c.Matchers != null))
|
||||||
{
|
{
|
||||||
requestBuilder = requestBuilder.WithCookie(cookieModel.Name, cookieModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray());
|
requestBuilder = requestBuilder.WithCookie(
|
||||||
|
cookieModel.Name,
|
||||||
|
cookieModel.IgnoreCase == true,
|
||||||
|
cookieModel.RejectOnMatch == true ? MatchBehaviour.RejectOnMatch : MatchBehaviour.AcceptOnMatch,
|
||||||
|
cookieModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -808,12 +876,13 @@ namespace WireMock.Server
|
|||||||
return responseBuilder.WithProxy(proxyAndRecordSettings);
|
return responseBuilder.WithProxy(proxyAndRecordSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseModel.StatusCode is string)
|
if (responseModel.StatusCode is string statusCodeAsString)
|
||||||
{
|
{
|
||||||
responseBuilder = responseBuilder.WithStatusCode((string) responseModel.StatusCode);
|
responseBuilder = responseBuilder.WithStatusCode(statusCodeAsString);
|
||||||
}
|
}
|
||||||
else
|
else if (responseModel.StatusCode != null)
|
||||||
{
|
{
|
||||||
|
// Convert to Int32 because Newtonsoft deserializes an 'object' with a number value to a long.
|
||||||
responseBuilder = responseBuilder.WithStatusCode(Convert.ToInt32(responseModel.StatusCode));
|
responseBuilder = responseBuilder.WithStatusCode(Convert.ToInt32(responseModel.StatusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,7 +940,7 @@ namespace WireMock.Server
|
|||||||
DetectedBodyType = BodyType.String,
|
DetectedBodyType = BodyType.String,
|
||||||
BodyAsString = JsonConvert.SerializeObject(result, keepNullValues ? _settingsIncludeNullValues : _jsonSerializerSettings)
|
BodyAsString = JsonConvert.SerializeObject(result, keepNullValues ? _settingsIncludeNullValues : _jsonSerializerSettings)
|
||||||
},
|
},
|
||||||
StatusCode = 200,
|
StatusCode = (int)HttpStatusCode.OK,
|
||||||
Headers = new Dictionary<string, WireMockList<string>> { { HttpKnownHeaderNames.ContentType, new WireMockList<string>(ContentTypeJson) } }
|
Headers = new Dictionary<string, WireMockList<string>> { { HttpKnownHeaderNames.ContentType, new WireMockList<string>(ContentTypeJson) } }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
using JetBrains.Annotations;
|
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
|
||||||
using Newtonsoft.Json;
|
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using WireMock.Admin.Mappings;
|
using WireMock.Admin.Mappings;
|
||||||
using WireMock.Exceptions;
|
using WireMock.Exceptions;
|
||||||
using WireMock.Handlers;
|
using WireMock.Handlers;
|
||||||
@@ -17,7 +19,6 @@ using WireMock.RequestBuilders;
|
|||||||
using WireMock.ResponseProviders;
|
using WireMock.ResponseProviders;
|
||||||
using WireMock.Serialization;
|
using WireMock.Serialization;
|
||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
using WireMock.Util;
|
|
||||||
using WireMock.Validation;
|
using WireMock.Validation;
|
||||||
|
|
||||||
namespace WireMock.Server
|
namespace WireMock.Server
|
||||||
@@ -202,31 +203,37 @@ namespace WireMock.Server
|
|||||||
_settings.Logger.Info("WireMock.Net by Stef Heyenrath (https://github.com/WireMock-Net/WireMock.Net)");
|
_settings.Logger.Info("WireMock.Net by Stef Heyenrath (https://github.com/WireMock-Net/WireMock.Net)");
|
||||||
_settings.Logger.Debug("WireMock.Net server settings {0}", JsonConvert.SerializeObject(settings, Formatting.Indented));
|
_settings.Logger.Debug("WireMock.Net server settings {0}", JsonConvert.SerializeObject(settings, Formatting.Indented));
|
||||||
|
|
||||||
|
HostUrlOptions urlOptions;
|
||||||
if (settings.Urls != null)
|
if (settings.Urls != null)
|
||||||
{
|
{
|
||||||
Urls = settings.Urls.ToArray();
|
urlOptions = new HostUrlOptions
|
||||||
|
{
|
||||||
|
Urls = settings.Urls
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int port = settings.Port > 0 ? settings.Port.Value : PortUtils.FindFreeTcpPort();
|
urlOptions = new HostUrlOptions
|
||||||
Urls = new[] { $"{(settings.UseSSL == true ? "https" : "http")}://localhost:{port}" };
|
{
|
||||||
|
UseSSL = settings.UseSSL == true,
|
||||||
|
Port = settings.Port
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_options.FileSystemHandler = _settings.FileSystemHandler;
|
_options.FileSystemHandler = _settings.FileSystemHandler;
|
||||||
_options.PreWireMockMiddlewareInit = settings.PreWireMockMiddlewareInit;
|
_options.PreWireMockMiddlewareInit = _settings.PreWireMockMiddlewareInit;
|
||||||
_options.PostWireMockMiddlewareInit = settings.PostWireMockMiddlewareInit;
|
_options.PostWireMockMiddlewareInit = _settings.PostWireMockMiddlewareInit;
|
||||||
_options.Logger = _settings.Logger;
|
_options.Logger = _settings.Logger;
|
||||||
|
_options.DisableJsonBodyParsing = _settings.DisableJsonBodyParsing;
|
||||||
|
|
||||||
_matcherMapper = new MatcherMapper(_settings);
|
_matcherMapper = new MatcherMapper(_settings);
|
||||||
_mappingConverter = new MappingConverter(_matcherMapper);
|
_mappingConverter = new MappingConverter(_matcherMapper);
|
||||||
|
|
||||||
#if USE_ASPNETCORE
|
#if USE_ASPNETCORE
|
||||||
_httpServer = new AspNetCoreSelfHost(_options, Urls);
|
_httpServer = new AspNetCoreSelfHost(_options, urlOptions);
|
||||||
#else
|
#else
|
||||||
_httpServer = new OwinSelfHost(_options, Urls);
|
_httpServer = new OwinSelfHost(_options, urlOptions);
|
||||||
#endif
|
#endif
|
||||||
Ports = _httpServer.Ports;
|
|
||||||
|
|
||||||
var startTask = _httpServer.StartAsync();
|
var startTask = _httpServer.StartAsync();
|
||||||
|
|
||||||
using (var ctsStartTimeout = new CancellationTokenSource(settings.StartTimeout))
|
using (var ctsStartTimeout = new CancellationTokenSource(settings.StartTimeout))
|
||||||
@@ -253,12 +260,21 @@ namespace WireMock.Server
|
|||||||
|
|
||||||
ctsStartTimeout.Token.WaitHandle.WaitOne(ServerStartDelayInMs);
|
ctsStartTimeout.Token.WaitHandle.WaitOne(ServerStartDelayInMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Urls = _httpServer.Urls.ToArray();
|
||||||
|
Ports = _httpServer.Ports;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.AllowBodyForAllHttpMethods == true)
|
if (settings.AllowBodyForAllHttpMethods == true)
|
||||||
{
|
{
|
||||||
_options.AllowBodyForAllHttpMethods = _settings.AllowBodyForAllHttpMethods;
|
_options.AllowBodyForAllHttpMethods = _settings.AllowBodyForAllHttpMethods;
|
||||||
_settings.Logger.Info("AllowBodyForAllHttpMethods is set to {0}", _settings.AllowBodyForAllHttpMethods == true);
|
_settings.Logger.Info("AllowBodyForAllHttpMethods is set to True");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.AllowOnlyDefinedHttpStatusCodeInResponse == true)
|
||||||
|
{
|
||||||
|
_options.AllowOnlyDefinedHttpStatusCodeInResponse = _settings.AllowOnlyDefinedHttpStatusCodeInResponse;
|
||||||
|
_settings.Logger.Info("AllowOnlyDefinedHttpStatusCodeInResponse is set to True");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.AllowPartialMapping == true)
|
if (settings.AllowPartialMapping == true)
|
||||||
|
|||||||
@@ -1,141 +1,161 @@
|
|||||||
using System;
|
using System;
|
||||||
using HandlebarsDotNet;
|
using HandlebarsDotNet;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using WireMock.Handlers;
|
using WireMock.Handlers;
|
||||||
using WireMock.Logging;
|
using WireMock.Logging;
|
||||||
|
|
||||||
namespace WireMock.Settings
|
namespace WireMock.Settings
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IWireMockServerSettings
|
/// IWireMockServerSettings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IWireMockServerSettings
|
public interface IWireMockServerSettings
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the port.
|
/// Gets or sets the port.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
int? Port { get; set; }
|
int? Port { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the use SSL.
|
/// Gets or sets the use SSL.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
bool? UseSSL { get; set; }
|
bool? UseSSL { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether to start admin interface.
|
/// Gets or sets whether to start admin interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
bool? StartAdminInterface { get; set; }
|
bool? StartAdminInterface { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets if the static mappings should be read at startup.
|
/// Gets or sets if the static mappings should be read at startup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
bool? ReadStaticMappings { get; set; }
|
bool? ReadStaticMappings { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Watch the static mapping files + folder for changes when running.
|
/// Watch the static mapping files + folder for changes when running.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
bool? WatchStaticMappings { get; set; }
|
bool? WatchStaticMappings { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A value indicating whether subdirectories within the static mappings path should be monitored.
|
/// A value indicating whether subdirectories within the static mappings path should be monitored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
bool? WatchStaticMappingsInSubdirectories { get; set; }
|
bool? WatchStaticMappingsInSubdirectories { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets if the proxy and record settings.
|
/// Gets or sets if the proxy and record settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
IProxyAndRecordSettings ProxyAndRecordSettings { get; set; }
|
IProxyAndRecordSettings ProxyAndRecordSettings { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the urls.
|
/// Gets or sets the urls.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
string[] Urls { get; set; }
|
string[] Urls { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// StartTimeout
|
/// StartTimeout
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
int StartTimeout { get; set; }
|
int StartTimeout { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allow Partial Mapping (default set to false).
|
/// Allow Partial Mapping (default set to false).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
bool? AllowPartialMapping { get; set; }
|
bool? AllowPartialMapping { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The username needed for __admin access.
|
/// The username needed for __admin access.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
string AdminUsername { get; set; }
|
string AdminUsername { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The password needed for __admin access.
|
/// The password needed for __admin access.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
string AdminPassword { get; set; }
|
string AdminPassword { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The RequestLog expiration in hours (optional).
|
/// The RequestLog expiration in hours (optional).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
int? RequestLogExpirationDuration { get; set; }
|
int? RequestLogExpirationDuration { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The MaxRequestLog count (optional).
|
/// The MaxRequestLog count (optional).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
int? MaxRequestLogCount { get; set; }
|
int? MaxRequestLogCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Action which is called (with the IAppBuilder or IApplicationBuilder) before the internal WireMockMiddleware is initialized. [Optional]
|
/// Action which is called (with the IAppBuilder or IApplicationBuilder) before the internal WireMockMiddleware is initialized. [Optional]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
Action<object> PreWireMockMiddlewareInit { get; set; }
|
Action<object> PreWireMockMiddlewareInit { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Action which is called (with the IAppBuilder or IApplicationBuilder) after the internal WireMockMiddleware is initialized. [Optional]
|
/// Action which is called (with the IAppBuilder or IApplicationBuilder) after the internal WireMockMiddleware is initialized. [Optional]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
Action<object> PostWireMockMiddlewareInit { get; set; }
|
Action<object> PostWireMockMiddlewareInit { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The IWireMockLogger which logs Debug, Info, Warning or Error
|
/// The IWireMockLogger which logs Debug, Info, Warning or Error
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
IWireMockLogger Logger { get; set; }
|
IWireMockLogger Logger { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler to interact with the file system to read and write static mapping files.
|
/// Handler to interact with the file system to read and write static mapping files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
IFileSystemHandler FileSystemHandler { get; set; }
|
IFileSystemHandler FileSystemHandler { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Action which can be used to add additional Handlebars registrations. [Optional]
|
/// Action which can be used to add additional Handlebars registrations. [Optional]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
Action<IHandlebars, IFileSystemHandler> HandlebarsRegistrationCallback { get; set; }
|
Action<IHandlebars, IFileSystemHandler> HandlebarsRegistrationCallback { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allow the usage of CSharpCodeMatcher (default is not allowed).
|
/// Allow the usage of CSharpCodeMatcher (default is not allowed).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
bool? AllowCSharpCodeMatcher { get; set; }
|
bool? AllowCSharpCodeMatcher { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allow a Body for all HTTP Methods. (default set to false).
|
/// Allow a Body for all HTTP Methods. (default set to false).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
bool? AllowBodyForAllHttpMethods { get; set; }
|
bool? AllowBodyForAllHttpMethods { get; set; }
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allow only a HttpStatus Code in the response which is defined. (default set to false).
|
||||||
|
/// - false : also null, 0, empty or invalid HttpStatus codes are allowed.
|
||||||
|
/// - true : only codes defined in <see cref="System.Net.HttpStatusCode"/> are allowed.
|
||||||
|
/// </summary>
|
||||||
|
/// [PublicAPI]
|
||||||
|
bool? AllowOnlyDefinedHttpStatusCodeInResponse { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set to true to disable Json deserialization when processing requests. (default set to false).
|
||||||
|
/// </summary>
|
||||||
|
[PublicAPI]
|
||||||
|
bool? DisableJsonBodyParsing { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disable support for GZip and Deflate request body decompression. (default set to false).
|
||||||
|
/// </summary>
|
||||||
|
[PublicAPI]
|
||||||
|
bool? DisableRequestBodyDecompressing { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -101,5 +101,17 @@ namespace WireMock.Settings
|
|||||||
/// <inheritdoc cref="IWireMockServerSettings.AllowBodyForAllHttpMethods"/>
|
/// <inheritdoc cref="IWireMockServerSettings.AllowBodyForAllHttpMethods"/>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public bool? AllowBodyForAllHttpMethods { get; set; }
|
public bool? AllowBodyForAllHttpMethods { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IWireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>
|
||||||
|
[PublicAPI]
|
||||||
|
public bool? AllowOnlyDefinedHttpStatusCodeInResponse { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IWireMockServerSettings.DisableJsonBodyParsing"/>
|
||||||
|
[PublicAPI]
|
||||||
|
public bool? DisableJsonBodyParsing { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IWireMockServerSettings.DisableRequestBodyDecompressing"/>
|
||||||
|
[PublicAPI]
|
||||||
|
public bool? DisableRequestBodyDecompressing { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,9 @@ namespace WireMock.Settings
|
|||||||
MaxRequestLogCount = parser.GetIntValue("MaxRequestLogCount"),
|
MaxRequestLogCount = parser.GetIntValue("MaxRequestLogCount"),
|
||||||
RequestLogExpirationDuration = parser.GetIntValue("RequestLogExpirationDuration"),
|
RequestLogExpirationDuration = parser.GetIntValue("RequestLogExpirationDuration"),
|
||||||
AllowCSharpCodeMatcher = parser.GetBoolValue("AllowCSharpCodeMatcher"),
|
AllowCSharpCodeMatcher = parser.GetBoolValue("AllowCSharpCodeMatcher"),
|
||||||
AllowBodyForAllHttpMethods = parser.GetBoolValue("AllowBodyForAllHttpMethods")
|
AllowBodyForAllHttpMethods = parser.GetBoolValue("AllowBodyForAllHttpMethods"),
|
||||||
|
AllowOnlyDefinedHttpStatusCodeInResponse = parser.GetBoolValue("AllowOnlyDefinedHttpStatusCodeInResponse"),
|
||||||
|
DisableJsonBodyParsing = parser.GetBoolValue("DisableJsonBodyParsing")
|
||||||
};
|
};
|
||||||
|
|
||||||
if (logger != null)
|
if (logger != null)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using WireMock.Validation;
|
|||||||
|
|
||||||
namespace WireMock.Transformers
|
namespace WireMock.Transformers
|
||||||
{
|
{
|
||||||
internal static class HandleBarsFile
|
internal static class HandlebarsFile
|
||||||
{
|
{
|
||||||
public static void Register(IHandlebars handlebarsContext, IFileSystemHandler fileSystemHandler)
|
public static void Register(IHandlebars handlebarsContext, IFileSystemHandler fileSystemHandler)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
using HandlebarsDotNet;
|
|
||||||
using WireMock.Handlers;
|
|
||||||
|
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
|
||||||
internal static class HandlebarsHelpers
|
|
||||||
{
|
|
||||||
public static void Register(IHandlebars handlebarsContext, IFileSystemHandler fileSystemHandler)
|
|
||||||
{
|
|
||||||
HandleBarsRegex.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandleBarsJsonPath.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandleBarsLinq.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandleBarsRandom.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandleBarsXeger.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandleBarsXPath.Register(handlebarsContext);
|
|
||||||
|
|
||||||
HandleBarsFile.Register(handlebarsContext, fileSystemHandler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ using WireMock.Validation;
|
|||||||
|
|
||||||
namespace WireMock.Transformers
|
namespace WireMock.Transformers
|
||||||
{
|
{
|
||||||
internal static class HandleBarsJsonPath
|
internal static class HandlebarsJsonPath
|
||||||
{
|
{
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
public static void Register(IHandlebars handlebarsContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using WireMock.Validation;
|
|||||||
|
|
||||||
namespace WireMock.Transformers
|
namespace WireMock.Transformers
|
||||||
{
|
{
|
||||||
internal static class HandleBarsLinq
|
internal static class HandlebarsLinq
|
||||||
{
|
{
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
public static void Register(IHandlebars handlebarsContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using WireMock.Validation;
|
|||||||
|
|
||||||
namespace WireMock.Transformers
|
namespace WireMock.Transformers
|
||||||
{
|
{
|
||||||
internal static class HandleBarsRandom
|
internal static class HandlebarsRandom
|
||||||
{
|
{
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
public static void Register(IHandlebars handlebarsContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using WireMock.Validation;
|
|||||||
|
|
||||||
namespace WireMock.Transformers
|
namespace WireMock.Transformers
|
||||||
{
|
{
|
||||||
internal static class HandleBarsRegex
|
internal static class HandlebarsRegex
|
||||||
{
|
{
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
public static void Register(IHandlebars handlebarsContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using Wmhelp.XPath2;
|
|||||||
|
|
||||||
namespace WireMock.Transformers
|
namespace WireMock.Transformers
|
||||||
{
|
{
|
||||||
internal static class HandleBarsXPath
|
internal static class HandlebarsXPath
|
||||||
{
|
{
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
public static void Register(IHandlebars handlebarsContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using WireMock.Validation;
|
|||||||
|
|
||||||
namespace WireMock.Transformers
|
namespace WireMock.Transformers
|
||||||
{
|
{
|
||||||
internal static class HandleBarsXeger
|
internal static class HandlebarsXeger
|
||||||
{
|
{
|
||||||
public static void Register(IHandlebars handlebarsContext)
|
public static void Register(IHandlebars handlebarsContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace WireMock.Transformers
|
|||||||
{
|
{
|
||||||
var handlebars = Handlebars.Create(HandlebarsConfiguration);
|
var handlebars = Handlebars.Create(HandlebarsConfiguration);
|
||||||
|
|
||||||
HandlebarsHelpers.Register(handlebars, _fileSystemHandler);
|
WireMockHandlebarsHelpers.Register(handlebars, _fileSystemHandler);
|
||||||
|
|
||||||
_action?.Invoke(handlebars, _fileSystemHandler);
|
_action?.Invoke(handlebars, _fileSystemHandler);
|
||||||
|
|
||||||
|
|||||||
@@ -1,233 +1,236 @@
|
|||||||
using HandlebarsDotNet;
|
using HandlebarsDotNet;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using WireMock.Types;
|
using System.Text;
|
||||||
using WireMock.Util;
|
using WireMock.Types;
|
||||||
using WireMock.Validation;
|
using WireMock.Util;
|
||||||
|
using WireMock.Validation;
|
||||||
namespace WireMock.Transformers
|
|
||||||
{
|
namespace WireMock.Transformers
|
||||||
internal class ResponseMessageTransformer
|
{
|
||||||
{
|
internal class ResponseMessageTransformer
|
||||||
private readonly IHandlebarsContextFactory _factory;
|
{
|
||||||
|
private readonly IHandlebarsContextFactory _factory;
|
||||||
public ResponseMessageTransformer([NotNull] IHandlebarsContextFactory factory)
|
|
||||||
{
|
public ResponseMessageTransformer([NotNull] IHandlebarsContextFactory factory)
|
||||||
Check.NotNull(factory, nameof(factory));
|
{
|
||||||
|
Check.NotNull(factory, nameof(factory));
|
||||||
_factory = factory;
|
|
||||||
}
|
_factory = factory;
|
||||||
|
}
|
||||||
public ResponseMessage Transform(RequestMessage requestMessage, ResponseMessage original, bool useTransformerForBodyAsFile)
|
|
||||||
{
|
public ResponseMessage Transform(RequestMessage requestMessage, ResponseMessage original, bool useTransformerForBodyAsFile)
|
||||||
var handlebarsContext = _factory.Create();
|
{
|
||||||
|
var handlebarsContext = _factory.Create();
|
||||||
var responseMessage = new ResponseMessage();
|
|
||||||
|
var responseMessage = new ResponseMessage();
|
||||||
var template = new { request = requestMessage };
|
|
||||||
|
var template = new { request = requestMessage };
|
||||||
switch (original.BodyData.DetectedBodyType)
|
|
||||||
{
|
switch (original.BodyData?.DetectedBodyType)
|
||||||
case BodyType.Json:
|
{
|
||||||
TransformBodyAsJson(handlebarsContext.Handlebars, template, original, responseMessage);
|
case BodyType.Json:
|
||||||
break;
|
TransformBodyAsJson(handlebarsContext.Handlebars, template, original, responseMessage);
|
||||||
|
break;
|
||||||
case BodyType.File:
|
|
||||||
TransformBodyAsFile(handlebarsContext, template, original, responseMessage, useTransformerForBodyAsFile);
|
case BodyType.File:
|
||||||
break;
|
TransformBodyAsFile(handlebarsContext, template, original, responseMessage, useTransformerForBodyAsFile);
|
||||||
|
break;
|
||||||
case BodyType.String:
|
|
||||||
responseMessage.BodyOriginal = original.BodyData.BodyAsString;
|
case BodyType.String:
|
||||||
TransformBodyAsString(handlebarsContext.Handlebars, template, original, responseMessage);
|
responseMessage.BodyOriginal = original.BodyData.BodyAsString;
|
||||||
break;
|
TransformBodyAsString(handlebarsContext.Handlebars, template, original, responseMessage);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
responseMessage.FaultType = original.FaultType;
|
|
||||||
responseMessage.FaultPercentage = original.FaultPercentage;
|
responseMessage.FaultType = original.FaultType;
|
||||||
|
responseMessage.FaultPercentage = original.FaultPercentage;
|
||||||
// Headers
|
|
||||||
var newHeaders = new Dictionary<string, WireMockList<string>>();
|
// Headers
|
||||||
foreach (var header in original.Headers)
|
var newHeaders = new Dictionary<string, WireMockList<string>>();
|
||||||
{
|
foreach (var header in original.Headers)
|
||||||
var templateHeaderKey = handlebarsContext.Handlebars.Compile(header.Key);
|
{
|
||||||
var templateHeaderValues = header.Value
|
var templateHeaderKey = handlebarsContext.Handlebars.Compile(header.Key);
|
||||||
.Select(handlebarsContext.Handlebars.Compile)
|
var templateHeaderValues = header.Value
|
||||||
.Select(func => func(template))
|
.Select(handlebarsContext.Handlebars.Compile)
|
||||||
.ToArray();
|
.Select(func => func(template))
|
||||||
|
.ToArray();
|
||||||
newHeaders.Add(templateHeaderKey(template), new WireMockList<string>(templateHeaderValues));
|
|
||||||
}
|
newHeaders.Add(templateHeaderKey(template), new WireMockList<string>(templateHeaderValues));
|
||||||
|
}
|
||||||
responseMessage.Headers = newHeaders;
|
|
||||||
|
responseMessage.Headers = newHeaders;
|
||||||
switch (original.StatusCode)
|
|
||||||
{
|
switch (original.StatusCode)
|
||||||
case int statusCodeAsInteger:
|
{
|
||||||
responseMessage.StatusCode = statusCodeAsInteger;
|
case int statusCodeAsInteger:
|
||||||
break;
|
responseMessage.StatusCode = statusCodeAsInteger;
|
||||||
|
break;
|
||||||
case string statusCodeAsString:
|
|
||||||
var templateForStatusCode = handlebarsContext.Handlebars.Compile(statusCodeAsString);
|
case string statusCodeAsString:
|
||||||
responseMessage.StatusCode = templateForStatusCode(template);
|
var templateForStatusCode = handlebarsContext.Handlebars.Compile(statusCodeAsString);
|
||||||
break;
|
responseMessage.StatusCode = templateForStatusCode(template);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
return responseMessage;
|
|
||||||
}
|
return responseMessage;
|
||||||
|
}
|
||||||
private static void TransformBodyAsJson(IHandlebars handlebarsContext, object template, ResponseMessage original, ResponseMessage responseMessage)
|
|
||||||
{
|
private static void TransformBodyAsJson(IHandlebars handlebarsContext, object template, ResponseMessage original, ResponseMessage responseMessage)
|
||||||
JToken jToken;
|
{
|
||||||
switch (original.BodyData.BodyAsJson)
|
JToken jToken;
|
||||||
{
|
switch (original.BodyData.BodyAsJson)
|
||||||
case JObject bodyAsJObject:
|
{
|
||||||
jToken = bodyAsJObject.DeepClone();
|
case JObject bodyAsJObject:
|
||||||
WalkNode(handlebarsContext, jToken, template);
|
jToken = bodyAsJObject.DeepClone();
|
||||||
break;
|
WalkNode(handlebarsContext, jToken, template);
|
||||||
|
break;
|
||||||
case Array bodyAsArray:
|
|
||||||
jToken = JArray.FromObject(bodyAsArray);
|
case Array bodyAsArray:
|
||||||
WalkNode(handlebarsContext, jToken, template);
|
jToken = JArray.FromObject(bodyAsArray);
|
||||||
break;
|
WalkNode(handlebarsContext, jToken, template);
|
||||||
|
break;
|
||||||
case string bodyAsString:
|
|
||||||
jToken = ReplaceSingleNode(handlebarsContext, bodyAsString, template);
|
case string bodyAsString:
|
||||||
break;
|
jToken = ReplaceSingleNode(handlebarsContext, bodyAsString, template);
|
||||||
|
break;
|
||||||
default:
|
|
||||||
jToken = JObject.FromObject(original.BodyData.BodyAsJson);
|
default:
|
||||||
WalkNode(handlebarsContext, jToken, template);
|
jToken = JObject.FromObject(original.BodyData.BodyAsJson);
|
||||||
break;
|
WalkNode(handlebarsContext, jToken, template);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
responseMessage.BodyData = new BodyData
|
|
||||||
{
|
responseMessage.BodyData = new BodyData
|
||||||
DetectedBodyType = original.BodyData.DetectedBodyType,
|
{
|
||||||
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
Encoding = original.BodyData.Encoding,
|
||||||
BodyAsJson = jToken
|
DetectedBodyType = original.BodyData.DetectedBodyType,
|
||||||
};
|
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
||||||
}
|
BodyAsJson = jToken
|
||||||
|
};
|
||||||
private static JToken ReplaceSingleNode(IHandlebars handlebarsContext, string stringValue, object context)
|
}
|
||||||
{
|
|
||||||
var templateForStringValue = handlebarsContext.Compile(stringValue);
|
private static JToken ReplaceSingleNode(IHandlebars handlebarsContext, string stringValue, object context)
|
||||||
string transformedString = templateForStringValue(context);
|
{
|
||||||
if (!string.Equals(stringValue, transformedString))
|
var templateForStringValue = handlebarsContext.Compile(stringValue);
|
||||||
{
|
string transformedString = templateForStringValue(context);
|
||||||
const string property = "_";
|
if (!string.Equals(stringValue, transformedString))
|
||||||
JObject dummy = JObject.Parse($"{{ \"{property}\": null }}");
|
{
|
||||||
JToken node = dummy[property];
|
const string property = "_";
|
||||||
|
JObject dummy = JObject.Parse($"{{ \"{property}\": null }}");
|
||||||
ReplaceNodeValue(node, transformedString);
|
JToken node = dummy[property];
|
||||||
|
|
||||||
return dummy[property];
|
ReplaceNodeValue(node, transformedString);
|
||||||
}
|
|
||||||
|
return dummy[property];
|
||||||
return stringValue;
|
}
|
||||||
}
|
|
||||||
|
return stringValue;
|
||||||
private static void WalkNode(IHandlebars handlebarsContext, JToken node, object context)
|
}
|
||||||
{
|
|
||||||
if (node.Type == JTokenType.Object)
|
private static void WalkNode(IHandlebars handlebarsContext, JToken node, object context)
|
||||||
{
|
{
|
||||||
// In case of Object, loop all children. Do a ToArray() to avoid `Collection was modified` exceptions.
|
if (node.Type == JTokenType.Object)
|
||||||
foreach (JProperty child in node.Children<JProperty>().ToArray())
|
{
|
||||||
{
|
// In case of Object, loop all children. Do a ToArray() to avoid `Collection was modified` exceptions.
|
||||||
WalkNode(handlebarsContext, child.Value, context);
|
foreach (JProperty child in node.Children<JProperty>().ToArray())
|
||||||
}
|
{
|
||||||
}
|
WalkNode(handlebarsContext, child.Value, context);
|
||||||
else if (node.Type == JTokenType.Array)
|
}
|
||||||
{
|
}
|
||||||
// In case of Array, loop all items. Do a ToArray() to avoid `Collection was modified` exceptions.
|
else if (node.Type == JTokenType.Array)
|
||||||
foreach (JToken child in node.Children().ToArray())
|
{
|
||||||
{
|
// In case of Array, loop all items. Do a ToArray() to avoid `Collection was modified` exceptions.
|
||||||
WalkNode(handlebarsContext, child, context);
|
foreach (JToken child in node.Children().ToArray())
|
||||||
}
|
{
|
||||||
}
|
WalkNode(handlebarsContext, child, context);
|
||||||
else if (node.Type == JTokenType.String)
|
}
|
||||||
{
|
}
|
||||||
// In case of string, try to transform the value.
|
else if (node.Type == JTokenType.String)
|
||||||
string stringValue = node.Value<string>();
|
{
|
||||||
if (string.IsNullOrEmpty(stringValue))
|
// In case of string, try to transform the value.
|
||||||
{
|
string stringValue = node.Value<string>();
|
||||||
return;
|
if (string.IsNullOrEmpty(stringValue))
|
||||||
}
|
{
|
||||||
|
return;
|
||||||
var templateForStringValue = handlebarsContext.Compile(stringValue);
|
}
|
||||||
string transformedString = templateForStringValue(context);
|
|
||||||
if (!string.Equals(stringValue, transformedString))
|
var templateForStringValue = handlebarsContext.Compile(stringValue);
|
||||||
{
|
string transformedString = templateForStringValue(context);
|
||||||
ReplaceNodeValue(node, transformedString);
|
if (!string.Equals(stringValue, transformedString))
|
||||||
}
|
{
|
||||||
}
|
ReplaceNodeValue(node, transformedString);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private static void ReplaceNodeValue(JToken node, string stringValue)
|
}
|
||||||
{
|
|
||||||
if (bool.TryParse(stringValue, out bool valueAsBoolean))
|
private static void ReplaceNodeValue(JToken node, string stringValue)
|
||||||
{
|
{
|
||||||
node.Replace(valueAsBoolean);
|
if (bool.TryParse(stringValue, out bool valueAsBoolean))
|
||||||
return;
|
{
|
||||||
}
|
node.Replace(valueAsBoolean);
|
||||||
|
return;
|
||||||
JToken value;
|
}
|
||||||
try
|
|
||||||
{
|
JToken value;
|
||||||
// Try to convert this string into a JsonObject
|
try
|
||||||
value = JToken.Parse(stringValue);
|
{
|
||||||
}
|
// Try to convert this string into a JsonObject
|
||||||
catch (JsonException)
|
value = JToken.Parse(stringValue);
|
||||||
{
|
}
|
||||||
// Ignore JsonException and just keep string value and convert to JToken
|
catch (JsonException)
|
||||||
value = stringValue;
|
{
|
||||||
}
|
// Ignore JsonException and just keep string value and convert to JToken
|
||||||
|
value = stringValue;
|
||||||
node.Replace(value);
|
}
|
||||||
}
|
|
||||||
|
node.Replace(value);
|
||||||
private static void TransformBodyAsString(IHandlebars handlebarsContext, object template, ResponseMessage original, ResponseMessage responseMessage)
|
}
|
||||||
{
|
|
||||||
var templateBodyAsString = handlebarsContext.Compile(original.BodyData.BodyAsString);
|
private static void TransformBodyAsString(IHandlebars handlebarsContext, object template, ResponseMessage original, ResponseMessage responseMessage)
|
||||||
|
{
|
||||||
responseMessage.BodyData = new BodyData
|
var templateBodyAsString = handlebarsContext.Compile(original.BodyData.BodyAsString);
|
||||||
{
|
|
||||||
DetectedBodyType = original.BodyData.DetectedBodyType,
|
responseMessage.BodyData = new BodyData
|
||||||
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
{
|
||||||
BodyAsString = templateBodyAsString(template)
|
Encoding = original.BodyData.Encoding,
|
||||||
};
|
DetectedBodyType = original.BodyData.DetectedBodyType,
|
||||||
}
|
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
||||||
|
BodyAsString = templateBodyAsString(template)
|
||||||
private void TransformBodyAsFile(IHandlebarsContext handlebarsContext, object template, ResponseMessage original, ResponseMessage responseMessage, bool useTransformerForBodyAsFile)
|
};
|
||||||
{
|
}
|
||||||
var templateBodyAsFile = handlebarsContext.Handlebars.Compile(original.BodyData.BodyAsFile);
|
|
||||||
string transformedBodyAsFilename = templateBodyAsFile(template);
|
private void TransformBodyAsFile(IHandlebarsContext handlebarsContext, object template, ResponseMessage original, ResponseMessage responseMessage, bool useTransformerForBodyAsFile)
|
||||||
|
{
|
||||||
if (!useTransformerForBodyAsFile)
|
var templateBodyAsFile = handlebarsContext.Handlebars.Compile(original.BodyData.BodyAsFile);
|
||||||
{
|
string transformedBodyAsFilename = templateBodyAsFile(template);
|
||||||
responseMessage.BodyData = new BodyData
|
|
||||||
{
|
if (!useTransformerForBodyAsFile)
|
||||||
DetectedBodyType = original.BodyData.DetectedBodyType,
|
{
|
||||||
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
responseMessage.BodyData = new BodyData
|
||||||
BodyAsFile = transformedBodyAsFilename
|
{
|
||||||
};
|
DetectedBodyType = original.BodyData.DetectedBodyType,
|
||||||
}
|
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
||||||
else
|
BodyAsFile = transformedBodyAsFilename
|
||||||
{
|
};
|
||||||
string text = handlebarsContext.FileSystemHandler.ReadResponseBodyAsString(transformedBodyAsFilename);
|
}
|
||||||
var templateBodyAsString = handlebarsContext.Handlebars.Compile(text);
|
else
|
||||||
|
{
|
||||||
responseMessage.BodyData = new BodyData
|
string text = handlebarsContext.FileSystemHandler.ReadResponseBodyAsString(transformedBodyAsFilename);
|
||||||
{
|
var templateBodyAsString = handlebarsContext.Handlebars.Compile(text);
|
||||||
DetectedBodyType = BodyType.String,
|
|
||||||
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
responseMessage.BodyData = new BodyData
|
||||||
BodyAsString = templateBodyAsString(template),
|
{
|
||||||
BodyAsFile = transformedBodyAsFilename
|
DetectedBodyType = BodyType.String,
|
||||||
};
|
DetectedBodyTypeFromContentType = original.BodyData.DetectedBodyTypeFromContentType,
|
||||||
}
|
BodyAsString = templateBodyAsString(template),
|
||||||
}
|
BodyAsFile = transformedBodyAsFilename
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
30
src/WireMock.Net/Transformers/WireMockHandlebarsHelpers.cs
Normal file
30
src/WireMock.Net/Transformers/WireMockHandlebarsHelpers.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user