Compare commits

...
12 Commits
Author SHA1 Message Date
Stef Heyenrath 567f94d70d 2.31.0 2026-11-12 20:58:02 +01:00
Stef HeyenrathandCopilot Autofix powered by AI 22576eb539 Use X509CertificateLoader on .NET 9+ (#1543)
* Use X509CertificateLoader on .NET 9+

Preserve older-target certificate loading and add tests for
supported formats, passwords, and embedded certificates.

* !

* Potential fix for pull request finding 'Missed 'using' opportunity'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* enum

* namespace WireMock.Compatiblity;

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-11-12 20:56:01 +01:00
Stef Heyenrath 384c083a78 Upgrade dependencies 2026-11-12 20:03:03 +01:00
dependabot[bot] 920b5b48f2 Bump Microsoft.AspNetCore.WebUtilities from 2.3.0 to 2.3.14 (#1538)
---
updated-dependencies:
- dependency-name: Microsoft.AspNetCore.WebUtilities
  dependency-version: 2.3.14
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-11 08:28:03 +01:00
Stef Heyenrath b7a02e2971 Bump Aspire from 13.6.4 to 13.6.5 2026-11-11 08:21:10 +01:00
Stef Heyenrath dbf90c6888 New SonarCloud project (#1534)
* SonarCloud test

* xxx

* WebSocketIntegrationTests

* move sonar to github

* SonarCloud now runs for every Linux workflow event. The begin step supplies pull-request key/branch/base metadata for PRs and branch metadata for pushes; the end step is no longer gated. Workflow YAML parsing and the solution build both pass.

* SHA
2026-11-11 07:57:54 +01:00
Stef Heyenrath 6ae65ba73e 2.30.0 2026-11-07 15:44:44 +01:00
Stef HeyenrathandCopilot Autofix powered by AI 2760ecbe00 Switch to IHost for .NET 10 + update dotnet-WireMock (#1532)
* Switch to IHost for .NET 10

* 'dotnet-WireMock stops on CTRL-C'

* Potential fix for pull request finding 'Missing Dispose call on local IDisposable'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* .

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
2026-11-07 13:10:21 +01:00
CopilotandStefH f594a7cb19 Use version-aligned DCP for Aspire integration tests (#1531)
* Initial plan

* Fix Aspire integration test DCP version mismatch

Co-authored-by: StefH <249938+StefH@users.noreply.github.com>

* Enable Aspire Docker integration tests

Co-authored-by: StefH <249938+StefH@users.noreply.github.com>

* Use Aspire RID fallback with .NET 10 SDK

Co-authored-by: StefH <249938+StefH@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: StefH <249938+StefH@users.noreply.github.com>
2026-11-07 09:59:48 +01:00
Stef Heyenrath 30cf82fd8d Use 10.x.x NuGets for .NET 10 (#1530)
* Use 10.x.x NuGets for .NET 10

* await Task.Delay(500, _ct);
2026-11-01 13:25:40 +01:00
Stef HeyenrathandCopilot App 3630093d49 Add .NET 10 target framework (#1528)
* Add .NET 10 target framework

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* ...

* add delay

* ok

* TUnit - delay

* 10

* ado

* ado - no nuget tests

* .

* no collect

* await Task.Delay(500, _ct);

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-10-31 18:38:25 +01:00
Tomás Pinto f0965e5650 Create Release Artifacts (#1527) 2026-10-30 18:12:26 +01:00
91 changed files with 831 additions and 51697 deletions

No files matched your search

+1 -1
View File
@@ -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
+44 -2
View File
@@ -4,6 +4,7 @@ permissions:
contents: write
on:
workflow_dispatch:
push:
tags:
- "*.*.*"
@@ -13,9 +14,50 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- name: Setup .NET 8 and 10
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
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/*
+1 -1
View File
@@ -12,7 +12,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- name: Build projects
shell: pwsh
+136 -26
View File
@@ -20,24 +20,35 @@ jobs:
IsRunningOnGitHubActions: 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
- name: Setup .NET 8 and 10
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
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
@@ -47,24 +58,123 @@ jobs:
IsRunningOnGitHubActions: 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
- name: Setup .NET 8 and 10
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
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: Setup Java 17
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
with:
distribution: temurin
java-version: '17'
- name: 'WireMock.Net.Tests'
run: dotnet test --project './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' -c Release --framework net8.0
- name: Install .NET coverage and SonarScanner tools
run: |
dotnet tool install --global dotnet-sonarscanner
dotnet tool install --global dotnet-coverage
echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
- name: 'WireMock.Net.Tests.UsingNuGet'
run: dotnet test --project './test/WireMock.Net.Tests.UsingNuGet/WireMock.Net.Tests.UsingNuGet.csproj' -c Release
- name: Begin analysis on SonarCloud
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BRANCH: ${{ github.head_ref }}
PR_BASE: ${{ github.base_ref }}
run: |
sonar_args=(
/k:"wiremock_WireMock.Net"
/o:"wiremock"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.token="$SONAR_TOKEN"
/d:sonar.cs.vscoveragexml.reportsPaths="**/wiremock-coverage-*.xml"
/d:sonar.verbose=true
)
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
sonar_args+=(
/d:sonar.pullrequest.provider=github
/d:sonar.pullrequest.key="$PR_NUMBER"
/d:sonar.pullrequest.branch="$PR_BRANCH"
/d:sonar.pullrequest.base="$PR_BASE"
)
else
sonar_args+=(/d:sonar.branch.name="$GITHUB_REF_NAME")
fi
dotnet sonarscanner begin "${sonar_args[@]}"
- name: Build test projects for coverage
run: |
dotnet build ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Release --framework net10.0
dotnet build ./test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj --configuration Release --framework net10.0
dotnet build ./test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj --configuration Release --framework net10.0
dotnet build ./test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj --configuration Release --framework net10.0
# - 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.TUnitTests (net10.0) with coverage'
run: dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj --configuration Release --no-build --framework net10.0" -f xml -o "wiremock-coverage-tunit.xml"
# - 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) with coverage'
run: dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration Release --no-build --framework net10.0" -f xml -o "wiremock-coverage-xunit.xml"
- 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) with coverage'
run: dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Middleware.Tests/WireMock.Net.Middleware.Tests.csproj --configuration Release --no-build --framework net10.0" -f xml -o "wiremock-coverage-middleware.xml"
# - 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) with coverage'
run: dotnet-coverage collect "dotnet test --project ./test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj --configuration Release --no-build --framework net10.0" -f xml -o "wiremock-coverage-aspire.xml"
- name: Merge coverage files
run: dotnet coverage merge **/wiremock-coverage-*.xml --output ./test/wiremock-coverage.xml --output-format xml
- name: End analysis on SonarCloud
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
- name: Upload coverage results to Codecov
uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac # v5.5.5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./test/wiremock-coverage.xml
- 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
+2 -2
View File
@@ -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.*
+14
View File
@@ -1,3 +1,17 @@
# 2.31.0 (12 November 2026)
- [#1538](https://github.com/wiremock/WireMock.Net/pull/1538) - Bump Microsoft.AspNetCore.WebUtilities from 2.3.0 to 2.3.14 [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
- [#1540](https://github.com/wiremock/WireMock.Net/pull/1540) - Bump Aspire from 13.6.4 to 13.6.5 [dependencies] contributed by [StefH](https://github.com/StefH)
- [#1542](https://github.com/wiremock/WireMock.Net/pull/1542) - Upgrade dependencies [dependencies] contributed by [StefH](https://github.com/StefH)
- [#1543](https://github.com/wiremock/WireMock.Net/pull/1543) - Use X509CertificateLoader on .NET 9+ [bug] contributed by [StefH](https://github.com/StefH)
- [#1365](https://github.com/wiremock/WireMock.Net/issues/1365) - Client certificate authentication works with .NET 8 and fails with .NET 9 [bug]
- [#1541](https://github.com/wiremock/WireMock.Net/issues/1541) - WireMock.Shared depends on Microsoft.AspNetCore.Http 2.3.9 which has a high-severity vulnerability [dependencies]
# 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 -2
View File
@@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>2.21.0</VersionPrefix>
<VersionPrefix>2.31.0</VersionPrefix>
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
<PackageProjectUrl>https://github.com/wiremock/WireMock.Net</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
@@ -55,7 +55,7 @@
<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>
+7 -3
View File
@@ -1,5 +1,9 @@
# 2.21.0 (28 October 2026)
- #1526 Update Scriban to 7.5.3 [dependencies]
- #1525 High security vulnerability in Scriban package [security]
# 2.31.0 (12 November 2026)
- #1538 Bump Microsoft.AspNetCore.WebUtilities from 2.3.0 to 2.3.14 [dependencies]
- #1540 Bump Aspire from 13.6.4 to 13.6.5 [dependencies]
- #1542 Upgrade dependencies [dependencies]
- #1543 Use X509CertificateLoader on .NET 9+ [bug]
- #1365 Client certificate authentication works with .NET 8 and fails with .NET 9 [bug]
- #1541 WireMock.Shared depends on Microsoft.AspNetCore.Http 2.3.9 which has a high-severity vulnerability [dependencies]
The full release notes can be found here: https://github.com/wiremock/WireMock.Net/blob/master/CHANGELOG.md
+3 -3
View File
@@ -40,9 +40,9 @@ A C# .NET version based on [mock4net](https://github.com/alexvictoor/mock4net) w
| ***Quality*** | &nbsp; |
| &nbsp;&nbsp;**Build Azure** | [![Build Status Azure](https://stef.visualstudio.com/WireMock.Net/_apis/build/status/WireMock.Net)](https://stef.visualstudio.com/WireMock.Net/_build/latest?definitionId=61) |
| &nbsp;&nbsp;**Build GitHub** | [![Run Tests](https://github.com/wiremock/WireMock.Net/actions/workflows/ci.yml/badge.svg)](https://github.com/wiremock/WireMock.Net/actions/workflows/ci.yml)
| &nbsp;&nbsp;**Quality** | [![Sonar Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=WireMock-Net_WireMock.Net&metric=alert_status)](https://sonarcloud.io/project/issues?id=WireMock-Net_WireMock.Net) [![CodeFactor](https://www.codefactor.io/repository/github/wiremock/wiremock.net/badge)](https://www.codefactor.io/repository/github/wiremock/wiremock.net) |
| &nbsp;&nbsp;**SonarQube** | [![Sonar Bugs](https://sonarcloud.io/api/project_badges/measure?project=WireMock-Net_WireMock.Net&metric=bugs)](https://sonarcloud.io/project/issues?id=WireMock-Net_WireMock.Net&resolved=false&types=BUG) [![Sonar Code Smells](https://sonarcloud.io/api/project_badges/measure?project=WireMock-Net_WireMock.Net&metric=code_smells)](https://sonarcloud.io/project/issues?id=WireMock-Net_WireMock.Net&resolved=false&types=CODE_SMELL) |
| &nbsp;&nbsp;**Coverage** | [![Sonar Coverage](https://sonarcloud.io/api/project_badges/measure?project=WireMock-Net_WireMock.Net&metric=coverage)](https://sonarcloud.io/component_measures?id=WireMock-Net_WireMock.Net&metric=coverage) [![codecov](https://codecov.io/gh/wiremock/WireMock.Net/branch/master/graph/badge.svg)](https://codecov.io/gh/wiremock/WireMock.Net)|
| &nbsp;&nbsp;**Quality** | [![Sonar Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=wiremock_WireMock.Net&metric=alert_status)](https://sonarcloud.io/project/issues?id=wiremock_WireMock.Net) [![CodeFactor](https://www.codefactor.io/repository/github/wiremock/wiremock.net/badge)](https://www.codefactor.io/repository/github/wiremock/wiremock.net) |
| &nbsp;&nbsp;**SonarQube** | [![Sonar Bugs](https://sonarcloud.io/api/project_badges/measure?project=wiremock_WireMock.Net&metric=bugs)](https://sonarcloud.io/project/issues?id=wiremock_WireMock.Net&resolved=false&types=BUG) [![Sonar Code Smells](https://sonarcloud.io/api/project_badges/measure?project=wiremock_WireMock.Net&metric=code_smells)](https://sonarcloud.io/project/issues?id=wiremock_WireMock.Net&resolved=false&types=CODE_SMELL) |
| &nbsp;&nbsp;**Coverage** | [![Sonar Coverage](https://sonarcloud.io/api/project_badges/measure?project=wiremock_WireMock.Net&metric=coverage)](https://sonarcloud.io/component_measures?id=wiremock_WireMock.Net&metric=coverage) [![codecov](https://codecov.io/gh/wiremock/WireMock.Net/branch/master/graph/badge.svg)](https://codecov.io/gh/wiremock/WireMock.Net)|
| &nbsp;&nbsp;**TIOBE** | [TIOBE Quality Indicator](https://ticsdemo.tiobe.com/tiobeweb/DEMO/TqiDashboard.html#axes=Project(WireMock.Net),Sub()&metric=tqi)
### :package: NuGet packages
+16 -15
View File
@@ -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}
+79 -65
View File
@@ -1,3 +1,6 @@
trigger: none
pr: none
parameters:
- name: runWindowsReleaseToMyGet
displayName: Run Windows Release to MyGet
@@ -20,6 +23,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
@@ -39,7 +48,7 @@ jobs:
# See: https://docs.sonarsource.com/sonarcloud/enriching/test-coverage/dotnet-test-coverage
- script: |
dotnet sonarscanner begin /k:"WireMock-Net_WireMock.Net" /o:"wiremock-net" /d:sonar.branch.name=$(Build.SourceBranchName) /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token="$(SONAR_TOKEN)" /d:sonar.pullrequest.provider=github /d:sonar.cs.vscoveragexml.reportsPaths=**/wiremock-coverage-*.xml /d:sonar.verbose=true
dotnet sonarscanner begin /k:"wiremock_WireMock.Net" /o:"wiremock" /d:sonar.branch.name=$(Build.SourceBranchName) /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token="$(SONAR_TOKEN)" /d:sonar.pullrequest.provider=github /d:sonar.cs.vscoveragexml.reportsPaths=**/wiremock-coverage-*.xml /d:sonar.verbose=true
displayName: 'Begin analysis on SonarCloud'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
@@ -48,30 +57,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
@@ -110,77 +119,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
condition: and(succeeded(), ${{ parameters.runWindowsReleaseToMyGet }})
# - 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)
+6
View File
@@ -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.5" />
<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 / CVE-2026-92707 -->
<PackageReference Include="MessagePack" Version="2.5.303" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.6.5" />
</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.5" />
<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 / CVE-2026-92707 -->
<PackageReference Include="MessagePack" Version="2.5.303" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.6.5" />
</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,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>
@@ -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,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>
@@ -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>
</PropertyGroup>
<ItemGroup>
@@ -6,7 +6,7 @@ using log4net.Config;
using log4net.Repository;
using WireMock.Net.ConsoleApplication;
namespace WireMock.Net.Console.NET8;
namespace WireMock.Net.Console;
static class Program
{
@@ -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>
@@ -1,22 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<!--<ItemGroup>
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
</ItemGroup>-->
<ItemGroup>
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.12.0.118525" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.12.0.118525" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="WireMock.Net" Version="2.30.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="WireMock.Net" Version="2.15.0" />
</ItemGroup>
<!-- CVE -->
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.14" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.3.14" />
</ItemGroup>
</Project>
@@ -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>
@@ -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>
@@ -90,8 +90,11 @@
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Core">
<Version>2.3.11</Version>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.WebUtilities">
<Version>2.3.14</Version>
</PackageReference>
<PackageReference Include="WireMock.Net">
<Version>2.12.0</Version>
<Version>2.30.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
@@ -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>
@@ -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>
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<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 / CVE-2026-92707 -->
<PackageReference Include="MessagePack" Version="2.5.303" />
<PackageReference Include="Aspire.Hosting" Version="13.6.5" />
</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>
@@ -4,7 +4,7 @@
<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>
@@ -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>
@@ -2,6 +2,9 @@
using System.Security.Cryptography.X509Certificates;
using WireMock.Owin;
#if NETSTANDARD2_0
using Enum = WireMock.Compatiblity.EnumCompat;
#endif
namespace WireMock.HttpsCertificate;
@@ -18,32 +21,24 @@ internal static class CertificateLoader
{
var thumbprintOrSubjectNameOrHost = options.X509ThumbprintOrSubjectName ?? host;
var certStore = new X509Store((StoreName)Enum.Parse(typeof(StoreName), options.X509StoreName!), (StoreLocation)Enum.Parse(typeof(StoreLocation), options.X509StoreLocation!));
try
{
certStore.Open(OpenFlags.ReadOnly);
using var certStore = new X509Store(Enum.Parse<StoreName>(options.X509StoreName!), Enum.Parse<StoreLocation>(options.X509StoreLocation!));
certStore.Open(OpenFlags.ReadOnly);
// Attempt to find by Thumbprint first
var matchingCertificates = certStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprintOrSubjectNameOrHost, false);
// Attempt to find by Thumbprint first
var matchingCertificates = certStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprintOrSubjectNameOrHost, false);
if (matchingCertificates.Count == 0)
{
// Fallback to SubjectName
matchingCertificates = certStore.Certificates.Find(X509FindType.FindBySubjectName, thumbprintOrSubjectNameOrHost, false);
if (matchingCertificates.Count == 0)
{
// Fallback to SubjectName
matchingCertificates = certStore.Certificates.Find(X509FindType.FindBySubjectName, thumbprintOrSubjectNameOrHost, false);
if (matchingCertificates.Count == 0)
{
// No certificates matched the search criteria.
throw new FileNotFoundException($"No Certificate found with in store '{options.X509StoreName}', location '{options.X509StoreLocation}' for Thumbprint or SubjectName '{thumbprintOrSubjectNameOrHost}'.");
}
// No certificates matched the search criteria.
throw new FileNotFoundException($"No Certificate found with in store '{options.X509StoreName}', location '{options.X509StoreLocation}' for Thumbprint or SubjectName '{thumbprintOrSubjectNameOrHost}'.");
}
}
// Use the first matching certificate.
return matchingCertificates[0];
}
finally
{
certStore.Dispose();
certStore.Close();
}
// Use the first matching certificate.
return matchingCertificates[0];
}
if (!string.IsNullOrEmpty(options.X509CertificateFilePath))
@@ -55,10 +50,14 @@ internal static class CertificateLoader
if (!string.IsNullOrEmpty(options.X509CertificatePassword))
{
var certPem = File.ReadAllText(options.X509CertificateFilePath);
var cert = X509Certificate2.CreateFromPem(certPem, options.X509CertificatePassword);
using var cert = X509Certificate2.CreateFromPem(certPem, options.X509CertificatePassword);
const string defaultPasswordPem = "WireMock.Net";
#if NET9_0_OR_GREATER
return X509CertificateLoader.LoadPkcs12(cert.Export(X509ContentType.Pfx, defaultPasswordPem), defaultPasswordPem);
#else
return new X509Certificate2(cert.Export(X509ContentType.Pfx, defaultPasswordPem), defaultPasswordPem);
#endif
}
return X509Certificate2.CreateFromPemFile(options.X509CertificateFilePath);
#else
@@ -66,9 +65,29 @@ internal static class CertificateLoader
#endif
}
#if NET9_0_OR_GREATER
var data = File.ReadAllBytes(options.X509CertificateFilePath);
var contentType = X509Certificate2.GetCertContentType(data);
if (contentType == X509ContentType.Pfx)
{
return X509CertificateLoader.LoadPkcs12(data, string.IsNullOrEmpty(options.X509CertificatePassword) ? null : options.X509CertificatePassword);
}
if (contentType == X509ContentType.Cert)
{
return X509CertificateLoader.LoadCertificate(data);
}
// The loader does not support legacy formats such as PKCS#7 and serialized certificates.
#pragma warning disable SYSLIB0057
return !string.IsNullOrEmpty(options.X509CertificatePassword) ?
new X509Certificate2(data, options.X509CertificatePassword) :
new X509Certificate2(data);
#pragma warning restore SYSLIB0057
#else
return !string.IsNullOrEmpty(options.X509CertificatePassword) ?
new X509Certificate2(options.X509CertificateFilePath, options.X509CertificatePassword) :
new X509Certificate2(options.X509CertificateFilePath);
#endif
}
if (options.X509Certificate != null)
@@ -89,6 +89,10 @@ wTM1Z+CJZG9xAcf1zAVGl4ggYyYEFGBFyJ8VBwijS2zy1qwN1WYGtcWoAgIH0A==
public static X509Certificate2 GetX509Certificate2()
{
byte[] data = Convert.FromBase64String(Data);
#if NET9_0_OR_GREATER
return X509CertificateLoader.LoadPkcs12(data, null);
#else
return new X509Certificate2(data);
#endif
}
}
@@ -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,58 +102,71 @@ internal partial class AspNetCoreSelfHost
logging.AddProvider(new WireMockAspNetCoreLoggerProvider(_logger));
logging.SetMinimumLevel(LogLevel.Warning);
})
.ConfigureServices(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);
})
.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
@@ -126,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)
{
@@ -169,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)
{
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Minimal version from the lightweight Http Mocking Server for .NET</Description>
<AssemblyTitle>WireMock.Net.Minimal</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.Minimal</AssemblyName>
<PackageId>WireMock.Net.Minimal</PackageId>
@@ -28,7 +28,7 @@
<CodeAnalysisRuleSet>../WireMock.Net/WireMock.Net.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0' ">
<PropertyGroup Condition="('$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net10.0')">
<DefineConstants>$(DefineConstants);TRAILINGHEADERS</DefineConstants>
</PropertyGroup>
@@ -52,7 +52,7 @@
</PackageReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0'">
<ItemGroup Condition="('$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net10.0')">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
@@ -3,7 +3,7 @@
<Description>Some extensions for NUnit</Description>
<AssemblyTitle>WireMock.Net.NUnit</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0;net10.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.NUnit</AssemblyName>
<RootNamespace>WireMock.Net.NUnit</RootNamespace>
@@ -2,7 +2,7 @@
<PropertyGroup>
<Description>An OpenApi (swagger) parser to generate MappingModel or mapping.json file.</Description>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>wiremock;openapi;OAS;raml;converter;parser;openapiparser</PackageTags>
<ProjectGuid>{E5B03EEF-822C-4295-952B-4479AD30082B}</ProjectGuid>
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>OpenTelemetry exporter support for WireMock.Net</Description>
<AssemblyTitle>WireMock.Net.OpenTelemetry</AssemblyTitle>
<Authors>Petr Houška</Authors>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<RootNamespace>WireMock.OpenTelemetry</RootNamespace>
<PackageTags>wiremock;opentelemetry;otel;tracing;telemetry</PackageTags>
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>A RestClient using RestEase to access the admin interface.</Description>
<AssemblyTitle>WireMock.Net.RestClient</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.RestClient</AssemblyName>
<PackageId>WireMock.Net.RestClient</PackageId>
@@ -0,0 +1,10 @@
// Copyright © WireMock.Net
#if NETSTANDARD2_0
namespace WireMock.Compatiblity;
internal static class EnumCompat
{
public static TEnum Parse<TEnum>(string value) where TEnum : struct, Enum => (TEnum)Enum.Parse(typeof(TEnum), value);
}
#endif
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Shared interfaces, models, enumerations and types.</Description>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net10.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>tdd;mock;http;wiremock;test;server;shared</PackageTags>
<RootNamespace>WireMock</RootNamespace>
@@ -25,11 +25,17 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<!-- CVE -->
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.14" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.3.14" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.9" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
<PackageReference Include="AnyOf" Version="0.5.0.1" />
<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' " />
<PackageReference Include="JsonConverter.Newtonsoft.Json" Version="0.13.0" />
<PackageReference Include="JsonConverter.System.Text.Json" Version="0.13.0" />
</ItemGroup>
@@ -1,8 +1,6 @@
// Copyright © WireMock.Net
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using JetBrains.Annotations;
using Stef.Validation;
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Lightweight StandAlone Http Mocking Server for .Net.</Description>
<AssemblyTitle>WireMock.Net.StandAlone</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>netstandard2.1;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.1;net8.0;net10.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.StandAlone</AssemblyName>
<PackageId>WireMock.Net.StandAlone</PackageId>
@@ -29,7 +29,7 @@
<!-- Enable OpenTelemetry exporter support for .NET 8+ -->
<PropertyGroup Condition="' $(TargetFramework)' == 'net8.0' ">
<PropertyGroup Condition="('$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net10.0')">
<DefineConstants>$(DefineConstants);OPENTELEMETRY_SUPPORTED</DefineConstants>
</PropertyGroup>
@@ -45,7 +45,7 @@
</ItemGroup>
<!-- OpenTelemetry exporter for .NET 8+ -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<ItemGroup Condition="('$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net10.0')">
<ProjectReference Include="..\WireMock.Net.OpenTelemetry\WireMock.Net.OpenTelemetry.csproj" />
</ItemGroup>
</Project>
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Some extensions for TUnit (TUnitLogger)</Description>
<AssemblyTitle>WireMock.Net.TUnit</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net.TUnit</AssemblyName>
<RootNamespace>WireMock.Net.Tunit</RootNamespace>
+1 -1
View File
@@ -3,7 +3,7 @@
<Description>Lightweight Http Mocking Server for .NET, inspired by WireMock from the Java landscape.</Description>
<AssemblyTitle>WireMock.Net</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>net462;netstandard2.1;net8.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.1;net8.0;net10.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net</AssemblyName>
<PackageId>WireMock.Net</PackageId>
@@ -4,7 +4,7 @@
<Description>Commonly used interfaces, models, enumerations and types.</Description>
<AssemblyTitle>WireMock.Org.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>
<RootNamespace>WireMock.Org.Abstractions</RootNamespace>
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>A WireMock.org RestClient using RestEase to access the admin interface.</Description>
<AssemblyTitle>WireMock.Org.RestClient</AssemblyTitle>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Org.RestClient</AssemblyName>
<PackageId>WireMock.Org.RestClient</PackageId>
+36 -7
View File
@@ -1,7 +1,5 @@
// Copyright © WireMock.Net
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using WireMock.Logging;
using WireMock.Net.StandAlone;
@@ -25,6 +23,7 @@ public class Program
private static readonly IWireMockLogger Logger = new WireMockLogger(XLogger);
private static WireMockServer _server = null!;
private static int _stopped;
static async Task Main(string[] args)
{
@@ -33,29 +32,59 @@ public class Program
return;
}
using var cancelationTokenSource = new CancellationTokenSource();
Logger.Info("Press Ctrl+C to shut down");
Console.CancelKeyPress += (s, e) =>
{
Stop("CancelKeyPress");
// Prevent the runtime from terminating the process (exit code 130 / -1073741510)
// Main stops the server and returns normally.
e.Cancel = true;
Logger.Info("Shutdown requested because 'CancelKeyPress'");
cancelationTokenSource.Cancel();
};
System.Runtime.Loader.AssemblyLoadContext.Default.Unloading += ctx =>
{
Stop("AssemblyLoadContext.Default.Unloading");
Stop("AssemblyLoadContext.Default.Unloading", cancelationTokenSource);
};
while (true)
while (!cancelationTokenSource.IsCancellationRequested)
{
Logger.Info("Server running : {0}", _server.IsStarted);
await Task.Delay(SleepTime).ConfigureAwait(false);
try
{
await Task.Delay(SleepTime, cancelationTokenSource.Token).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
// Shutdown requested
}
}
Stop("shutdown requested", cancelationTokenSource);
}
private static void Stop(string why)
private static void Stop(string why, CancellationTokenSource cancellationTokenSource)
{
if (Interlocked.Exchange(ref _stopped, 1) == 1)
{
return;
}
Logger.Info("Server stopping because '{0}'", why);
_server.Stop();
Logger.Info("Server stopped");
try
{
cancellationTokenSource.Cancel();
}
catch (ObjectDisposedException)
{
// Main already finished
}
}
}
+27 -27
View File
@@ -1,27 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<PackAsTool>true</PackAsTool>
<RootNamespace>WireMock.Net</RootNamespace>
<ToolCommandName>dotnet-wiremock</ToolCommandName>
<Description>A dotnet commandline tool for WireMock.Net (A Lightweight Http Mocking Server for .NET)</Description>
<PackageTags>tdd;mock;http;wiremock;test;server;unittest;dotnet;tool;dotnet-tool</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>Stef Heyenrath</Authors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WireMock.Net.StandAlone\WireMock.Net.StandAlone.csproj" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<PackAsTool Condition="'$(PublishSingleFile)' != 'true'">true</PackAsTool>
<RootNamespace>WireMock.Net</RootNamespace>
<ToolCommandName>dotnet-wiremock</ToolCommandName>
<Description>A dotnet commandline tool for WireMock.Net (A Lightweight Http Mocking Server for .NET)</Description>
<PackageTags>tdd;mock;http;wiremock;test;server;unittest;dotnet;tool;dotnet-tool</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>Stef Heyenrath</Authors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release' And '$(PublishSingleFile)' != 'true'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.14" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WireMock.Net.StandAlone\WireMock.Net.StandAlone.csproj" />
</ItemGroup>
</Project>
@@ -1,16 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="13.4.0" />
<Sdk Name="Aspire.AppHost.Sdk" Version="13.6.5" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../src/WireMock.Net/WireMock.Net.snk</AssemblyOriginatorKeyFile>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<_AspireUseSdkPickBestRid>false</_AspireUseSdkPickBestRid>
</PropertyGroup>
<ItemGroup>
@@ -19,10 +20,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.4.3" />
<!-- CVE-2026-48109 / CVE-2026-92707 -->
<PackageReference Include="MessagePack" Version="2.5.303" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.6.5" />
</ItemGroup>
<ItemGroup>
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@@ -14,7 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.Testing" Version="13.4.3" />
<PackageReference Include="Aspire.Hosting.Testing" Version="13.6.5" />
<PackageReference Include="Codecov" Version="1.13.0" />
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
@@ -25,16 +25,13 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="AwesomeAssertions" Version="9.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<!-- CVE-2026-48109 / CVE-2026-92707 -->
<PackageReference Include="MessagePack" Version="2.5.303" />
</ItemGroup>
<ItemGroup>
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>Gennadii Saltyshchak</Authors>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
@@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="AwesomeAssertions" Version="9.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -16,6 +16,7 @@ public class IntegrationTests
// Arrange
await using var factory = new CustomWebApplicationFactory<Program>();
using var client = factory.CreateClient();
await Task.Delay(1000, TestContext.Current.CancellationToken);
// Act
var response = await client.GetAsync(requestUri, TestContext.Current.CancellationToken);
@@ -34,6 +35,7 @@ public class IntegrationTests
// Arrange
await using var factory = new CustomWebApplicationFactory<Program>(false);
using var client = factory.CreateClient();
await Task.Delay(1000, TestContext.Current.CancellationToken);
var request = new HttpRequestMessage(HttpMethod.Get, requestUri);
request.Headers.Add("X-WireMock-Redirect", "true");
@@ -43,7 +45,7 @@ public class IntegrationTests
var response = await client.SendAsync(request, TestContext.Current.CancellationToken);
// Assert
response.EnsureSuccessStatusCode();
//response.EnsureSuccessStatusCode();
var stringResponse = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
stringResponse.Should().Be(expectedResponse);
}
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@@ -23,8 +23,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="AwesomeAssertions" Version="9.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8" Condition=" '$(TargetFramework)' != 'net10.0' " />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.14" Condition=" '$(TargetFramework)' == 'net10.0' " />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
File diff suppressed because it is too large. Load diff
@@ -22,6 +22,8 @@ public class TUnitTests
Logger = new TUnitWireMockLogger(TestContext.Current!.GetDefaultLogger())
});
await Task.Delay(1000, TestContext.Current.Execution.CancellationToken);
server
.Given(Request.Create()
.WithPath(path)
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@@ -15,8 +15,8 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
<PackageReference Include="WireMock.Net" Version="2.20.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageReference Include="WireMock.Net" Version="2.21.0" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
@@ -39,4 +39,10 @@
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.11.0.117924" />
</ItemGroup>
<!-- CVE -->
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.14" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.3.14" />
</ItemGroup>
</Project>
@@ -0,0 +1,87 @@
// Copyright © WireMock.Net
#if NET8_0_OR_GREATER
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using WireMock.HttpsCertificate;
using WireMock.Owin;
namespace WireMock.Net.Tests.HttpsCertificate;
public class CertificateLoaderTests
{
[Theory]
[InlineData("pfx", null, true)]
[InlineData("pfx", "password", true)]
[InlineData("cer", null, false)]
[InlineData("cer", "password", false)]
[InlineData("pem", null, true)]
[InlineData("pem", "private-key", true)]
public void LoadCertificate_LoadsSupportedFormats(string format, string? password, bool hasPrivateKey)
{
using var key = RSA.Create(2048);
var request = new CertificateRequest("CN=localhost", key, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
using var original = request.CreateSelfSigned(DateTimeOffset.UtcNow.AddDays(-1), DateTimeOffset.UtcNow.AddDays(1));
var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.{format}");
try
{
if (format == "pem")
{
var pem = original.ExportCertificatePem();
File.WriteAllText(path, password == null ? pem + "\n" + key.ExportPkcs8PrivateKeyPem() : pem);
}
else
{
var contentType = format == "pfx" ? X509ContentType.Pfx : X509ContentType.Cert;
File.WriteAllBytes(path, original.Export(contentType, format == "pfx" ? password : null));
}
var options = new WireMockMiddlewareOptions
{
X509CertificateFilePath = path,
X509CertificatePassword = format == "pem" && password != null ? key.ExportPkcs8PrivateKeyPem() : password
};
using var loaded = CertificateLoader.LoadCertificate(options, "localhost");
loaded.Thumbprint.Should().Be(original.Thumbprint);
loaded.HasPrivateKey.Should().Be(hasPrivateKey);
}
finally
{
File.Delete(path);
}
}
[Fact]
public void LoadCertificate_InvalidPfxPassword_Throws()
{
using var key = RSA.Create(2048);
var request = new CertificateRequest("CN=localhost", key, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
using var original = request.CreateSelfSigned(DateTimeOffset.UtcNow.AddDays(-1), DateTimeOffset.UtcNow.AddDays(1));
var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.pfx");
try
{
File.WriteAllBytes(path, original.Export(X509ContentType.Pfx, "password"));
var options = new WireMockMiddlewareOptions { X509CertificateFilePath = path, X509CertificatePassword = "wrong" };
Action load = () => CertificateLoader.LoadCertificate(options, "localhost");
load.Should().Throw<CryptographicException>();
}
finally
{
File.Delete(path);
}
}
[Fact]
public void GetX509Certificate2_LoadsEmbeddedCertificate()
{
using var certificate = PublicCertificateHelper.GetX509Certificate2();
certificate.HasPrivateKey.Should().BeTrue();
certificate.Thumbprint.Should().NotBeNullOrEmpty();
}
}
#endif
@@ -1,8 +1,7 @@
// Copyright © WireMock.Net
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
using System.Runtime.InteropServices;
using AwesomeAssertions;
using AwesomeAssertions.Execution;
using DotNet.Testcontainers.Builders;
using Meziantou.Extensions.Logging.Xunit.v3;
@@ -13,8 +12,10 @@ using WireMock.Net.Tests.Facts;
namespace WireMock.Net.Tests.Testcontainers;
public class TestcontainersTests(ITestOutputHelper testOutputHelper)
public class TestcontainersTests(ITestOutputHelper testOutputHelper, ITestContextAccessor testContext)
{
private readonly CancellationToken _ct = testContext.Current.CancellationToken;
private readonly ILogger _logger = new XUnitLogger(testOutputHelper, new LoggerExternalScopeProvider(), nameof(TestcontainersTests), new XUnitLoggerOptions
{
IncludeCategory = true,
@@ -34,6 +35,8 @@ public class TestcontainersTests(ITestOutputHelper testOutputHelper)
.WithCleanUp(true)
.Build();
await Task.Delay(500, _ct);
await StartTestAsync(wireMockContainer);
await StopAsync(wireMockContainer);
}
@@ -53,6 +56,8 @@ public class TestcontainersTests(ITestOutputHelper testOutputHelper)
.WithWatchStaticMappings(true)
.Build();
await Task.Delay(500, _ct);
await StartTestAsync(wireMockContainer);
await StopAsync(wireMockContainer);
}
@@ -79,6 +84,8 @@ public class TestcontainersTests(ITestOutputHelper testOutputHelper)
var wireMockContainer = wireMockContainerBuilder.Build();
await Task.Delay(500, _ct);
await StartTestAsync(wireMockContainer);
await StopAsync(wireMockContainer);
}
@@ -105,14 +112,18 @@ public class TestcontainersTests(ITestOutputHelper testOutputHelper)
var wireMockContainer = wireMockContainerBuilder.Build();
await Task.Delay(500, _ct);
await StartTestAsync(wireMockContainer);
await StopAsync(wireMockContainer);
}
private static async Task StartTestAsync(WireMockContainer wireMockContainer)
private async Task StartTestAsync(WireMockContainer wireMockContainer)
{
// Start
await wireMockContainer.StartAsync();
await wireMockContainer.StartAsync(_ct);
await Task.Delay(500, _ct);
// Assert
using (new AssertionScope())
@@ -16,7 +16,7 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
private readonly CancellationToken _ct = testContext.Current.CancellationToken;
[Fact]
public async Task WithNoSetupShouldJustWaitForClose_AndCLose_When_ClientCloses()
public async Task WithNoSetupShouldJustWaitForClose_AndClose_When_ClientCloses()
{
// Arrange
using var server = WireMockServer.Start(new WireMockServerSettings
@@ -706,12 +706,14 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
public async Task WithWebSocketProxy_Should_Proxy_Multiple_TextMessages()
{
// Arrange - Start target echo server
var exampleEchoServer = WireMockServer.Start(new WireMockServerSettings
using var exampleEchoServer = WireMockServer.Start(new WireMockServerSettings
{
Logger = new TestOutputHelperWireMockLogger(output),
Urls = ["ws://localhost:0"]
});
await Task.Delay(500, _ct);
exampleEchoServer
.Given(Request.Create()
.WithPath("/ws/target")
@@ -721,13 +723,17 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
.WithWebSocket(ws => ws.WithEcho())
);
await Task.Delay(500, _ct);
// Arrange - Start proxy server
var sut = WireMockServer.Start(new WireMockServerSettings
using var sut = WireMockServer.Start(new WireMockServerSettings
{
Logger = new TestOutputHelperWireMockLogger(output),
Urls = ["ws://localhost:0"]
});
await Task.Delay(500, _ct);
sut
.Given(Request.Create()
.WithPath("/ws/proxy")
@@ -737,6 +743,8 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
.WithWebSocketProxy($"{exampleEchoServer.Url}/ws/target")
);
await Task.Delay(500, _ct);
using var client = new ClientWebSocket();
var proxyUri = new Uri($"{sut.Url}/ws/proxy");
await client.ConnectAsync(proxyUri, _ct);
@@ -757,26 +765,20 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
}
await client.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(250, _ct);
sut.Stop();
sut.Dispose();
exampleEchoServer.Stop();
exampleEchoServer.Dispose();
}
[Fact]
public async Task WithWebSocketProxy_Should_Proxy_Binary_Messages()
{
// Arrange - Start target echo server
var exampleEchoServer = WireMockServer.Start(new WireMockServerSettings
using var exampleEchoServer = WireMockServer.Start(new WireMockServerSettings
{
Logger = new TestOutputHelperWireMockLogger(output),
Urls = ["ws://localhost:0"]
});
await Task.Delay(500, _ct);
exampleEchoServer
.Given(Request.Create()
.WithPath("/ws/target")
@@ -786,13 +788,17 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
.WithWebSocket(ws => ws.WithEcho())
);
await Task.Delay(500, _ct);
// Arrange - Start proxy server
var sut = WireMockServer.Start(new WireMockServerSettings
using var sut = WireMockServer.Start(new WireMockServerSettings
{
Logger = new TestOutputHelperWireMockLogger(output),
Urls = ["ws://localhost:0"]
});
await Task.Delay(500, _ct);
sut
.Given(Request.Create()
.WithPath("/ws/proxy")
@@ -802,6 +808,8 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
.WithWebSocketProxy($"{exampleEchoServer.Url}/ws/target")
);
await Task.Delay(500, _ct);
using var client = new ClientWebSocket();
var proxyUri = new Uri($"{sut.Url}/ws/proxy");
await client.ConnectAsync(proxyUri, _ct);
@@ -820,15 +828,9 @@ public class WebSocketIntegrationTests(ITestOutputHelper output, ITestContextAcc
// Assert
receivedData.Should().BeEquivalentTo(testData, "binary data should be proxied and echoed back");
await Task.Delay(500, _ct);
await client.CloseAsync(WebSocketCloseStatus.NormalClosure, "Test complete", _ct);
await Task.Delay(250, _ct);
sut.Stop();
sut.Dispose();
exampleEchoServer.Stop();
exampleEchoServer.Dispose();
}
[Fact]
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>Stef Heyenrath</Authors>
<OutputType>Exe</OutputType>
<TargetFrameworks>net48;net8.0</TargetFrameworks>
<TargetFrameworks>net48;net8.0;net10.0</TargetFrameworks>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<DebugType>full</DebugType>
@@ -69,7 +69,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -35,8 +35,12 @@ public partial class WireMockServerTests
: 403
}));
#if NET9_0_OR_GREATER
var certificates = X509CertificateLoader.LoadPkcs12CollectionFromFile("client_cert.pfx", "1234", X509KeyStorageFlags.Exportable);
#else
var certificates = new X509Certificate2Collection();
certificates.Import("client_cert.pfx", "1234", X509KeyStorageFlags.Exportable);
#endif
var httpMessageHandler = new HttpClientHandler
{
@@ -482,6 +482,7 @@ public partial class WireMockServerTests
server.Stop();
}
#if !NET48
[Fact]
public async Task WireMockServer_WithSseBody()
{
@@ -527,13 +528,19 @@ public partial class WireMockServerTests
using var reader = new StreamReader(response);
var data = string.Empty;
while (!reader.EndOfStream)
while (true)
{
var line = reader.ReadLine();
var line = await reader.ReadLineAsync(_ct);
if (line is null)
{
break;
}
data += line;
}
// Assert 2
data.Should().Be("x 1;x 2;x 3;");
}
#endif
}