mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-11-13 12:23:42 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ae65ba73e | ||
|
|
2760ecbe00 | ||
|
|
f594a7cb19 | ||
|
|
30cf82fd8d | ||
|
|
3630093d49 | ||
|
|
f0965e5650 | ||
|
|
69ea61e42c | ||
|
|
bc65bccce5 | ||
|
|
f6dc299ecb | ||
|
|
dc14136492 | ||
|
|
c94824bd64 | ||
|
|
54e16fc045 | ||
|
|
7d0de75ab1 | ||
|
|
afb01a0fa6 | ||
|
|
0132ec873a | ||
|
|
64734c4f92 | ||
|
|
a5589e1e2f | ||
|
|
cb4503b1a6 | ||
|
|
dd762f218b | ||
|
|
b0f9924933 | ||
|
|
dc4cdfae50 | ||
|
|
f19d94acae | ||
|
|
90819f031e | ||
|
|
471745f704 | ||
|
|
7db5b562d8 | ||
|
|
e4389333a1 | ||
|
|
f0969e9618 | ||
|
|
84f4109a7c | ||
|
|
ee0f890795 | ||
|
|
2b165eb6a1 | ||
|
|
42353f035e | ||
|
|
7e9718eab7 | ||
|
|
a0df0916f9 | ||
|
|
7a8582fef5 | ||
|
|
05929bdea6 | ||
|
|
84c32d5b2d | ||
|
|
d39f7c771f | ||
|
|
97c8e4a08a | ||
|
|
f5eb01c580 | ||
|
|
8260dba641 | ||
|
|
5e1c126e34 | ||
|
|
ca4eea808e | ||
|
|
5692498ea3 | ||
|
|
d270ad7f4f |
No files matched your search
@@ -6,7 +6,7 @@ applyTo: '**/*.csproj, **/*.cs'
|
||||
# Multi .NET Framework Targeting
|
||||
|
||||
## Instructions
|
||||
- The main project "WireMock.Net.Minimal" targets `netstandard2.0` and `net8.0`. Ensure that any new code or dependencies are compatible with these frameworks.
|
||||
- The main project "WireMock.Net.Minimal" targets `netstandard2.0`, `net8.0` and `net10.0`. Ensure that any new code or dependencies are compatible with these frameworks.
|
||||
|
||||
|
||||
# C# Guidelines
|
||||
|
||||
@@ -4,6 +4,7 @@ permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "*.*.*"
|
||||
@@ -15,7 +16,48 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup .NET 8 and 10
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: |
|
||||
8.0.x
|
||||
10.0.x
|
||||
|
||||
- name: Publish Standalone Binaries
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ./artifacts
|
||||
RIDS=("win-x64" "win-arm64" "linux-x64" "linux-arm64" "osx-x64" "osx-arm64")
|
||||
|
||||
for RID in "${RIDS[@]}"; do
|
||||
echo "Publishing for $RID..."
|
||||
dotnet publish ./src/dotnet-WireMock.Net/dotnet-WireMock.csproj \
|
||||
-c Release \
|
||||
-r "$RID" \
|
||||
--self-contained true \
|
||||
-p:PublishSingleFile=true \
|
||||
-p:IncludeNativeLibrariesForSelfExtract=true \
|
||||
-p:PublishDocumentationFile=false \
|
||||
-p:DebugType=None \
|
||||
-p:DebugSymbols=false \
|
||||
-o "./publish/$RID"
|
||||
|
||||
if [[ "$RID" == win-* ]]; then
|
||||
(cd "./publish/$RID" && zip "../../artifacts/wiremock-net-$RID.zip" dotnet-WireMock.exe)
|
||||
else
|
||||
tar -czvf "./artifacts/wiremock-net-$RID.tar.gz" -C "./publish/$RID" dotnet-WireMock
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Upload Standalone Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: wiremock-standalone
|
||||
path: ./artifacts/*
|
||||
|
||||
- name: Release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
generate_release_notes: true
|
||||
generate_release_notes: true
|
||||
files: ./artifacts/*
|
||||
+75
-22
@@ -8,6 +8,9 @@ on:
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
windows-build-and-run:
|
||||
name: Run Tests on Windows
|
||||
@@ -19,22 +22,33 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup .NET 8
|
||||
- name: Setup .NET 8 and 10
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
dotnet-version: |
|
||||
8.0.x
|
||||
10.0.x
|
||||
|
||||
- name: 'WireMock.Net.TUnitTests'
|
||||
run: dotnet test --project './test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj' -c Release
|
||||
# - name: 'WireMock.Net.TUnitTests (net8.0)'
|
||||
# run: dotnet test --project './test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj' -c Release --framework net8.0
|
||||
|
||||
- name: 'WireMock.Net.Tests'
|
||||
run: dotnet test --project './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' -c Release --framework net8.0
|
||||
- name: 'WireMock.Net.TUnitTests (net10.0)'
|
||||
run: dotnet test --project './test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj' -c Release --framework net10.0
|
||||
|
||||
- name: 'WireMock.Net.Tests.UsingNuGet'
|
||||
run: dotnet test --project './test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj' -c Release
|
||||
# - name: 'WireMock.Net.Tests (net8.0)'
|
||||
# run: dotnet test --project './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' -c Release --framework net8.0
|
||||
|
||||
- name: 'WireMock.Net.Middleware.Tests'
|
||||
run: dotnet test --project './test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj' -c Release
|
||||
- name: 'WireMock.Net.Tests (net10.0)'
|
||||
run: dotnet test --project './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' -c Release --framework net10.0
|
||||
|
||||
# - name: 'WireMock.Net.Tests.UsingNuGet'
|
||||
# run: dotnet test --project './test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj' -c Release
|
||||
|
||||
# - name: 'WireMock.Net.Middleware.Tests (net8.0)'
|
||||
# run: dotnet test --project './test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj' -c Release --framework net8.0
|
||||
|
||||
- name: 'WireMock.Net.Middleware.Tests (net10.0)'
|
||||
run: dotnet test --project './test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj' -c Release --framework net10.0
|
||||
|
||||
linux-build-and-run:
|
||||
name: Run Tests on Linux
|
||||
@@ -46,22 +60,61 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup .NET 8
|
||||
- name: Setup .NET 8 and 10
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
dotnet-version: |
|
||||
8.0.x
|
||||
10.0.x
|
||||
|
||||
- name: 'WireMock.Net.TUnitTests'
|
||||
run: dotnet test --project './test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj' -c Release
|
||||
# - name: 'WireMock.Net.TUnitTests (net8.0)'
|
||||
# run: dotnet test --project './test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj' -c Release --framework net8.0
|
||||
|
||||
- name: 'WireMock.Net.Tests'
|
||||
run: dotnet test --project './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' -c Release --framework net8.0
|
||||
- name: 'WireMock.Net.TUnitTests (net10.0)'
|
||||
run: dotnet test --project './test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj' -c Release --framework net10.0
|
||||
|
||||
- name: 'WireMock.Net.Tests.UsingNuGet'
|
||||
run: dotnet test --project './test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj' -c Release
|
||||
# - name: 'WireMock.Net.Tests (net8.0)'
|
||||
# run: dotnet test --project './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' -c Release --framework net8.0
|
||||
|
||||
- name: 'WireMock.Net.Tests (net10.0)'
|
||||
run: dotnet test --project './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' -c Release --framework net10.0
|
||||
|
||||
- name: 'WireMock.Net.Tests.UsingNuGet (net8.0)'
|
||||
run: dotnet test --project './test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj' -c Release --framework net8.0
|
||||
|
||||
# - name: 'WireMock.Net.Tests.UsingNuGet (net10.0)'
|
||||
# run: dotnet test --project './test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj' -c Release --framework net10.0
|
||||
|
||||
- name: 'WireMock.Net.Middleware.Tests'
|
||||
run: dotnet test --project './test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj' -c Release
|
||||
# - name: 'WireMock.Net.Middleware.Tests (net8.0)'
|
||||
# run: dotnet test --project './test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj' -c Release --framework net8.0
|
||||
|
||||
- name: 'WireMock.Net.Aspire.Tests'
|
||||
run: dotnet test --project './test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj' -c Release
|
||||
- name: 'WireMock.Net.Middleware.Tests (net10.0)'
|
||||
run: dotnet test --project './test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj' -c Release --framework net10.0
|
||||
|
||||
# - name: 'WireMock.Net.Aspire.Tests (net8.0)'
|
||||
# run: dotnet test --project './test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj' -c Release --framework net8.0
|
||||
|
||||
- name: 'WireMock.Net.Aspire.Tests (net10.0)'
|
||||
run: dotnet test --project './test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj' -c Release --framework net10.0
|
||||
|
||||
- name: 'dotnet-WireMock stops on CTRL-C'
|
||||
run: |
|
||||
set -m # job control, so the background process does not ignore SIGINT
|
||||
dotnet build ./src/dotnet-WireMock.Net/dotnet-WireMock.csproj -c Release
|
||||
dotnet ./src/dotnet-WireMock.Net/bin/Release/net10.0/dotnet-WireMock.dll --Urls http://localhost:0 > wiremock.log 2>&1 & # port 0 = OS assigns a free port
|
||||
PID=$!
|
||||
sleep 3
|
||||
grep -q 'Server listening at' wiremock.log || { cat wiremock.log; kill -9 $PID; exit 1; }
|
||||
kill -INT $PID
|
||||
for i in $(seq 1 10); do
|
||||
if ! kill -0 $PID 2>/dev/null; then
|
||||
EXIT_CODE=0
|
||||
wait $PID || EXIT_CODE=$?
|
||||
echo "dotnet-WireMock stopped (exit code $EXIT_CODE)"
|
||||
exit $EXIT_CODE
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "dotnet-WireMock did not stop within 10 seconds after CTRL-C"
|
||||
kill -9 $PID
|
||||
exit 1
|
||||
@@ -1,36 +0,0 @@
|
||||
name: "Copilot Setup Steps"
|
||||
|
||||
# Automatically run the setup steps when they are changed to allow for easy validation, and
|
||||
# allow manual testing through the repository's "Actions" tab
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- .github/workflows/copilot-setup-steps.yml
|
||||
pull_request:
|
||||
paths:
|
||||
- .github/workflows/copilot-setup-steps.yml
|
||||
|
||||
jobs:
|
||||
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
|
||||
copilot-setup-steps:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Set the permissions to the lowest permissions possible needed for your steps.
|
||||
# Copilot will be given its own token for its operations.
|
||||
permissions:
|
||||
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
|
||||
contents: read
|
||||
|
||||
# You can define any steps you want, and they will run before the agent starts.
|
||||
# If you do not check out your code, Copilot will do this for you.
|
||||
steps:
|
||||
- name: Install .NET 10.x
|
||||
uses: actions/setup-dotnet@v5
|
||||
with:
|
||||
dotnet-version: |
|
||||
10.x
|
||||
dotnet-quality: preview
|
||||
|
||||
- name: dotnet --info
|
||||
run: dotnet --info
|
||||
+2
-2
@@ -253,7 +253,7 @@ paket-files/
|
||||
|
||||
./report/coverlet/
|
||||
/test/WireMock.Net.Tests/coverage.opencover.xml
|
||||
/test/WireMock.Net.Tests/coverage.netcoreapp3.1.opencover.xml
|
||||
/test/WireMock.Net.Tests/coverage.net8.0.opencover.xml
|
||||
|
||||
/test/WireMock.Net.Tests/coverage.*.opencover.xml
|
||||
/test/WireMock.Net.Middleware.Tests/coverage.opencover.xml
|
||||
*.received.*
|
||||
@@ -1,3 +1,57 @@
|
||||
# 2.30.0 (07 November 2026)
|
||||
- [#1527](https://github.com/wiremock/WireMock.Net/pull/1527) - Publish standalone single-file binaries in GitHub Releases [feature] contributed by [tomas-pinto](https://github.com/tomas-pinto)
|
||||
- [#1528](https://github.com/wiremock/WireMock.Net/pull/1528) - Add .NET 10 target framework [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1530](https://github.com/wiremock/WireMock.Net/pull/1530) - Use 10.x.x NuGets for .NET 10 [dependencies] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1532](https://github.com/wiremock/WireMock.Net/pull/1532) - Switch to IHost for .NET 10 + update dotnet-WireMock [feature] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
# 2.21.0 (28 October 2026)
|
||||
- [#1526](https://github.com/wiremock/WireMock.Net/pull/1526) - Update Scriban to 7.5.3 [dependencies] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1525](https://github.com/wiremock/WireMock.Net/issues/1525) - High security vulnerability in Scriban package [security]
|
||||
|
||||
# 2.20.0 (23 October 2026)
|
||||
- [#1516](https://github.com/wiremock/WireMock.Net/pull/1516) - Add ScribanRegistrationCallback to register custom Scriban functions [feature] contributed by [Quattordici](https://github.com/Quattordici)
|
||||
- [#1519](https://github.com/wiremock/WireMock.Net/pull/1519) - Bump MessagePack from 2.5.302 to 2.5.303 [dependencies] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1521](https://github.com/wiremock/WireMock.Net/pull/1521) - Add near-miss diagnostics and request count/unmatched endpoints to the admin API [feature] contributed by [Quattordici](https://github.com/Quattordici)
|
||||
- [#1522](https://github.com/wiremock/WireMock.Net/pull/1522) - Downgrade JsonPath.Net from 3.0.2 to 2.2.0 to avoid Open Source Maintenance Fee issues [dependencies] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1515](https://github.com/wiremock/WireMock.Net/issues/1515) - Allow registering custom Scriban functions (ScribanRegistrationCallback), like HandlebarsRegistrationCallback [feature]
|
||||
- [#1520](https://github.com/wiremock/WireMock.Net/issues/1520) - json-everything sub-dependency now has Open Source Maintenance Fee [dependencies]
|
||||
|
||||
# 2.19.0 (07 October 2026)
|
||||
- [#1512](https://github.com/wiremock/WireMock.Net/pull/1512) - Use IDateTimeUtils in WireMockWebSocketContext [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1514](https://github.com/wiremock/WireMock.Net/pull/1514) - Fix DateTime in Response [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1511](https://github.com/wiremock/WireMock.Net/issues/1511) - Incorrect response datetime for mapped response [bug]
|
||||
|
||||
# 2.18.0 (22 September 2026)
|
||||
- [#1510](https://github.com/wiremock/WireMock.Net/pull/1510) - WireMock.Net.OpenApiParser: fix depencency on RamlToOpenApiConverter.SourceOnly [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1508](https://github.com/wiremock/WireMock.Net/issues/1508) - Transitive Dependency Conflict with Microsoft.OpenApi in 2.16.0 [bug]
|
||||
|
||||
# 2.17.0 (21 September 2026)
|
||||
- [#1509](https://github.com/wiremock/WireMock.Net/pull/1509) - Revert to RamlToOpenApiConverter.SourceOnly [bug] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
# 2.16.0 (19 September 2026)
|
||||
- [#1502](https://github.com/wiremock/WireMock.Net/pull/1502) - Fix #1501: Generate WhenStateIs/WillSetStateTo correctly in ToCSharpCode contributed by [Bafyn](https://github.com/Bafyn)
|
||||
- [#1503](https://github.com/wiremock/WireMock.Net/pull/1503) - Fix FormUrlEncodedMatcher (+ refactor values / matchers logic) contributed by [StefH](https://github.com/StefH)
|
||||
- [#1504](https://github.com/wiremock/WireMock.Net/pull/1504) - Update SharpYaml package to version 2.5.1 [dependencies] contributed by [johnthcall](https://github.com/johnthcall)
|
||||
- [#1505](https://github.com/wiremock/WireMock.Net/pull/1505) - Upgrade dependency RamlToOpenApiConverter to version 0.40.0 [dependencies] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1500](https://github.com/wiremock/WireMock.Net/issues/1500) - Sending a form-urlencoded body with a repeated field name returns HTTP 500 [bug]
|
||||
- [#1501](https://github.com/wiremock/WireMock.Net/issues/1501) - Generated C# code for stateful (Scenario) mappings does not compile and drops the WhenStateIs condition [bug]
|
||||
|
||||
# 2.15.0 (15 August 2026)
|
||||
- [#1495](https://github.com/wiremock/WireMock.Net/pull/1495) - Fix #1494: `WithClientIP(MatchOperator, params IStringMatcher[])` ignores the MatchOperator argument [bug] contributed by [Bafyn](https://github.com/Bafyn)
|
||||
- [#1497](https://github.com/wiremock/WireMock.Net/pull/1497) - Fix WithParam RejectOnMatch inverting the match result #1496 [bug] contributed by [Bafyn](https://github.com/Bafyn)
|
||||
- [#1499](https://github.com/wiremock/WireMock.Net/pull/1499) - Update Testcontainers [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1494](https://github.com/wiremock/WireMock.Net/issues/1494) - `WithClientIP(MatchOperator, params IStringMatcher[])` ignores the `MatchOperator` argument [bug]
|
||||
- [#1496](https://github.com/wiremock/WireMock.Net/issues/1496) - `WithParam(key, MatchBehaviour.RejectOnMatch, values)` inverts the match result [bug]
|
||||
|
||||
# 2.14.0 (06 August 2026)
|
||||
- [#1493](https://github.com/wiremock/WireMock.Net/pull/1493) - Fix #1492: Serialize WithClientIP matcher to Request.ClientIP [bug] contributed by [Bafyn](https://github.com/Bafyn)
|
||||
- [#1492](https://github.com/wiremock/WireMock.Net/issues/1492) - `WithClientIP` matcher is lost / corrupted when a mapping is serialized [bug]
|
||||
|
||||
# 2.13.0 (19 July 2026)
|
||||
- [#1488](https://github.com/wiremock/WireMock.Net/pull/1488) - feat(xunit logging): TestOutputHelperWireMockLogger [feature] contributed by [Stepami](https://github.com/Stepami)
|
||||
- [#1490](https://github.com/wiremock/WireMock.Net/pull/1490) - Fix: Fully respect configured custom admin path (merge PR #1483) [feature] contributed by [Copilot](https://github.com/apps/copilot-swe-agent)
|
||||
- [#1482](https://github.com/wiremock/WireMock.Net/issues/1482) - WireMock.Minimal.Owin does not respect custom pathing for determining admin paths [bug]
|
||||
|
||||
# 2.12.0 (07 July 2026)
|
||||
- [#1479](https://github.com/wiremock/WireMock.Net/pull/1479) - Upgrade Microsoft.OpenApi to 3.7.0 and YamlDotNet to 18.1.0 [security] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1480](https://github.com/wiremock/WireMock.Net/pull/1480) - Upgrade RamlToOpenApiConverter.SourceOnly to 0.21.0 [feature] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>2.12.0</VersionPrefix>
|
||||
<VersionPrefix>2.30.0</VersionPrefix>
|
||||
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
|
||||
<PackageProjectUrl>https://github.com/wiremock/WireMock.Net</PackageProjectUrl>
|
||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||
@@ -51,11 +51,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.300" PrivateAssets="All" />
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2026.2.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.403" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
|
||||
<ItemGroup Condition="('$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net10.0')">
|
||||
<!--<PackageReference Include="SonarAnalyzer.CSharp" Version="10.15.0.120848">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
rem https://github.com/StefH/GitHubReleaseNotes
|
||||
|
||||
SET version=2.12.0
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
for /f "usebackq delims=" %%v in (`powershell -NoProfile -Command "[xml]$props = Get-Content 'Directory.Build.props'; $props.Project.PropertyGroup | ForEach-Object { $_.VersionPrefix } | Where-Object { $_ } | Select-Object -First 1"`) do set version=%%v
|
||||
|
||||
if "%version%"=="" (
|
||||
echo Unable to determine VersionPrefix from Directory.Build.props.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels wontfix test question invalid doc duplicate example environment --version %version% --token %GH_TOKEN%
|
||||
if errorlevel 1 exit /b %errorlevel%
|
||||
|
||||
GitHubReleaseNotes --output PackageReleaseNotes.txt --skip-empty-releases --exclude-labels wontfix test question invalid doc duplicate example environment --template PackageReleaseNotes.template --version %version% --token %GH_TOKEN%
|
||||
GitHubReleaseNotes --output PackageReleaseNotes.txt --skip-empty-releases --exclude-labels wontfix test question invalid doc duplicate example environment --template PackageReleaseNotes.template --version %version% --token %GH_TOKEN%
|
||||
if errorlevel 1 exit /b %errorlevel%
|
||||
@@ -1,8 +1,7 @@
|
||||
# 2.12.0 (07 July 2026)
|
||||
- #1479 Upgrade Microsoft.OpenApi to 3.7.0 and YamlDotNet to 18.1.0 [security]
|
||||
- #1480 Upgrade RamlToOpenApiConverter.SourceOnly to 0.21.0 [feature]
|
||||
- #1484 Update Scriban.Signed package version to 7.2.5 [security]
|
||||
- #1487 Response.Create() sets the DateTime to UtcNow [bug]
|
||||
- #1486 ResponseMessage.DateTime defaults to DateTime.MinValue, causing premature log entry purging for *matched* requests [bug]
|
||||
# 2.30.0 (07 November 2026)
|
||||
- #1527 Publish standalone single-file binaries in GitHub Releases [feature]
|
||||
- #1528 Add .NET 10 target framework [feature]
|
||||
- #1530 Use 10.x.x NuGets for .NET 10 [dependencies]
|
||||
- #1532 Switch to IHost for .NET 10 + update dotnet-WireMock [feature]
|
||||
|
||||
The full release notes can be found here: https://github.com/wiremock/WireMock.Net/blob/master/CHANGELOG.md
|
||||
+16
-15
@@ -1,3 +1,4 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 18
|
||||
VisualStudioVersion = 18.0.11205.157
|
||||
@@ -73,8 +74,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Testcontainers
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.TestcontainersExample", "examples\WireMock.Net.TestcontainersExample\WireMock.Net.TestcontainersExample.csproj", "{56A38798-C48B-4A4A-B805-071E05C02CE1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NET8", "examples\WireMock.Net.Console.NET8\WireMock.Net.Console.NET8.csproj", "{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMockAzureQueueProxy", "examples\WireMockAzureQueueProxy\WireMockAzureQueueProxy.csproj", "{7FC0B409-2682-40EE-B3B9-3930D6769D01}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.GrpcClient", "examples\WireMock.Net.Console.GrpcClient\WireMock.Net.Console.GrpcClient.csproj", "{B1580A38-84E7-44BE-8FE7-3EE5031D74A1}"
|
||||
@@ -153,6 +152,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Matchers.Syste
|
||||
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", "examples\WireMock.Net.Console\WireMock.Net.Console.csproj", "{1B2D0EF9-A494-400C-91CF-651249B2BA0B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -379,18 +380,6 @@ Global
|
||||
{56A38798-C48B-4A4A-B805-071E05C02CE1}.Release|x64.Build.0 = Release|Any CPU
|
||||
{56A38798-C48B-4A4A-B805-071E05C02CE1}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{56A38798-C48B-4A4A-B805-071E05C02CE1}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Release|x64.Build.0 = Release|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA}.Release|x86.Build.0 = Release|Any CPU
|
||||
{7FC0B409-2682-40EE-B3B9-3930D6769D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7FC0B409-2682-40EE-B3B9-3930D6769D01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7FC0B409-2682-40EE-B3B9-3930D6769D01}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
@@ -847,6 +836,18 @@ Global
|
||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -872,7 +873,6 @@ Global
|
||||
{BAA9EC2A-874B-45CE-8E51-A73622DC7F3D} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||
{12B016A5-9D8B-4EFE-96C2-CA51BE43367D} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||
{56A38798-C48B-4A4A-B805-071E05C02CE1} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||
{1EA72C0F-92E9-486B-8FFE-53F992BFC4AA} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||
{7FC0B409-2682-40EE-B3B9-3930D6769D01} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||
{B1580A38-84E7-44BE-8FE7-3EE5031D74A1} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||
{CAB42D88-B4E4-4887-B684-9F3E09D085A1} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||
@@ -911,6 +911,7 @@ Global
|
||||
{F4B2B967-98D7-4D93-9A5C-5EF7B84B941A} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||
{A1B2C3D4-E5F6-7890-ABCD-EF1234567890} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||
{7F0B2446-0363-4720-AF46-F47F83B557DC} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||
{1B2D0EF9-A494-400C-91CF-651249B2BA0B} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458}
|
||||
|
||||
+81
-63
@@ -1,3 +1,9 @@
|
||||
parameters:
|
||||
- name: runWindowsReleaseToMyGet
|
||||
displayName: Run Windows Release to MyGet
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
variables:
|
||||
Prerelease: 'ci'
|
||||
buildId: "1$(Build.BuildId)"
|
||||
@@ -14,6 +20,12 @@ jobs:
|
||||
echo "BuildId = $(buildId)"
|
||||
displayName: 'Print buildId'
|
||||
|
||||
- task: UseDotNet@2
|
||||
displayName: Use .NET 10.0
|
||||
inputs:
|
||||
packageType: 'sdk'
|
||||
version: '10.0.x'
|
||||
|
||||
- script: |
|
||||
dotnet tool install --global dotnet-sonarscanner
|
||||
dotnet tool install --global dotnet-coverage
|
||||
@@ -42,30 +54,30 @@ jobs:
|
||||
inputs:
|
||||
command: 'build'
|
||||
projects: '**/test/**/*.csproj'
|
||||
arguments: '--configuration Debug --framework net8.0'
|
||||
arguments: '--configuration Debug --framework net10.0'
|
||||
|
||||
- task: CmdLine@2
|
||||
inputs:
|
||||
script: |
|
||||
dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --no-build --framework net8.0" -f xml -o "wiremock-coverage-xunit.xml"
|
||||
dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --no-build --framework net10.0" -f xml -o "wiremock-coverage-xunit.xml"
|
||||
displayName: 'WireMock.Net.Tests with Coverage'
|
||||
|
||||
- task: CmdLine@2
|
||||
inputs:
|
||||
script: |
|
||||
dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj --configuration Debug --no-build" -f xml -o "wiremock-coverage-tunit.xml"
|
||||
dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj --configuration Debug --no-build --framework net10.0" -f xml -o "wiremock-coverage-tunit.xml"
|
||||
displayName: 'WireMock.Net.TUnitTests with Coverage'
|
||||
|
||||
- task: CmdLine@2
|
||||
inputs:
|
||||
script: |
|
||||
dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj --configuration Debug --no-build" -f xml -o "wiremock-coverage-middleware.xml"
|
||||
dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj --configuration Debug --no-build --framework net10.0" -f xml -o "wiremock-coverage-middleware.xml"
|
||||
displayName: 'WireMock.Net.Middleware.Tests with Coverage'
|
||||
|
||||
- task: CmdLine@2
|
||||
inputs:
|
||||
script: |
|
||||
dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj --configuration Debug --no-build" -f xml -o "wiremock-coverage-aspire.xml"
|
||||
dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj --configuration Debug --no-build --framework net10.0" -f xml -o "wiremock-coverage-aspire.xml"
|
||||
displayName: 'WireMock.Net.Aspire.Tests with Coverage'
|
||||
|
||||
- task: CmdLine@2
|
||||
@@ -104,76 +116,82 @@ jobs:
|
||||
|
||||
steps:
|
||||
- task: UseDotNet@2
|
||||
displayName: Use .NET 8.0
|
||||
displayName: Use .NET 10.0
|
||||
inputs:
|
||||
packageType: 'sdk'
|
||||
version: '8.0.x'
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 'WireMock.Net.Tests.UsingNuGet'
|
||||
inputs:
|
||||
script: 'dotnet test ./test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj --configuration Release'
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 'WireMock.Net.Tests with Coverage'
|
||||
inputs:
|
||||
script: 'dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --framework net8.0 --collect:"XPlat Code Coverage" --logger trx'
|
||||
version: '10.0.x'
|
||||
|
||||
# - task: CmdLine@2
|
||||
# displayName: 'WireMock.Net.TUnitTests with Coverage'
|
||||
# displayName: 'WireMock.Net.Tests.UsingNuGet'
|
||||
# inputs:
|
||||
# script: 'dotnet test --project ./test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj --configuration Debug --framework net8.0 --collect:"XPlat Code Coverage" --logger trx'
|
||||
# script: 'dotnet test ./test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj --configuration Release'
|
||||
|
||||
# - task: CmdLine@2
|
||||
# displayName: 'WireMock.Net.Tests'
|
||||
# inputs:
|
||||
# script: 'dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --framework net8.0'
|
||||
|
||||
- task: CmdLine@2
|
||||
displayName: 'WireMock.Net.Middleware.Tests with Coverage'
|
||||
displayName: 'WireMock.Net.Tests'
|
||||
inputs:
|
||||
script: 'dotnet test ./test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj --configuration Debug --framework net8.0 --collect:"XPlat Code Coverage" --logger trx'
|
||||
script: 'dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Debug --framework net10.0'
|
||||
|
||||
- job: Windows_Release_to_MyGet
|
||||
dependsOn: Windows_Build_Test
|
||||
# - task: CmdLine@2
|
||||
# displayName: 'WireMock.Net.TUnitTests'
|
||||
# inputs:
|
||||
# script: 'dotnet test --project ./test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj --configuration Debug --framework net10.0'
|
||||
|
||||
pool:
|
||||
vmImage: 'windows-2025'
|
||||
|
||||
steps:
|
||||
- script: |
|
||||
echo "BuildId = $(buildId)"
|
||||
displayName: 'Print buildId'
|
||||
|
||||
- task: UseDotNet@2
|
||||
displayName: Use .NET 8.0
|
||||
- task: CmdLine@2
|
||||
displayName: 'WireMock.Net.Middleware.Tests'
|
||||
inputs:
|
||||
packageType: 'sdk'
|
||||
version: '8.0.x'
|
||||
script: 'dotnet test ./test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj --configuration Debug --framework net10.0'
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Build Release
|
||||
inputs:
|
||||
command: 'build'
|
||||
arguments: /p:Configuration=Release
|
||||
projects: $(buildProjects)
|
||||
# - job: Windows_Release_to_MyGet
|
||||
# dependsOn: Windows_Build_Test
|
||||
# condition: and(succeeded(), ${{ parameters.runWindowsReleaseToMyGet }})
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Pack
|
||||
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
|
||||
inputs:
|
||||
command: pack
|
||||
configuration: 'Release'
|
||||
packagesToPack: $(buildProjects)
|
||||
nobuild: true
|
||||
packDirectory: '$(Build.ArtifactStagingDirectory)/packages'
|
||||
verbosityPack: 'normal'
|
||||
# pool:
|
||||
# vmImage: 'windows-2025'
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
displayName: Publish Artifacts
|
||||
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
|
||||
inputs:
|
||||
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
|
||||
# steps:
|
||||
# - script: |
|
||||
# echo "BuildId = $(buildId)"
|
||||
# displayName: 'Print buildId'
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Push to MyGet
|
||||
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
|
||||
inputs:
|
||||
command: custom
|
||||
custom: nuget
|
||||
arguments: push $(Build.ArtifactStagingDirectory)\packages\*.nupkg -n -s https://www.myget.org/F/wiremock-net/api/v3/index.json -k $(MyGetKey)
|
||||
# - task: UseDotNet@2
|
||||
# displayName: Use .NET 10.0
|
||||
# inputs:
|
||||
# packageType: 'sdk'
|
||||
# version: '10.0.x'
|
||||
|
||||
# - task: DotNetCoreCLI@2
|
||||
# displayName: Build Release
|
||||
# inputs:
|
||||
# command: 'build'
|
||||
# arguments: /p:Configuration=Release
|
||||
# projects: $(buildProjects)
|
||||
|
||||
# - task: DotNetCoreCLI@2
|
||||
# displayName: Pack
|
||||
# condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
|
||||
# inputs:
|
||||
# command: pack
|
||||
# configuration: 'Release'
|
||||
# packagesToPack: $(buildProjects)
|
||||
# nobuild: true
|
||||
# packDirectory: '$(Build.ArtifactStagingDirectory)/packages'
|
||||
# verbosityPack: 'normal'
|
||||
|
||||
# - task: PublishBuildArtifacts@1
|
||||
# displayName: Publish Artifacts
|
||||
# condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
|
||||
# inputs:
|
||||
# PathtoPublish: '$(Build.ArtifactStagingDirectory)'
|
||||
|
||||
# - task: DotNetCoreCLI@2
|
||||
# displayName: Push to MyGet
|
||||
# condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
|
||||
# inputs:
|
||||
# command: custom
|
||||
# custom: nuget
|
||||
# arguments: push $(Build.ArtifactStagingDirectory)\packages\*.nupkg -n -s https://www.myget.org/F/wiremock-net/api/v3/index.json -k $(MyGetKey)
|
||||
@@ -18,6 +18,12 @@ steps:
|
||||
packageType: sdk
|
||||
version: 8.0.x
|
||||
|
||||
- task: UseDotNet@2
|
||||
displayName: 'Use .NET 10'
|
||||
inputs:
|
||||
packageType: sdk
|
||||
version: 10.0.x
|
||||
|
||||
# Based on https://whereslou.com/2018/09/versioning-and-publishing-nuget-packages-automatically-using-azure-devops-pipelines/
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Build Release
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="13.4.0" />
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="13.6.4" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AspireUseCliBundle>true</AspireUseCliBundle>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -18,10 +19,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.4.3" />
|
||||
|
||||
<!-- CVE-2026-48109 -->
|
||||
<PackageReference Include="MessagePack" Version="2.5.302" />
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.6.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="13.4.0" />
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="13.6.4" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AspireUseCliBundle>true</AspireUseCliBundle>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -15,10 +16,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.4.3" />
|
||||
|
||||
<!-- CVE-2026-48109 -->
|
||||
<PackageReference Include="MessagePack" Version="2.5.302" />
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.6.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsAspireSharedProject>true</IsAspireSharedProject>
|
||||
@@ -10,8 +10,8 @@
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.4.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.11.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="10.11.0" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.3" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.15.3" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.15.2" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using RestEase;
|
||||
using WireMock.Admin.Settings;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ApplicationIcon>../../resources/WireMock.Net-Logo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace WireMock.Net.Console.MimePart;
|
||||
|
||||
static class Program
|
||||
{
|
||||
private static readonly ILoggerRepository LogRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
|
||||
private static readonly ILoggerRepository LogRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()!);
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(Program));
|
||||
|
||||
static async Task Main(params string[] args)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<DefineConstants>$(DefineConstants);GRAPHQL;MIMEKIT;PROTOBUF</DefineConstants>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||
<PackageReference Include="log4net" Version="3.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="log4net" Version="3.5.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.IO;
|
||||
using WireMock.Logging;
|
||||
using WireMock.Server;
|
||||
using WireMock.Settings;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ApplicationIcon>../../resources/WireMock.Net-Logo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using WireMock.Logging;
|
||||
using WireMock.Net.StandAlone;
|
||||
using WireMock.RequestBuilders;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
File renamed without changes.
+27
-8
@@ -1,14 +1,9 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using SharpYaml.Model;
|
||||
using Scriban.Runtime;
|
||||
using WireMock.Logging;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Models;
|
||||
@@ -291,11 +286,21 @@ namespace WireMock.Net.ConsoleApplication
|
||||
|
||||
var server = WireMockServer.Start(new WireMockServerSettings
|
||||
{
|
||||
StartAdminInterface = true,
|
||||
Logger = new WireMockConsoleLogger(),
|
||||
|
||||
Port = 9091
|
||||
});
|
||||
|
||||
server
|
||||
.WhenRequest(r => r
|
||||
.WithPath("/test")
|
||||
.UsingAnyMethod()
|
||||
)
|
||||
.ThenRespondWith(r => r
|
||||
.WithStatusCode(HttpStatusCode.OK)
|
||||
.WithBody("OK")
|
||||
);
|
||||
|
||||
server
|
||||
.WhenRequest(r => r
|
||||
.WithPath("/Content-Length")
|
||||
@@ -405,12 +410,26 @@ namespace WireMock.Net.ConsoleApplication
|
||||
// handlebarsContext.RegisterHelper(transformer.Name, transformer.Render); TODO
|
||||
},
|
||||
|
||||
ScribanRegistrationCallback = (scriptObject, fileSystemHandler) =>
|
||||
{
|
||||
var globals = (ScriptObject)scriptObject;
|
||||
globals.Import("greet", new Func<string, string>(name => $"Hello {name}"));
|
||||
},
|
||||
|
||||
// Uncomment below if you want to use the CustomFileSystemFileHandler
|
||||
// FileSystemHandler = new CustomFileSystemFileHandler()
|
||||
});
|
||||
System.Console.WriteLine("WireMockServer listening at {0}", string.Join(",", server.Urls));
|
||||
|
||||
server.SetBasicAuthentication("a", "b");
|
||||
|
||||
server
|
||||
.Given(Request.Create().WithPath("/scriban/greet").UsingGet())
|
||||
.RespondWith(Response.Create()
|
||||
.WithBody("{{ greet 'WireMock.Net' }}")
|
||||
.WithTransformer(TransformerType.Scriban)
|
||||
);
|
||||
|
||||
//server.SetAzureADAuthentication(Environment.GetEnvironmentVariable("WIREMOCK_AAD_TENANT")!, "api://e083d51a-01a6-446c-8ad5-0c5c7f002208");
|
||||
|
||||
//var http = new HttpClient();
|
||||
@@ -1115,7 +1134,7 @@ namespace WireMock.Net.ConsoleApplication
|
||||
{
|
||||
BodyData = new BodyData
|
||||
{
|
||||
BodyAsString = "random200or505:" + code + ", HeadersFromRequest = " + string.Join(",", request.Headers),
|
||||
BodyAsString = "random200or505:" + code + ", HeadersFromRequest = " + request.Headers != null ? string.Join(",", request.Headers!.Select(h => $"{h.Key}:{h.Value}")) : "none",
|
||||
DetectedBodyType = BodyType.String,
|
||||
},
|
||||
StatusCode = code
|
||||
+2
-5
@@ -1,19 +1,16 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using log4net;
|
||||
using log4net.Config;
|
||||
using log4net.Repository;
|
||||
using WireMock.Net.ConsoleApplication;
|
||||
|
||||
namespace WireMock.Net.Console.NET8;
|
||||
namespace WireMock.Net.Console;
|
||||
|
||||
static class Program
|
||||
{
|
||||
private static readonly ILoggerRepository LogRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(Program));
|
||||
private static readonly ILoggerRepository LogRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()!);
|
||||
|
||||
static async Task Main(params string[] args)
|
||||
{
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<!--<DefineConstants>$(DefineConstants);GRAPHQL;MIMEKIT;PROTOBUF</DefineConstants>-->
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||
<PackageReference Include="log4net" Version="3.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="log4net" Version="3.5.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
@@ -16,7 +16,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="WireMock.Net" Version="2.10.0" />
|
||||
<PackageReference Include="WireMock.Net" Version="2.15.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,7 +1,5 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
|
||||
|
||||
+3
-5
@@ -1,20 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.OpenApi.YamlReader" Version="3.7.0" />
|
||||
|
||||
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\..\src\WireMock.Net.OpenApiParser\WireMock.Net.OpenApiParser.csproj" />
|
||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="3.7.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="3.10.2" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -36,12 +36,6 @@
|
||||
<StartupObject>Wiremock.Net.Service.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SimMetrics.Net, Version=1.0.5.0, Culture=neutral, PublicKeyToken=c58dc06d59f3391b, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
@@ -91,13 +85,13 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="log4net">
|
||||
<Version>3.3.0</Version>
|
||||
<Version>3.3.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Core">
|
||||
<Version>2.3.9</Version>
|
||||
<Version>2.3.11</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="WireMock.Net">
|
||||
<Version>2.10.0</Version>
|
||||
<Version>2.12.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<!--<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>-->
|
||||
<StartupObject>WireMock.Net.WebApplication.Program</StartupObject>
|
||||
<AssemblyName>WireMock.Net.WebApplication</AssemblyName>
|
||||
@@ -10,10 +10,6 @@
|
||||
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -4,7 +4,7 @@ This project demonstrates all the WebSocket capabilities of WireMock.Net.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- .NET 8.0 SDK
|
||||
- .NET 10.0 SDK
|
||||
- Optional: `wscat` for manual testing (`npm install -g wscat`)
|
||||
|
||||
## Running the Examples
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<AssemblyName>WireMock.Net.WebSocketExamples</AssemblyName>
|
||||
<RootNamespace>WireMock.Net.WebSocketExamples</RootNamespace>
|
||||
</PropertyGroup>
|
||||
@@ -12,7 +12,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
|
||||
<UserSecretsId>bb7d8355-68c4-4f81-8c2d-6cdd80cd7602</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
namespace WireMock.Admin.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// NearMiss Model: a mapping which did not (fully) match a request.
|
||||
/// </summary>
|
||||
public class NearMissModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The unique identifier of the log entry for the request. [Optional]
|
||||
/// </summary>
|
||||
public Guid? LogEntryGuid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The request.
|
||||
/// </summary>
|
||||
public LogRequestModel? Request { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The unique identifier of the mapping.
|
||||
/// </summary>
|
||||
public Guid MappingGuid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The title of the mapping.
|
||||
/// </summary>
|
||||
public string? MappingTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The request match result, containing the score per matcher.
|
||||
/// </summary>
|
||||
public LogRequestMatchModel? RequestMatchResult { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
namespace WireMock.Admin.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// RequestCount Model
|
||||
/// </summary>
|
||||
public class RequestCountModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of requests which match the criteria.
|
||||
/// </summary>
|
||||
public int Count { get; set; }
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public interface IRequestMessage
|
||||
string? ProxyUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DateTime.
|
||||
/// The DateTime when this request was done.
|
||||
/// </summary>
|
||||
DateTime DateTime { get; }
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public interface IResponseMessage
|
||||
object? StatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DateTime.
|
||||
/// The DateTime when this response was sent.
|
||||
/// </summary>
|
||||
DateTime DateTime { get; }
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
namespace WireMock.Matchers.Request;
|
||||
|
||||
/// <summary>
|
||||
/// A mapping which did not (fully) match a request, together with the match result explaining why.
|
||||
/// </summary>
|
||||
public class NearMiss
|
||||
{
|
||||
/// <summary>
|
||||
/// The request which was evaluated against the mapping.
|
||||
/// </summary>
|
||||
public required IRequestMessage RequestMessage { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The unique identifier of the log entry for the request. [Optional]
|
||||
/// </summary>
|
||||
public Guid? LogEntryGuid { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The unique identifier of the mapping.
|
||||
/// </summary>
|
||||
public required Guid MappingGuid { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The title of the mapping. [Optional]
|
||||
/// </summary>
|
||||
public string? MappingTitle { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The match result, containing the score per matcher.
|
||||
/// </summary>
|
||||
public required IRequestMatchResult RequestMatchResult { get; init; }
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public interface IBodyData
|
||||
/// <summary>
|
||||
/// The body as Form UrlEncoded dictionary.
|
||||
/// </summary>
|
||||
IDictionary<string, string>? BodyAsFormUrlEncoded { get; set; }
|
||||
IDictionary<string, WireMockList<string>>? BodyAsFormUrlEncoded { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The detected body type (detection based on body content).
|
||||
|
||||
@@ -107,6 +107,39 @@ public interface IWireMockServer : IDisposable
|
||||
/// <returns>The <see cref="IReadOnlyList{ILogEntry}"/>.</returns>
|
||||
IReadOnlyList<ILogEntry> FindLogEntries(params IRequestMatcher[] matchers);
|
||||
|
||||
/// <summary>
|
||||
/// Get the log-entries for the requests which did not fully match any mapping.
|
||||
/// This includes the requests which were served by a partial match when AllowPartialMapping is enabled.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="IReadOnlyList{ILogEntry}"/>.</returns>
|
||||
IReadOnlyList<ILogEntry> FindUnmatchedLogEntries();
|
||||
|
||||
/// <summary>
|
||||
/// Find the mappings which partially match the request (the near misses), ordered by best match first.
|
||||
/// Perfect matches and mappings which do not match at all are excluded.
|
||||
/// Use this to find out why a request did not match the expected mapping.
|
||||
/// </summary>
|
||||
/// <param name="requestMessage">The request to evaluate.</param>
|
||||
/// <param name="maxResults">The maximum number of near misses to return. Default is 3.</param>
|
||||
/// <returns>The <see cref="IReadOnlyList{NearMiss}"/>.</returns>
|
||||
IReadOnlyList<NearMiss> FindNearMisses(IRequestMessage requestMessage, int maxResults = 3);
|
||||
|
||||
/// <summary>
|
||||
/// Find the mappings which partially match the request of a log-entry (the near misses), ordered by best match first.
|
||||
/// Perfect matches and mappings which do not match at all are excluded.
|
||||
/// </summary>
|
||||
/// <param name="logEntry">The log-entry for which to evaluate the request.</param>
|
||||
/// <param name="maxResults">The maximum number of near misses to return. Default is 3.</param>
|
||||
/// <returns>The <see cref="IReadOnlyList{NearMiss}"/>.</returns>
|
||||
IReadOnlyList<NearMiss> FindNearMisses(ILogEntry logEntry, int maxResults = 3);
|
||||
|
||||
/// <summary>
|
||||
/// Find the near misses for all requests which did not fully match any mapping.
|
||||
/// </summary>
|
||||
/// <param name="maxResultsPerRequest">The maximum number of near misses to return per request. Default is 3.</param>
|
||||
/// <returns>The <see cref="IReadOnlyList{NearMiss}"/>.</returns>
|
||||
IReadOnlyList<NearMiss> FindNearMissesForUnmatchedRequests(int maxResultsPerRequest = 3);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a static mapping file and adds or updates a single mapping.
|
||||
///
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace WireMock.Types;
|
||||
|
||||
/// <summary>
|
||||
/// A special List which overrides the ToString() to return first value.
|
||||
/// A special List which overrides the ToString() to return first value in case of a single element.
|
||||
/// Else it will return a comma separated list of all values.
|
||||
/// If null or empty, it will return an empty string.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The generic type</typeparam>
|
||||
/// <seealso cref="List{T}" />
|
||||
@@ -46,6 +46,98 @@ public class WireMockList<T> : List<T>
|
||||
/// <param name="values">The values to set.</param>
|
||||
public static implicit operator WireMockList<T>(T[] values) => new(values);
|
||||
|
||||
/// <summary>
|
||||
/// Operator for equality comparison from WireMockList to T
|
||||
/// </summary>
|
||||
public static bool operator ==(WireMockList<T>? left, T? right)
|
||||
{
|
||||
if (ReferenceEquals(left, right))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (left?.Count == 1 && Equals(left[0], right))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operator for equality comparison from T to WireMockList
|
||||
/// </summary>
|
||||
public static bool operator ==(T? left, WireMockList<T>? right)
|
||||
{
|
||||
if (ReferenceEquals(left, right))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (right?.Count == 1 && Equals(left, right[0]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operator for inequality comparison from WireMockList to T
|
||||
/// </summary>
|
||||
public static bool operator !=(WireMockList<T>? left, T? right) => !(left == right);
|
||||
|
||||
/// <summary>
|
||||
/// Operator for inequality comparison from T to WireMockList
|
||||
/// </summary>
|
||||
public static bool operator !=(T? left, WireMockList<T>? right) => !(left == right);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified object is equal to the current instance.
|
||||
/// Two <see cref="WireMockList{T}"/> instances are equal if they contain the same elements in the same order.
|
||||
/// </summary>
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(this, obj))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj is WireMockList<T> other)
|
||||
{
|
||||
if (Count != other.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < Count; i++)
|
||||
{
|
||||
if (!Equals(this[i], other[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hash code for this instance based on its elements.
|
||||
/// </summary>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
var hashCode = 17;
|
||||
foreach (var item in this)
|
||||
{
|
||||
hashCode = hashCode * 31 + (item?.GetHashCode() ?? 0);
|
||||
}
|
||||
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="string" /> that represents this instance.
|
||||
/// </summary>
|
||||
@@ -62,10 +154,10 @@ public class WireMockList<T> : List<T>
|
||||
return strValue;
|
||||
}
|
||||
|
||||
return this[0]?.ToString();
|
||||
return this[0]?.ToString() ?? string.Empty;
|
||||
|
||||
default:
|
||||
var strings = this.Select(x => x as string ?? x?.ToString());
|
||||
var strings = this.Select(x => x as string ?? x?.ToString() ?? string.Empty);
|
||||
return string.Join(", ", strings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<Description>Commonly used interfaces, models, enumerations and types.</Description>
|
||||
<AssemblyTitle>WireMock.Net.Abstractions</AssemblyTitle>
|
||||
<Authors>Stef Heyenrath</Authors>
|
||||
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591;8603</NoWarn>
|
||||
<AssemblyName>WireMock.Net.Abstractions</AssemblyName>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Description>Middleware which can be used to host WireMock.Net as a Middleware background process in a AspNetCore WebApplication</Description>
|
||||
<AssemblyTitle>WireMock.Net.AspNetCore.Middleware</AssemblyTitle>
|
||||
<Authors>Matthew Yost;Stef Heyenrath</Authors>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<AssemblyName>WireMock.Net.AspNetCore.Middleware</AssemblyName>
|
||||
<PackageId>WireMock.Net.AspNetCore.Middleware</PackageId>
|
||||
@@ -31,7 +31,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" Condition=" '$(TargetFramework)' != 'net10.0' " />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.14" Condition=" '$(TargetFramework)' == 'net10.0' " />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Description>Aspire extension to start a WireMock.Net server to stub an api.</Description>
|
||||
<AssemblyTitle>WireMock.Net.Aspire</AssemblyTitle>
|
||||
<Authors>Stef Heyenrath</Authors>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<AssemblyName>WireMock.Net.Aspire</AssemblyName>
|
||||
<PackageId>WireMock.Net.Aspire</PackageId>
|
||||
@@ -22,6 +22,7 @@
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageIcon>WireMock.Net-LogoAspire.png</PackageIcon>
|
||||
<ApplicationIcon>../../resources/WireMock.Net-LogoAspire.ico</ApplicationIcon>
|
||||
<AspireUseCliBundle>true</AspireUseCliBundle>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -45,10 +46,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting" Version="13.4.3" />
|
||||
|
||||
<!-- CVE-2026-48109 -->
|
||||
<PackageReference Include="MessagePack" Version="2.5.302" />
|
||||
<PackageReference Include="Aspire.Hosting" Version="13.6.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AwesomeAssertions" Version="9.4.0" />
|
||||
<PackageReference Include="AwesomeAssertions" Version="9.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -71,7 +71,7 @@ This leads to more maintainable, scalable, and production-like test code.
|
||||
- Asynchronous handlers
|
||||
- Fluent, composable routing extensions
|
||||
- Easy integration with existing WireMock.Net servers
|
||||
- .NET 8+ support
|
||||
- .NET 8 and .NET 10 support
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<Description>WireMock.Net.Routing extends WireMock.Net with modern, minimal-API-style routing for .NET</Description>
|
||||
<Authors>Gennadii Saltyshchak</Authors>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>tdd;mock;http;wiremock;test;server;unittest;routing;minimalapi</PackageTags>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>GraphQL support for WireMock.Net</Description>
|
||||
<AssemblyTitle>WireMock.Net.Matchers.GraphQL</AssemblyTitle>
|
||||
<Authors>Stef Heyenrath</Authors>
|
||||
<TargetFrameworks>net462;netstandard2.1;net8.0</TargetFrameworks>
|
||||
<TargetFrameworks>net462;netstandard2.1;net8.0;net10.0</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>wiremock;matchers;matcher;graphql</PackageTags>
|
||||
<RootNamespace>WireMock</RootNamespace>
|
||||
|
||||
@@ -70,7 +70,7 @@ public class CSharpCodeMatcher : ICSharpCodeMatcher
|
||||
/// <inheritdoc />
|
||||
public string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(CSharpCodeMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{MatchOperator.GetFullyQualifiedEnumValue()}, " +
|
||||
|
||||
@@ -126,7 +126,7 @@ public class SystemTextJsonPathMatcher : ISystemTextJsonPathMatcher
|
||||
/// <inheritdoc />
|
||||
public string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(SystemTextJsonPathMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{MatchOperator.GetFullyQualifiedEnumValue()}, " +
|
||||
|
||||
+5
-4
@@ -1,10 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>A SystemTextJsonPathMatcher which can be used to match WireMock.Net Requests using JsonPath.Net.</Description>
|
||||
<AssemblyTitle>WireMock.Net.Matchers.SystemTextJsonPath</AssemblyTitle>
|
||||
<Authors>Stef Heyenrath</Authors>
|
||||
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>wiremock;matchers;matcher;jsonpath;systemtextjson</PackageTags>
|
||||
<RootNamespace>WireMock</RootNamespace>
|
||||
@@ -35,7 +35,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JsonPath.Net" Version="3.0.2" />
|
||||
<!-- Downgraded from 3.0.2 to 2.2.0 to avoid Open Source Maintenance Fee issues -->
|
||||
<PackageReference Include="JsonPath.Net" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,10 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>MultiPart Mime support for WireMock.Net using MimeKitLite</Description>
|
||||
<AssemblyTitle>WireMock.Net.MimePart</AssemblyTitle>
|
||||
<Authors>Stef Heyenrath</Authors>
|
||||
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageTags>wiremock;matchers;matcher;mime;multipart;mimekit</PackageTags>
|
||||
<RootNamespace>WireMock</RootNamespace>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace WireMock.Extensions;
|
||||
|
||||
internal static class HttpContextExtensions
|
||||
{
|
||||
internal static bool TryGet<T>(this HttpContext httpContext, [NotNullWhen(true)] out T? value)
|
||||
{
|
||||
return httpContext.Items.TryGetValue(nameof(T), out value);
|
||||
}
|
||||
}
|
||||
@@ -80,10 +80,10 @@ public class ContentTypeMatcher : WildcardMatcher
|
||||
/// <inheritdoc />
|
||||
public override string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(ContentTypeMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{MappingConverterUtils.ToCSharpCodeArguments(_patterns)}, " +
|
||||
$"new AnyOfTypes.AnyOf<string, WireMock.Models.StringPattern>[] {{ {MappingConverterUtils.ToCSharpCodeArguments(_patterns)} }}, " +
|
||||
$"{CSharpFormatter.ToCSharpBooleanLiteral(IgnoreCase)}" +
|
||||
$")";
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ExactMatcher : IStringMatcher, IIgnoreCaseMatcher
|
||||
/// <inheritdoc />
|
||||
public string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(ExactMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{CSharpFormatter.ToCSharpBooleanLiteral(IgnoreCase)}, " +
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Linq;
|
||||
using AnyOfTypes;
|
||||
using Stef.Validation;
|
||||
using WireMock.Extensions;
|
||||
using WireMock.Models;
|
||||
using WireMock.Types;
|
||||
using WireMock.Util;
|
||||
|
||||
namespace WireMock.Matchers;
|
||||
@@ -21,7 +21,7 @@ public class FormUrlEncodedMatcher : IStringMatcher, IIgnoreCaseMatcher
|
||||
/// <inheritdoc />
|
||||
public MatchBehaviour MatchBehaviour { get; }
|
||||
|
||||
private readonly List<(WildcardMatcher Key, WildcardMatcher? Value)> _pairs = [];
|
||||
private readonly List<(WildcardMatcher Key, WildcardMatcher[]? Values)> KeyValueMatchers = [];
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FormUrlEncodedMatcher"/> class.
|
||||
@@ -91,9 +91,10 @@ public class FormUrlEncodedMatcher : IStringMatcher, IIgnoreCaseMatcher
|
||||
{
|
||||
foreach (var nameValue in nameValueCollection)
|
||||
{
|
||||
var keyMatcher = new WildcardMatcher(MatchBehaviour.AcceptOnMatch, [nameValue.Key], ignoreCase, MatchOperator);
|
||||
var valueMatcher = new WildcardMatcher(MatchBehaviour.AcceptOnMatch, [nameValue.Value], ignoreCase, MatchOperator);
|
||||
_pairs.Add((keyMatcher, valueMatcher));
|
||||
var keyMatcher = new WildcardMatcher(MatchBehaviour.AcceptOnMatch, nameValue.Key, ignoreCase);
|
||||
var valueMatchers = nameValue.Value.Select(value => new WildcardMatcher(MatchBehaviour.AcceptOnMatch, value, ignoreCase)).ToArray();
|
||||
|
||||
KeyValueMatchers.Add((keyMatcher, valueMatchers));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,34 +120,48 @@ public class FormUrlEncodedMatcher : IStringMatcher, IIgnoreCaseMatcher
|
||||
return MatchResult.From(Name, MatchBehaviourHelper.Convert(MatchBehaviour, score));
|
||||
}
|
||||
|
||||
private bool[] GetMatches(IDictionary<string, string> inputNameValueCollection)
|
||||
private List<double> GetMatches(IDictionary<string, WireMockList<string>> inputNameValueCollection)
|
||||
{
|
||||
var matches = new List<bool>();
|
||||
if (_pairs.Count > inputNameValueCollection.Count)
|
||||
var inputPairs = inputNameValueCollection.ToArray();
|
||||
var rowCount = inputPairs.Length;
|
||||
var columnCount = KeyValueMatchers.Count;
|
||||
|
||||
if (rowCount == 0 && columnCount == 0)
|
||||
{
|
||||
matches.AddRange(Enumerable.Repeat(false, _pairs.Count - inputNameValueCollection.Count));
|
||||
return [];
|
||||
}
|
||||
|
||||
foreach (var inputKeyValuePair in inputNameValueCollection)
|
||||
var matrix = new double[rowCount][];
|
||||
|
||||
for (var row = 0; row < rowCount; row++)
|
||||
{
|
||||
var match = false;
|
||||
foreach (var pair in _pairs)
|
||||
matrix[row] = new double[columnCount];
|
||||
|
||||
var inputKeyValuePair = inputPairs[row];
|
||||
var inputKey = inputKeyValuePair.Key;
|
||||
var inputValues = inputKeyValuePair.Value;
|
||||
|
||||
for (var column = 0; column < columnCount; column++)
|
||||
{
|
||||
var keyMatchResult = pair.Key.IsMatch(inputKeyValuePair.Key).IsPerfect();
|
||||
if (keyMatchResult)
|
||||
{
|
||||
match = pair.Value?.IsMatch(inputKeyValuePair.Value).IsPerfect() ?? false;
|
||||
if (match)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var (keyMatcher, valuesMatchers) = KeyValueMatchers[column];
|
||||
|
||||
matches.Add(match);
|
||||
var keyScore = keyMatcher.IsMatch(inputKey).Score;
|
||||
var valueScore = valuesMatchers != null ? MatchScores.ToScore(inputValues, valuesMatchers) : MatchScores.Perfect;
|
||||
|
||||
matrix[row][column] = Math.Min(keyScore, valueScore);
|
||||
}
|
||||
}
|
||||
|
||||
return matches.ToArray();
|
||||
var rowScores = rowCount == 0 ? [] : matrix.Select(row => row.Length == 0 ? MatchScores.Mismatch : row.Max()).ToList();
|
||||
|
||||
var columnScores = new List<double>();
|
||||
for (var column = 0; column < columnCount; column++)
|
||||
{
|
||||
columnScores.Add(rowCount == 0 ? MatchScores.Mismatch : matrix.Max(row => row[column]));
|
||||
}
|
||||
|
||||
rowScores.AddRange(columnScores);
|
||||
return rowScores;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -167,10 +182,10 @@ public class FormUrlEncodedMatcher : IStringMatcher, IIgnoreCaseMatcher
|
||||
/// <inheritdoc />
|
||||
public string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(FormUrlEncodedMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{MappingConverterUtils.ToCSharpCodeArguments(_patterns)}, " +
|
||||
$"new AnyOfTypes.AnyOf<string, WireMock.Models.StringPattern>[] {{ {MappingConverterUtils.ToCSharpCodeArguments(_patterns)} }}, " +
|
||||
$"{CSharpFormatter.ToCSharpBooleanLiteral(IgnoreCase)}, " +
|
||||
$"{MatchOperator.GetFullyQualifiedEnumValue()}" +
|
||||
$")";
|
||||
|
||||
@@ -76,7 +76,7 @@ public class FuncMatcher : IFuncMatcher
|
||||
public string GetCSharpCodeArguments()
|
||||
{
|
||||
var funcType = _stringFunc != null ? "Func<string?, bool>" : "Func<byte[]?, bool>";
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(FuncMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"/* {funcType} function */, " +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}" +
|
||||
|
||||
@@ -119,7 +119,7 @@ public class JsonPathMatcher : IJsonPathMatcher
|
||||
/// <inheritdoc />
|
||||
public string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(JsonPathMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{MatchOperator.GetFullyQualifiedEnumValue()}, " +
|
||||
|
||||
@@ -119,7 +119,7 @@ public class JmesPathMatcher : IStringMatcher, IObjectMatcher
|
||||
/// <inheritdoc />
|
||||
public string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(JmesPathMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{MatchOperator.GetFullyQualifiedEnumValue()}, " +
|
||||
|
||||
@@ -110,7 +110,7 @@ public class JsonMatcher : IJsonMatcher
|
||||
/// <inheritdoc />
|
||||
public virtual string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(JsonMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{CSharpFormatter.ConvertToAnonymousObjectDefinition(Value, 3)}, " +
|
||||
|
||||
@@ -41,7 +41,7 @@ public class JsonPartialMatcher : AbstractJsonPartialMatcher
|
||||
/// <inheritdoc />
|
||||
public override string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(JsonPartialMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{CSharpFormatter.ConvertToAnonymousObjectDefinition(Value, 3)}, " +
|
||||
|
||||
@@ -41,7 +41,7 @@ public class JsonPartialWildcardMatcher : AbstractJsonPartialMatcher
|
||||
/// <inheritdoc />
|
||||
public override string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(JsonPartialWildcardMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{CSharpFormatter.ConvertToAnonymousObjectDefinition(Value, 3)}, " +
|
||||
|
||||
@@ -141,7 +141,7 @@ public class LinqMatcher : IObjectMatcher, IStringMatcher
|
||||
/// <inheritdoc />
|
||||
public string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(LinqMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{MatchOperator.GetFullyQualifiedEnumValue()}, " +
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
using Stef.Validation;
|
||||
using WireMock.Matchers.Helpers;
|
||||
using WireMock.Types;
|
||||
using WireMock.Util;
|
||||
|
||||
namespace WireMock.Matchers.Request;
|
||||
@@ -34,7 +35,7 @@ public class RequestMessageBodyMatcher : IRequestMatcher
|
||||
/// <summary>
|
||||
/// The body data function for FormUrlEncoded
|
||||
/// </summary>
|
||||
public Func<IDictionary<string, string>?, bool>? MatchOnBodyAsFormUrlEncodedFunc { get; }
|
||||
public Func<IDictionary<string, WireMockList<string>>?, bool>? MatchOnBodyAsFormUrlEncodedFunc { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The matchers.
|
||||
@@ -116,7 +117,7 @@ public class RequestMessageBodyMatcher : IRequestMatcher
|
||||
/// Initializes a new instance of the <see cref="RequestMessageBodyMatcher"/> class.
|
||||
/// </summary>
|
||||
/// <param name="func">The function.</param>
|
||||
public RequestMessageBodyMatcher(Func<IDictionary<string, string>?, bool> func)
|
||||
public RequestMessageBodyMatcher(Func<IDictionary<string, WireMockList<string>>?, bool> func)
|
||||
{
|
||||
MatchOnBodyAsFormUrlEncodedFunc = Guard.NotNull(func);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Linq;
|
||||
using Stef.Validation;
|
||||
using WireMock.Types;
|
||||
|
||||
@@ -54,7 +53,10 @@ public class RequestMessageParamMatcher : IRequestMatcher
|
||||
/// <param name="ignoreCase">Defines if the key should be matched using case-ignore.</param>
|
||||
/// <param name="values">The values.</param>
|
||||
public RequestMessageParamMatcher(MatchBehaviour matchBehaviour, string key, bool ignoreCase, params string[]? values) :
|
||||
this(matchBehaviour, key, ignoreCase, values?.Select(value => new ExactMatcher(matchBehaviour, ignoreCase, MatchOperator.And, value)).Cast<IStringMatcher>().ToArray())
|
||||
// Note: the inner ExactMatcher must use AcceptOnMatch.
|
||||
// The MatchBehaviour (e.g. RejectOnMatch) is applied once by this matcher's GetMatchingScore.
|
||||
// Passing matchBehaviour here as well would apply the conversion twice and invert RejectOnMatch.
|
||||
this(matchBehaviour, key, ignoreCase, values?.Select(value => new ExactMatcher(MatchBehaviour.AcceptOnMatch, ignoreCase, MatchOperator.And, value)).Cast<IStringMatcher>().ToArray())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -113,36 +115,6 @@ public class RequestMessageParamMatcher : IRequestMatcher
|
||||
}
|
||||
|
||||
// Return the score based on Matchers and valuesPresentInRequestMessage
|
||||
return CalculateScore(Matchers, valuesPresentInRequestMessage);
|
||||
}
|
||||
|
||||
private static double CalculateScore(IReadOnlyList<IStringMatcher> matchers, WireMockList<string> valuesPresentInRequestMessage)
|
||||
{
|
||||
var total = new List<double>();
|
||||
|
||||
// If the total patterns in all matchers > values in message, use the matcher as base
|
||||
if (matchers.Sum(m => m.GetPatterns().Length) > valuesPresentInRequestMessage.Count)
|
||||
{
|
||||
foreach (var matcher in matchers)
|
||||
{
|
||||
double score = 0d;
|
||||
foreach (string valuePresentInRequestMessage in valuesPresentInRequestMessage)
|
||||
{
|
||||
score += matcher.IsMatch(valuePresentInRequestMessage).Score / matcher.GetPatterns().Length;
|
||||
}
|
||||
|
||||
total.Add(score);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string valuePresentInRequestMessage in valuesPresentInRequestMessage)
|
||||
{
|
||||
var score = matchers.Max(m => m.IsMatch(valuePresentInRequestMessage).Score);
|
||||
total.Add(score);
|
||||
}
|
||||
}
|
||||
|
||||
return total.Any() ? MatchScores.ToScore(total, MatchOperator.Average) : 0;
|
||||
return MatchScores.ToScore(valuesPresentInRequestMessage, Matchers.ToArray());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Linq;
|
||||
using AnyOfTypes;
|
||||
using SimMetrics.Net;
|
||||
using SimMetrics.Net.API;
|
||||
@@ -92,10 +91,10 @@ public class SimMetricsMatcher : IStringMatcher
|
||||
/// <inheritdoc />
|
||||
public virtual string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(SimMetricsMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{MappingConverterUtils.ToCSharpCodeArguments(_patterns)}, " +
|
||||
$"new AnyOfTypes.AnyOf<string, WireMock.Models.StringPattern>[] {{ {MappingConverterUtils.ToCSharpCodeArguments(_patterns)} }}, " +
|
||||
$"{_simMetricType.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{MatchOperator.GetFullyQualifiedEnumValue()}" +
|
||||
$")";
|
||||
|
||||
@@ -115,7 +115,7 @@ public class SystemTextJsonMatcher : IJsonMatcher
|
||||
/// <inheritdoc />
|
||||
public virtual string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(SystemTextJsonMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{CSharpFormatter.ConvertToAnonymousObjectDefinition(Value, 3)}, " +
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SystemTextJsonPartialMatcher : AbstractSystemTextJsonPartialMatcher
|
||||
/// <inheritdoc />
|
||||
public override string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(SystemTextJsonPartialMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{CSharpFormatter.ConvertToAnonymousObjectDefinition(Value, 3)}, " +
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SystemTextJsonPartialWildcardMatcher : AbstractSystemTextJsonPartia
|
||||
/// <inheritdoc />
|
||||
public override string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(SystemTextJsonPartialWildcardMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{CSharpFormatter.ConvertToAnonymousObjectDefinition(Value, 3)}, " +
|
||||
|
||||
@@ -101,7 +101,7 @@ public class XPathMatcher : IStringMatcher
|
||||
/// <inheritdoc />
|
||||
public string GetCSharpCodeArguments()
|
||||
{
|
||||
return $"new {Name}" +
|
||||
return $"new {typeof(XPathMatcher).FullName}" +
|
||||
$"(" +
|
||||
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
|
||||
$"{MatchOperator.GetFullyQualifiedEnumValue()}, " +
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
using WireMock.Matchers;
|
||||
|
||||
namespace WireMock.Owin;
|
||||
|
||||
internal sealed class AdminPaths(string? adminPath) : IAdminPaths
|
||||
{
|
||||
private const string DefaultAdminPathPrefix = "/__admin";
|
||||
|
||||
private readonly string _prefix = adminPath ?? DefaultAdminPathPrefix;
|
||||
|
||||
public string Files => $"{_prefix}/files";
|
||||
|
||||
public string Health => $"{_prefix}/health";
|
||||
|
||||
public string Mappings => $"{_prefix}/mappings";
|
||||
|
||||
public string MappingsCode => $"{_prefix}/mappings/code";
|
||||
|
||||
public string MappingsWireMockOrg => $"{_prefix}/mappings/wiremock.org";
|
||||
|
||||
public string Requests => $"{_prefix}/requests";
|
||||
|
||||
public string Settings => $"{_prefix}/settings";
|
||||
|
||||
public string Scenarios => $"{_prefix}/scenarios";
|
||||
|
||||
public string OpenApi => $"{_prefix}/openapi";
|
||||
|
||||
public string ProtoDefinitions => $"{_prefix}/protodefinitions";
|
||||
|
||||
private string PrefixRegexEscaped => Regex.Escape(_prefix);
|
||||
|
||||
public RegexMatcher MappingsGuidPathMatcher => new($@"^{PrefixRegexEscaped}\/mappings\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})$");
|
||||
|
||||
public RegexMatcher MappingsGuidEnablePathMatcher => new($@"^{PrefixRegexEscaped}\/mappings\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})\/enable$");
|
||||
|
||||
public RegexMatcher MappingsGuidDisablePathMatcher => new($@"^{PrefixRegexEscaped}\/mappings\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})\/disable$");
|
||||
|
||||
public RegexMatcher MappingsCodeGuidPathMatcher => new($@"^{PrefixRegexEscaped}\/mappings\/code\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})$");
|
||||
|
||||
public RegexMatcher RequestsGuidPathMatcher => new($@"^{PrefixRegexEscaped}\/requests\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})$");
|
||||
|
||||
public RegexMatcher RequestsGuidNearMissesPathMatcher => new($@"^{PrefixRegexEscaped}\/requests\/([0-9A-Fa-f]{{8}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{4}}[-][0-9A-Fa-f]{{12}})\/near-misses$");
|
||||
|
||||
public RegexMatcher ScenariosNameMatcher => new($@"^{PrefixRegexEscaped}\/scenarios\/.+$");
|
||||
|
||||
public RegexMatcher ScenariosNameWithStateMatcher => new($@"^{PrefixRegexEscaped}\/scenarios\/.+\/state$");
|
||||
|
||||
public RegexMatcher ScenariosNameWithResetMatcher => new($@"^{PrefixRegexEscaped}\/scenarios\/.+\/reset$");
|
||||
|
||||
public RegexMatcher FilesFilenamePathMatcher => new($@"^{PrefixRegexEscaped}\/files\/.+$");
|
||||
|
||||
public RegexMatcher ProtoDefinitionsIdPathMatcher => new($@"^{PrefixRegexEscaped}\/protodefinitions\/.+$");
|
||||
|
||||
public bool Includes(string? path) => path?.StartsWith($"{_prefix}/") ?? false;
|
||||
|
||||
public override string ToString() => _prefix;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright © WireMock.Net
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
#if NET8_0
|
||||
#if NET8_0_OR_GREATER
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using WireMock.Types;
|
||||
|
||||
@@ -11,6 +11,11 @@ using WireMock.Serialization;
|
||||
using WireMock.Services;
|
||||
using WireMock.Util;
|
||||
|
||||
#if NET10_0
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
#endif
|
||||
|
||||
namespace WireMock.Owin;
|
||||
|
||||
internal partial class AspNetCoreSelfHost
|
||||
@@ -20,7 +25,11 @@ internal partial class AspNetCoreSelfHost
|
||||
private readonly IWireMockLogger _logger;
|
||||
private readonly HostUrlOptions _urlOptions;
|
||||
|
||||
#if NET10_0
|
||||
private Microsoft.Extensions.Hosting.IHost _host = null!;
|
||||
#else
|
||||
private IWebHost _host = null!;
|
||||
#endif
|
||||
|
||||
public bool IsStarted { get; private set; }
|
||||
|
||||
@@ -43,6 +52,36 @@ internal partial class AspNetCoreSelfHost
|
||||
|
||||
public Task StartAsync()
|
||||
{
|
||||
#if NET10_0
|
||||
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
|
||||
{
|
||||
// Workaround for https://github.com/wiremock/WireMock.Net/issues/292
|
||||
// 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
|
||||
// a filesystem handler).
|
||||
ContentRootPath = string.IsNullOrEmpty(AppContext.BaseDirectory) ? Directory.GetCurrentDirectory() : null
|
||||
});
|
||||
|
||||
builder.Configuration.Sources.Clear();
|
||||
builder.Configuration.AddEnvironmentVariables();
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Logging.AddProvider(new WireMockAspNetCoreLoggerProvider(_logger));
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Warning);
|
||||
builder.Services.Configure<KestrelServerOptions>(builder.Configuration.GetSection("Kestrel"));
|
||||
|
||||
// The default ConsoleLifetime cancels Ctrl+C and shuts down the host itself, which prevents the consuming application from controlling the process lifetime.
|
||||
builder.Services.AddSingleton<Microsoft.Extensions.Hosting.IHostLifetime, NoopHostLifetime>();
|
||||
ConfigureServices(builder.Services);
|
||||
builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
SetKestrelOptionsLimits(options);
|
||||
SetHttpsAndUrls(options, _wireMockMiddlewareOptions, _urlOptions.GetDetails());
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
ConfigureApplication(app);
|
||||
_host = app;
|
||||
#else
|
||||
var builder = new WebHostBuilder();
|
||||
|
||||
// Workaround for https://github.com/wiremock/WireMock.Net/issues/292
|
||||
@@ -63,57 +102,71 @@ internal partial class AspNetCoreSelfHost
|
||||
logging.AddProvider(new WireMockAspNetCoreLoggerProvider(_logger));
|
||||
logging.SetMinimumLevel(LogLevel.Warning);
|
||||
})
|
||||
.ConfigureServices(services =>
|
||||
{
|
||||
services.AddSingleton(_wireMockMiddlewareOptions);
|
||||
services.AddSingleton<IMappingMatcher, MappingMatcher>();
|
||||
services.AddSingleton<IRandomizerDoubleBetween0And1, RandomizerDoubleBetween0And1>();
|
||||
services.AddSingleton<IOwinRequestMapper, OwinRequestMapper>();
|
||||
services.AddSingleton<IOwinResponseMapper, OwinResponseMapper>();
|
||||
services.AddSingleton<IGuidUtils, GuidUtils>();
|
||||
services.AddSingleton<IDateTimeUtils, DateTimeUtils>();
|
||||
services.AddSingleton<IResponseMessageBuilder, ResponseMessageBuilder>();
|
||||
services.AddSingleton<LogEntryMapper>();
|
||||
services.AddSingleton<IWireMockMiddlewareLogger, WireMockMiddlewareLogger>();
|
||||
|
||||
#if NET8_0_OR_GREATER
|
||||
AddCors(services);
|
||||
#endif
|
||||
_wireMockMiddlewareOptions.AdditionalServiceRegistration?.Invoke(services);
|
||||
})
|
||||
.Configure(appBuilder =>
|
||||
{
|
||||
appBuilder.UseMiddleware<GlobalExceptionMiddleware>();
|
||||
|
||||
#if NET8_0_OR_GREATER
|
||||
UseCors(appBuilder);
|
||||
|
||||
var webSocketOptions = new WebSocketOptions();
|
||||
if (_wireMockMiddlewareOptions.WebSocketSettings?.KeepAliveIntervalSeconds != null)
|
||||
{
|
||||
webSocketOptions.KeepAliveInterval = TimeSpan.FromSeconds(_wireMockMiddlewareOptions.WebSocketSettings.KeepAliveIntervalSeconds);
|
||||
}
|
||||
|
||||
appBuilder.UseWebSockets(webSocketOptions);
|
||||
#endif
|
||||
_wireMockMiddlewareOptions.PreWireMockMiddlewareInit?.Invoke(appBuilder);
|
||||
|
||||
appBuilder.UseMiddleware<WireMockMiddleware>();
|
||||
|
||||
_wireMockMiddlewareOptions.PostWireMockMiddlewareInit?.Invoke(appBuilder);
|
||||
})
|
||||
.ConfigureServices(ConfigureServices)
|
||||
.Configure(ConfigureApplication)
|
||||
.UseKestrel(options =>
|
||||
{
|
||||
SetKestrelOptionsLimits(options);
|
||||
|
||||
SetHttpsAndUrls(options, _wireMockMiddlewareOptions, _urlOptions.GetDetails());
|
||||
})
|
||||
.ConfigureKestrelServerOptions()
|
||||
.Build();
|
||||
#endif
|
||||
|
||||
return RunHost(_cts.Token);
|
||||
}
|
||||
|
||||
#if NET10_0
|
||||
private sealed class NoopHostLifetime : Microsoft.Extensions.Hosting.IHostLifetime
|
||||
{
|
||||
public Task WaitForStartAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
}
|
||||
#endif
|
||||
|
||||
private void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton(_wireMockMiddlewareOptions);
|
||||
services.AddSingleton(_wireMockMiddlewareOptions.AdminPaths);
|
||||
services.AddSingleton<IMappingMatcher, MappingMatcher>();
|
||||
services.AddSingleton<IRandomizerDoubleBetween0And1, RandomizerDoubleBetween0And1>();
|
||||
services.AddSingleton<IOwinRequestMapper, OwinRequestMapper>();
|
||||
services.AddSingleton<IOwinResponseMapper, OwinResponseMapper>();
|
||||
services.AddSingleton<IGuidUtils, GuidUtils>();
|
||||
services.AddSingleton<IDateTimeUtils, DateTimeUtils>();
|
||||
services.AddSingleton<IResponseMessageBuilder, ResponseMessageBuilder>();
|
||||
services.AddSingleton<LogEntryMapper>();
|
||||
services.AddSingleton<IWireMockMiddlewareLogger, WireMockMiddlewareLogger>();
|
||||
|
||||
#if NET8_0_OR_GREATER
|
||||
AddCors(services);
|
||||
#endif
|
||||
_wireMockMiddlewareOptions.AdditionalServiceRegistration?.Invoke(services);
|
||||
}
|
||||
|
||||
private void ConfigureApplication(IApplicationBuilder appBuilder)
|
||||
{
|
||||
appBuilder.UseMiddleware<GlobalExceptionMiddleware>();
|
||||
|
||||
#if NET8_0_OR_GREATER
|
||||
UseCors(appBuilder);
|
||||
|
||||
var webSocketOptions = new WebSocketOptions();
|
||||
if (_wireMockMiddlewareOptions.WebSocketSettings?.KeepAliveIntervalSeconds != null)
|
||||
{
|
||||
webSocketOptions.KeepAliveInterval = TimeSpan.FromSeconds(_wireMockMiddlewareOptions.WebSocketSettings.KeepAliveIntervalSeconds);
|
||||
}
|
||||
|
||||
appBuilder.UseWebSockets(webSocketOptions);
|
||||
#endif
|
||||
_wireMockMiddlewareOptions.PreWireMockMiddlewareInit?.Invoke(appBuilder);
|
||||
|
||||
appBuilder.UseMiddleware<WireMockMiddleware>();
|
||||
|
||||
_wireMockMiddlewareOptions.PostWireMockMiddlewareInit?.Invoke(appBuilder);
|
||||
}
|
||||
|
||||
private Task RunHost(CancellationToken token)
|
||||
{
|
||||
try
|
||||
@@ -125,10 +178,18 @@ internal partial class AspNetCoreSelfHost
|
||||
#endif
|
||||
appLifetime.ApplicationStarted.Register(() =>
|
||||
{
|
||||
#if NET10_0
|
||||
var addresses = _host.Services.GetRequiredService<Microsoft.AspNetCore.Hosting.Server.IServer>()
|
||||
.Features
|
||||
.Get<Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature>()!
|
||||
.Addresses
|
||||
.ToArray();
|
||||
#else
|
||||
var addresses = _host.ServerFeatures
|
||||
.Get<Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature>()!
|
||||
.Addresses
|
||||
.ToArray();
|
||||
#endif
|
||||
|
||||
if (_urlOptions.Urls == null)
|
||||
{
|
||||
@@ -168,13 +229,19 @@ internal partial class AspNetCoreSelfHost
|
||||
IsStarted = true;
|
||||
});
|
||||
|
||||
#if NET8_0
|
||||
#if NET10_0
|
||||
_logger.Info("Server using .NET 10.0");
|
||||
#elif NET8_0
|
||||
_logger.Info("Server using .NET 8.0");
|
||||
#else
|
||||
_logger.Info("Server using .NET Standard 2.0");
|
||||
#endif
|
||||
|
||||
#if NET10_0
|
||||
return Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(_host, token);
|
||||
#else
|
||||
return _host.RunAsync(token);
|
||||
#endif
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using WireMock.Matchers;
|
||||
|
||||
namespace WireMock.Owin;
|
||||
|
||||
internal interface IAdminPaths
|
||||
{
|
||||
string Files { get; }
|
||||
|
||||
string Health { get; }
|
||||
|
||||
string Mappings { get; }
|
||||
|
||||
string MappingsCode { get; }
|
||||
|
||||
string MappingsWireMockOrg { get; }
|
||||
|
||||
RegexMatcher MappingsGuidPathMatcher { get; }
|
||||
|
||||
RegexMatcher MappingsGuidEnablePathMatcher { get; }
|
||||
|
||||
RegexMatcher MappingsGuidDisablePathMatcher { get; }
|
||||
|
||||
RegexMatcher MappingsCodeGuidPathMatcher { get; }
|
||||
|
||||
RegexMatcher RequestsGuidPathMatcher { get; }
|
||||
|
||||
RegexMatcher RequestsGuidNearMissesPathMatcher { get; }
|
||||
|
||||
RegexMatcher ScenariosNameMatcher { get; }
|
||||
|
||||
RegexMatcher ScenariosNameWithStateMatcher { get; }
|
||||
|
||||
RegexMatcher ScenariosNameWithResetMatcher { get; }
|
||||
|
||||
RegexMatcher FilesFilenamePathMatcher { get; }
|
||||
|
||||
RegexMatcher ProtoDefinitionsIdPathMatcher { get; }
|
||||
|
||||
string Requests { get; }
|
||||
|
||||
string Settings { get; }
|
||||
|
||||
string Scenarios { get; }
|
||||
|
||||
string OpenApi { get; }
|
||||
|
||||
string ProtoDefinitions { get; }
|
||||
|
||||
bool Includes(string? path);
|
||||
}
|
||||
@@ -5,4 +5,6 @@ namespace WireMock.Owin;
|
||||
internal interface IMappingMatcher
|
||||
{
|
||||
(MappingMatcherResult? Match, MappingMatcherResult? Partial) FindBestMatch(RequestMessage request);
|
||||
|
||||
IReadOnlyList<MappingMatcherResult> FindNearMisses(IRequestMessage request, int maxResults);
|
||||
}
|
||||
@@ -108,4 +108,6 @@ internal interface IWireMockMiddlewareOptions
|
||||
/// Set this property to customize how objects are serialized to and deserialized from JSON during mapping.
|
||||
/// </remarks>
|
||||
IJsonConverter DefaultJsonSerializer { get; set; }
|
||||
|
||||
IAdminPaths AdminPaths { get; set; }
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace WireMock.Owin.Mappers;
|
||||
/// <summary>
|
||||
/// OwinRequestMapper
|
||||
/// </summary>
|
||||
internal class OwinRequestMapper : IOwinRequestMapper
|
||||
internal class OwinRequestMapper(IDateTimeUtils dateTimeUtils) : IOwinRequestMapper
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public async Task<RequestMessage> MapAsync(HttpContext context, IWireMockMiddlewareOptions options)
|
||||
@@ -72,7 +72,7 @@ internal class OwinRequestMapper : IOwinRequestMapper
|
||||
await request.HttpContext.Connection.GetClientCertificateAsync()
|
||||
)
|
||||
{
|
||||
DateTime = DateTime.UtcNow
|
||||
DateTime = dateTimeUtils.UtcNow
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,39 @@ internal class MappingMatcher(IWireMockMiddlewareOptions options, IRandomizerDou
|
||||
return (match, partialMatch);
|
||||
}
|
||||
|
||||
public IReadOnlyList<MappingMatcherResult> FindNearMisses(IRequestMessage request, int maxResults)
|
||||
{
|
||||
Guard.NotNull(request);
|
||||
|
||||
var nearMisses = new List<MappingMatcherResult>();
|
||||
|
||||
// Probability is not taken into account here: a mapping which was skipped based on probability can still be a near miss.
|
||||
foreach (var mapping in _options.Mappings.Values.Where(m => !m.IsAdminInterface && !m.IsDisabled && m.TimeSettings.IsValid()))
|
||||
{
|
||||
try
|
||||
{
|
||||
var requestMatchResult = mapping.GetRequestMatchResult(request, GetNextState(mapping));
|
||||
if (requestMatchResult.MatchDetails.All(md => md.Exception == null))
|
||||
{
|
||||
nearMisses.Add(new MappingMatcherResult(mapping, requestMatchResult));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(mapping, ex);
|
||||
}
|
||||
}
|
||||
|
||||
// A near miss is a mapping which matches the request partially: perfect matches and complete mismatches are excluded.
|
||||
return nearMisses
|
||||
.Where(nm => !nm.RequestMatchResult.IsPerfectMatch && nm.RequestMatchResult.AverageTotalScore > 0.0)
|
||||
.OrderBy(nm => nm.RequestMatchResult)
|
||||
.ThenBy(nm => nm.Mapping.Priority)
|
||||
.ThenByDescending(nm => nm.Mapping.UpdatedAt)
|
||||
.Take(maxResults)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private void LogException(IMapping mapping, Exception ex)
|
||||
{
|
||||
_options.Logger.Error($"Getting a Request MatchResult for Mapping '{mapping.Guid}' failed. This mapping will not be evaluated. Exception: {ex}");
|
||||
|
||||
@@ -21,6 +21,7 @@ internal class WireMockMiddleware(
|
||||
RequestDelegate next,
|
||||
#pragma warning restore CS9113 // Parameter is unread.
|
||||
IWireMockMiddlewareOptions options,
|
||||
IAdminPaths adminPaths,
|
||||
IOwinRequestMapper requestMapper,
|
||||
IOwinResponseMapper responseMapper,
|
||||
IMappingMatcher mappingMatcher,
|
||||
@@ -64,7 +65,7 @@ internal class WireMockMiddleware(
|
||||
Activity? activity = null;
|
||||
|
||||
// Check if we should trace this request (optionally exclude admin requests)
|
||||
var shouldTrace = tracingEnabled && !(excludeAdmin && request.Path.StartsWith("/__admin/"));
|
||||
var shouldTrace = tracingEnabled && !(excludeAdmin && adminPaths.Includes(request.Path));
|
||||
|
||||
if (shouldTrace)
|
||||
{
|
||||
@@ -170,6 +171,12 @@ internal class WireMockMiddleware(
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Set the DateTime from the Response to the current DateTime
|
||||
if (response is ResponseMessage responseMessage)
|
||||
{
|
||||
responseMessage.DateTime = dateTimeUtils.UtcNow;
|
||||
}
|
||||
|
||||
logger.LogRequestAndResponse(logRequest, request, response, result.Match, result.Partial, activity);
|
||||
|
||||
try
|
||||
@@ -254,4 +261,4 @@ internal class WireMockMiddleware(
|
||||
scenario.Finished = mapping.NextState == null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,23 +12,27 @@ internal class WireMockMiddlewareLogger(
|
||||
IWireMockMiddlewareOptions options,
|
||||
LogEntryMapper logEntryMapper,
|
||||
IGuidUtils guidUtils,
|
||||
IAdminPaths adminPaths,
|
||||
IDateTimeUtils dateTimeUtils
|
||||
) : IWireMockMiddlewareLogger
|
||||
{
|
||||
public void LogRequestAndResponse(bool logRequest, RequestMessage request, IResponseMessage? response, MappingMatcherResult? match, MappingMatcherResult? partialMatch, Activity? activity)
|
||||
{
|
||||
var mapping = match?.Mapping;
|
||||
var partialMapping = partialMatch?.Mapping;
|
||||
|
||||
var logEntry = new LogEntry
|
||||
{
|
||||
Guid = guidUtils.NewGuid(),
|
||||
RequestMessage = request,
|
||||
ResponseMessage = response,
|
||||
|
||||
MappingGuid = match?.Mapping?.Guid,
|
||||
MappingTitle = match?.Mapping?.Title,
|
||||
MappingGuid = mapping?.Guid,
|
||||
MappingTitle = mapping?.Title,
|
||||
RequestMatchResult = match?.RequestMatchResult,
|
||||
|
||||
PartialMappingGuid = partialMatch?.Mapping?.Guid,
|
||||
PartialMappingTitle = partialMatch?.Mapping?.Title,
|
||||
PartialMappingGuid = partialMapping?.Guid,
|
||||
PartialMappingTitle = partialMapping?.Title,
|
||||
PartialMatchResult = partialMatch?.RequestMatchResult
|
||||
};
|
||||
|
||||
@@ -53,7 +57,8 @@ internal class WireMockMiddlewareLogger(
|
||||
|
||||
public void LogLogEntry(LogEntry entry, bool addRequest)
|
||||
{
|
||||
options.Logger.DebugRequestResponse(logEntryMapper.Map(entry), entry.RequestMessage?.Path.StartsWith("/__admin/") == true);
|
||||
var isAdminRequest = adminPaths.Includes(entry.RequestMessage?.Path);
|
||||
options.Logger.DebugRequestResponse(logEntryMapper.Map(entry), isAdminRequest);
|
||||
|
||||
// If addRequest is set to true and MaxRequestLogCount is null or does have a value greater than 0, try to add a new request log.
|
||||
if (addRequest && options.MaxRequestLogCount is null or > 0)
|
||||
@@ -68,20 +73,20 @@ internal class WireMockMiddlewareLogger(
|
||||
var logEntries = options.LogEntries.ToList();
|
||||
|
||||
foreach (var logEntry in logEntries
|
||||
.OrderBy(le => le.RequestMessage?.DateTime ?? le.ResponseMessage?.DateTime)
|
||||
.OrderBy(le => le.RequestMessage?.DateTime)
|
||||
.Take(logEntries.Count - options.MaxRequestLogCount.Value))
|
||||
{
|
||||
TryRemoveLogEntry(logEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// In case RequestLogExpirationDuration has a value greater than 0, try to delete existing request logs based on the date.
|
||||
// In case RequestLogExpirationDuration has a value greater than 0, try to delete existing request logs based on the RequestMessage date.
|
||||
if (options.RequestLogExpirationDuration is > 0)
|
||||
{
|
||||
var logEntries = options.LogEntries.ToList();
|
||||
|
||||
var checkTime = dateTimeUtils.UtcNow.AddHours(-options.RequestLogExpirationDuration.Value);
|
||||
foreach (var logEntry in logEntries.Where(le => le.RequestMessage?.DateTime < checkTime || le.ResponseMessage?.DateTime < checkTime))
|
||||
foreach (var logEntry in logEntries.Where(le => le.RequestMessage?.DateTime < checkTime))
|
||||
{
|
||||
TryRemoveLogEntry(logEntry);
|
||||
}
|
||||
|
||||
Loaded 100 of 226 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user