mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-06-13 10:14:31 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cbc28c235c | |||
| dd1aa5139e |
@@ -1,3 +1,8 @@
|
||||
# 2.11.0 (12 June 2026)
|
||||
- [#1475](https://github.com/wiremock/WireMock.Net/pull/1475) - Update NuGet packages (Aspire, MessagePack and more) [security] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1476](https://github.com/wiremock/WireMock.Net/pull/1476) - Fix BodyParser [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1473](https://github.com/wiremock/WireMock.Net/issues/1473) - JsonPartialWildCardMatcher With DateTime Regex Stopped Matching (Regression?) [bug]
|
||||
|
||||
# 2.10.0 (07 June 2026)
|
||||
- [#1472](https://github.com/wiremock/WireMock.Net/pull/1472) - Update JsonConverter to 0.13.0 [bug] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>2.10.0</VersionPrefix>
|
||||
<VersionPrefix>2.11.0</VersionPrefix>
|
||||
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
|
||||
<PackageProjectUrl>https://github.com/wiremock/WireMock.Net</PackageProjectUrl>
|
||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
rem https://github.com/StefH/GitHubReleaseNotes
|
||||
|
||||
SET version=2.10.0
|
||||
SET version=2.11.0
|
||||
|
||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels wontfix test question invalid doc duplicate example environment --version %version% --token %GH_TOKEN%
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# 2.10.0 (07 June 2026)
|
||||
- #1472 Update JsonConverter to 0.13.0 [bug]
|
||||
# 2.11.0 (12 June 2026)
|
||||
- #1475 Update NuGet packages (Aspire, MessagePack and more) [security]
|
||||
- #1476 Fix BodyParser [bug]
|
||||
- #1473 JsonPartialWildCardMatcher With DateTime Regex Stopped Matching (Regression?) [bug]
|
||||
|
||||
The full release notes can be found here: https://github.com/wiremock/WireMock.Net/blob/master/CHANGELOG.md
|
||||
@@ -305,12 +305,6 @@ public class WireMockServerSettings
|
||||
[PublicAPI, JsonIgnore]
|
||||
public IDictionary<string, Func<MatcherModel, IMatcher>>? CustomMatcherMappings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="JsonSerializerSettings"/> used when the JSON response is generated.
|
||||
/// </summary>
|
||||
[PublicAPI, JsonIgnore]
|
||||
public JsonSerializerSettings? JsonSerializerSettings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Culture to use.
|
||||
/// Currently used for:
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using Stef.Validation;
|
||||
using WireMock.Constants;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Serialization;
|
||||
using WireMock.Types;
|
||||
|
||||
namespace WireMock.Util;
|
||||
@@ -25,7 +26,7 @@ internal static class BodyParser
|
||||
CONNECT - No defined body semantics
|
||||
PATCH - Body supported.
|
||||
*/
|
||||
private static readonly IDictionary<string, bool> BodyAllowedForMethods = new Dictionary<string, bool>
|
||||
private static readonly Dictionary<string, bool> BodyAllowedForMethods = new()
|
||||
{
|
||||
{ HttpRequestMethod.HEAD, false },
|
||||
{ HttpRequestMethod.GET, false },
|
||||
@@ -173,7 +174,7 @@ internal static class BodyParser
|
||||
{
|
||||
try
|
||||
{
|
||||
data.BodyAsJson = settings.DefaultJsonConverter.Deserialize<object>(data.BodyAsString);
|
||||
data.BodyAsJson = settings.DefaultJsonConverter.Deserialize<object>(data.BodyAsString, JsonSerializationConstants.JsonConverterOptionsWithDateParsingNone);
|
||||
data.DetectedBodyType = BodyType.Json;
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -416,4 +416,20 @@ public class JsonPartialWildcardMatcherTests
|
||||
// Assert
|
||||
Assert.Equal(1.0, match);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonPartialWildcardMatcher_IsMatch_WithRegexTrue_DateFormat_ShouldMatch()
|
||||
{
|
||||
// Assign
|
||||
var matcher = new JsonPartialWildcardMatcher(
|
||||
new { date = "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$", id = 1 },
|
||||
ignoreCase: false,
|
||||
regex: true);
|
||||
|
||||
// Act
|
||||
var match = matcher.IsMatch("{\"date\":\"2026-06-09T22:23:18.53421+00:00\",\"id\":1}").Score;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(1.0, match);
|
||||
}
|
||||
}
|
||||
@@ -366,17 +366,33 @@ public class SystemTextJsonPartialWildcardMatcherTests
|
||||
Assert.Equal(1.0, match);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SystemTextJsonPartialWildcardMatcher_IsMatch_JsonElement_ShouldMatch()
|
||||
{
|
||||
// Assign
|
||||
var matcher = new SystemTextJsonPartialWildcardMatcher(new { Id = 1, Name = "Test" });
|
||||
[Fact]
|
||||
public void SystemTextJsonPartialWildcardMatcher_IsMatch_JsonElement_ShouldMatch()
|
||||
{
|
||||
// Assign
|
||||
var matcher = new SystemTextJsonPartialWildcardMatcher(new { Id = 1, Name = "Test" });
|
||||
|
||||
// Act
|
||||
var jsonElement = JsonDocument.Parse("{ \"Id\" : 1, \"Name\" : \"Test\", \"Extra\" : \"value\" }").RootElement;
|
||||
var match = matcher.IsMatch(jsonElement).Score;
|
||||
// Act
|
||||
var jsonElement = JsonDocument.Parse("{ \"Id\" : 1, \"Name\" : \"Test\", \"Extra\" : \"value\" }").RootElement;
|
||||
var match = matcher.IsMatch(jsonElement).Score;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(1.0, match);
|
||||
// Assert
|
||||
Assert.Equal(1.0, match);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SystemTextJsonPartialWildcardMatcher_IsMatch_WithRegexTrue_DateFormat_ShouldMatch()
|
||||
{
|
||||
// Assign
|
||||
var matcher = new SystemTextJsonPartialWildcardMatcher(
|
||||
new { date = "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$", id = 1 },
|
||||
ignoreCase: false,
|
||||
regex: true);
|
||||
|
||||
// Act
|
||||
var match = matcher.IsMatch("{\"date\":\"2026-06-09T22:23:18.53421+00:00\",\"id\":1}").Score;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(1.0, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,81 @@ public partial class WireMockServerTests
|
||||
response.Should().BeEquivalentTo("{\"first_name\":\"John\",\"last_name\":\"Smith\"}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsJson_WithJsonPartialWildcardMatcher()
|
||||
{
|
||||
// Arrange
|
||||
using var server = WireMockServer.Start(new WireMockServerSettings
|
||||
{
|
||||
Logger = new TestOutputHelperWireMockLogger(testOutputHelper)
|
||||
});
|
||||
server
|
||||
.Given(
|
||||
Request.Create()
|
||||
.WithPath("/test")
|
||||
.UsingPost()
|
||||
.WithBody(new JsonPartialWildcardMatcher(
|
||||
new
|
||||
{
|
||||
date = @"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$",
|
||||
id = 1
|
||||
},
|
||||
ignoreCase: true,
|
||||
regex: true
|
||||
)
|
||||
)
|
||||
)
|
||||
.RespondWith(Response.Create().WithStatusCode(200).WithBody("matched"));
|
||||
|
||||
// Act
|
||||
var requestUri = new Uri($"http://localhost:{server.Port}/test");
|
||||
|
||||
var response = await server.CreateClient().PostAsync(requestUri, new StringContent("{\"date\":\"2026-06-09T22:23:18.53421+00:00\",\"id\":1}"), _ct);
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsJson_WithSystemTextJsonPartialWildcardMatcher()
|
||||
{
|
||||
// Arrange
|
||||
using var server = WireMockServer.Start(new WireMockServerSettings
|
||||
{
|
||||
Logger = new TestOutputHelperWireMockLogger(testOutputHelper),
|
||||
DefaultJsonSerializer = new SystemTextJsonConverter()
|
||||
});
|
||||
server
|
||||
.Given(
|
||||
Request.Create()
|
||||
.WithPath("/test")
|
||||
.UsingPost()
|
||||
.WithBody(new SystemTextJsonPartialWildcardMatcher(
|
||||
new
|
||||
{
|
||||
date = @"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$",
|
||||
id = 1
|
||||
},
|
||||
ignoreCase: true,
|
||||
regex: true
|
||||
)
|
||||
)
|
||||
)
|
||||
.RespondWith(Response.Create().WithStatusCode(200).WithBody("matched"));
|
||||
|
||||
// Act
|
||||
var requestUri = new Uri($"http://localhost:{server.Port}/test");
|
||||
|
||||
var response = await server.CreateClient().PostAsync(requestUri, new StringContent("{\"date\":\"2026-06-09T22:23:18.53421+00:00\",\"id\":1}"), _ct);
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithBodyAsJson_Using_PostAsJsonAsync_And_MultipleJmesPathMatchers_ShouldMatch()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user