Compare commits

..
Author SHA1 Message Date
dependabot[bot]andGitHub bb5d1a1925 Bump SSH.NET from 2025.1.0 to 2026.0.0
---
updated-dependencies:
- dependency-name: SSH.NET
  dependency-version: 2026.0.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-13 05:04:49 +00:00
Dmytro NikitinandGitHub 7a8582fef5 Fix #1494: WithClientIP(MatchOperator, IStringMatcher[]) ignores the operator (#1495) 2026-08-09 18:49:13 +02:00
Stef Heyenrath 05929bdea6 remove copilot-setup-steps.yml 2026-08-06 20:15:30 +02:00
Stef Heyenrath 84c32d5b2d 2.14.0 2026-08-06 19:32:33 +02:00
Dmytro NikitinandGitHub d39f7c771f Fix #1492: Serialize WithClientIP matcher to Request.ClientIP (#1493) 2026-08-06 19:28:40 +02:00
15 changed files with 135 additions and 47 deletions
-36
View File
@@ -1,36 +0,0 @@
name: "Copilot Setup Steps"
# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest
# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read
# You can define any steps you want, and they will run before the agent starts.
# If you do not check out your code, Copilot will do this for you.
steps:
- name: Install .NET 10.x
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
10.x
dotnet-quality: preview
- name: dotnet --info
run: dotnet --info
+4
View File
@@ -1,3 +1,7 @@
# 2.14.0 (06 August 2026)
- [#1493](https://github.com/wiremock/WireMock.Net/pull/1493) - Fix #1492: Serialize WithClientIP matcher to Request.ClientIP [bug] contributed by [Bafyn](https://github.com/Bafyn)
- [#1492](https://github.com/wiremock/WireMock.Net/issues/1492) - `WithClientIP` matcher is lost / corrupted when a mapping is serialized [bug]
# 2.13.0 (19 July 2026)
- [#1488](https://github.com/wiremock/WireMock.Net/pull/1488) - feat(xunit logging): TestOutputHelperWireMockLogger [feature] contributed by [Stepami](https://github.com/Stepami)
- [#1490](https://github.com/wiremock/WireMock.Net/pull/1490) - Fix: Fully respect configured custom admin path (merge PR #1483) [feature] contributed by [Copilot](https://github.com/apps/copilot-swe-agent)
+1 -1
View File
@@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>2.13.0</VersionPrefix>
<VersionPrefix>2.14.0</VersionPrefix>
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
<PackageProjectUrl>https://github.com/wiremock/WireMock.Net</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
+1 -1
View File
@@ -1,6 +1,6 @@
rem https://github.com/StefH/GitHubReleaseNotes
SET version=2.13.0
SET version=2.14.0
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels wontfix test question invalid doc duplicate example environment --version %version% --token %GH_TOKEN%
+3 -4
View File
@@ -1,6 +1,5 @@
# 2.13.0 (19 July 2026)
- #1488 feat(xunit logging): TestOutputHelperWireMockLogger [feature]
- #1490 Fix: Fully respect configured custom admin path (merge PR #1483) [feature]
- #1482 WireMock.Minimal.Owin does not respect custom pathing for determining admin paths [bug]
# 2.14.0 (06 August 2026)
- #1493 Fix #1492: Serialize WithClientIP matcher to Request.ClientIP [bug]
- #1492 `WithClientIP` matcher is lost / corrupted when a mapping is serialized [bug]
The full release notes can be found here: https://github.com/wiremock/WireMock.Net/blob/master/CHANGELOG.md
@@ -19,7 +19,7 @@ public partial class Request
{
Guard.NotNullOrEmpty(matchers);
_requestMatchers.Add(new RequestMessageClientIPMatcher(MatchBehaviour.AcceptOnMatch, MatchOperator.Or, matchers));
_requestMatchers.Add(new RequestMessageClientIPMatcher(MatchBehaviour.AcceptOnMatch, matchOperator, matchers));
return this;
}
@@ -342,7 +342,7 @@ internal class MappingConverter(MatcherMapper mapper)
if (clientIPMatcher?.Matchers != null)
{
var clientIPMatchers = _mapper.Map(clientIPMatcher.Matchers);
mappingModel.Request.Path = new ClientIPModel
mappingModel.Request.ClientIP = new ClientIPModel
{
Matchers = clientIPMatchers,
MatchOperator = clientIPMatchers?.Length > 1 ? clientIPMatcher.MatchOperator.ToString() : null
@@ -155,7 +155,8 @@ public partial class WireMockServer
var clientIPModel = _settings.DefaultJsonSerializer.ParseJsonToken<ClientIPModel>(requestModel.ClientIP);
if (clientIPModel.Matchers != null)
{
requestBuilder = requestBuilder.WithPath(clientIPModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray());
var matchOperator = StringUtils.ParseMatchOperator(clientIPModel.MatchOperator);
requestBuilder = requestBuilder.WithClientIP(matchOperator, clientIPModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray());
}
}
}
@@ -38,6 +38,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SSH.NET" Version="2026.0.0" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
<PackageReference Include="Testcontainers" Version="4.12.0" />
</ItemGroup>
@@ -64,4 +64,23 @@ public class RequestBuilderWithClientIPTests
var requestMatchResult = new RequestMatchResult();
spec.GetMatchingScore(request, requestMatchResult).Should().Be(1.0);
}
[Fact]
public void Request_WithClientIP_MatchOperator_And_RequiresAllMatchers()
{
// given: two matchers combined with And (the client IP must satisfy BOTH)
var spec = Request.Create().WithClientIP(MatchOperator.And, new WildcardMatcher("1.2.*"), new WildcardMatcher("*.3.4"));
// when: an IP matching both matchers -> perfect match
var matchesBoth = new RequestMessage(new UrlDetails("http://localhost"), "GET", "1.2.3.4");
spec.GetMatchingScore(matchesBoth, new RequestMatchResult()).Should().Be(1.0);
// when: an IP matching only the first matcher -> mismatch
var matchesFirstOnly = new RequestMessage(new UrlDetails("http://localhost"), "GET", "1.2.9.9");
spec.GetMatchingScore(matchesFirstOnly, new RequestMatchResult()).Should().Be(0.0);
// when: an IP matching only the second matcher -> mismatch
var matchesSecondOnly = new RequestMessage(new UrlDetails("http://localhost"), "GET", "9.3.4");
spec.GetMatchingScore(matchesSecondOnly, new RequestMatchResult()).Should().Be(0.0);
}
}
@@ -0,0 +1,29 @@
{
Guid: Guid_1,
UpdatedAt: DateTime_1,
Title: ,
Description: ,
Priority: 42,
Request: {
ClientIP: {
Matchers: [
{
Name: WildcardMatcher,
Pattern: 1.2.3.4,
IgnoreCase: false
}
]
},
Path: {
Matchers: [
{
Name: WildcardMatcher,
Pattern: /foo,
IgnoreCase: false
}
]
}
},
Response: {},
UseWebhooksFireAndForget: false
}
@@ -5,7 +5,7 @@
Description: ,
Priority: 42,
Request: {
Path: {
ClientIP: {
Matchers: [
{
Name: WildcardMatcher,
@@ -5,7 +5,7 @@
Description: ,
Priority: 42,
Request: {
Path: {
ClientIP: {
Matchers: [
{
Name: WildcardMatcher,
@@ -0,0 +1,29 @@
[
{
Guid: Guid_1,
UpdatedAt: DateTime_1,
Request: {
ClientIP: {
Matchers: [
{
Name: WildcardMatcher,
Pattern: 1.2.3.4,
IgnoreCase: false
}
]
},
Path: {
Matchers: [
{
Name: WildcardMatcher,
Pattern: /foo,
IgnoreCase: false
}
]
}
},
Response: {
StatusCode: 200
}
}
]
@@ -6,6 +6,7 @@ using WireMock.Models;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Serialization;
using WireMock.Server;
using WireMock.Settings;
using WireMock.Types;
using WireMock.Util;
@@ -376,6 +377,47 @@ message HelloReply {
return Verify(model);
}
[Fact]
public Task ToMappingModel_Request_WithClientIP_And_Path_MapsClientIPToClientIPModel_NotPath()
{
// Arrange: a request that gates on BOTH ClientIP and Path.
var request = Request.Create().WithPath("/foo").WithClientIP("1.2.3.4");
var response = Response.Create();
var mapping = new Mapping(_guid, _updatedAt, string.Empty, string.Empty, null, _settings, request, response, 42, null, null, null, null, null, false, null, null);
// Act
var model = _sut.ToMappingModel(mapping);
// Assert
model.Should().NotBeNull();
// Verify
return Verify(model);
}
[Fact]
public Task WithClientIP_And_Path_SurvivesMappingModelRoundTrip_AsClientIPMatcher()
{
// Arrange: a server with a mapping that gates on BOTH ClientIP and Path.
using var source = WireMockServer.Start();
source
.Given(Request.Create().WithPath("/foo").WithClientIP("1.2.3.4"))
.RespondWith(Response.Create().WithSuccess());
var models = source.MappingModels.ToArray();
models.Should().ContainSingle();
// Act
using var target = WireMockServer.Start();
target.WithMapping(models);
// Assert
var request = (Request)target.Mappings.Single(m => !m.IsAdminInterface).RequestMatcher;
// Verify
return Verify(target.MappingModels);
}
[Fact]
public Task ToMappingModel_Request_WithHeader_And_Cookie_ReturnsCorrectModel()
{