From 3693d6a676553c4cbf10319d0e904d8ff4eb6f9b Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Tue, 29 Oct 2024 19:52:31 +0100 Subject: [PATCH 1/9] Log exception when (static) mapping file cannot be read (#1202) --- src/WireMock.Net.Abstractions/Logging/IWireMockLogger.cs | 4 ++-- src/WireMock.Net/Logging/WireMockConsoleLogger.cs | 4 ++-- src/WireMock.Net/Logging/WireMockNullLogger.cs | 2 +- src/WireMock.Net/Server/WireMockServer.Admin.cs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/WireMock.Net.Abstractions/Logging/IWireMockLogger.cs b/src/WireMock.Net.Abstractions/Logging/IWireMockLogger.cs index c68ce26d..c8d5a3d9 100644 --- a/src/WireMock.Net.Abstractions/Logging/IWireMockLogger.cs +++ b/src/WireMock.Net.Abstractions/Logging/IWireMockLogger.cs @@ -51,10 +51,10 @@ public interface IWireMockLogger /// /// Writes the message at the Error level using the specified exception. /// - /// The format string. + /// The message. /// The exception. [PublicAPI] - void Error(string formatString, Exception exception); + void Error(string message, Exception exception); /// /// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more). diff --git a/src/WireMock.Net/Logging/WireMockConsoleLogger.cs b/src/WireMock.Net/Logging/WireMockConsoleLogger.cs index 37b6b3ce..092e54e3 100644 --- a/src/WireMock.Net/Logging/WireMockConsoleLogger.cs +++ b/src/WireMock.Net/Logging/WireMockConsoleLogger.cs @@ -52,9 +52,9 @@ public void Error(string formatString, params object[] args) } /// - public void Error(string formatString, Exception exception) + public void Error(string message, Exception exception) { - Console.WriteLine(Format("Error", formatString, exception.Message)); + Console.WriteLine(Format("Error", $"{message} {{0}}", exception.Message)); if (exception is AggregateException ae) { diff --git a/src/WireMock.Net/Logging/WireMockNullLogger.cs b/src/WireMock.Net/Logging/WireMockNullLogger.cs index 3db1d186..148d7d95 100644 --- a/src/WireMock.Net/Logging/WireMockNullLogger.cs +++ b/src/WireMock.Net/Logging/WireMockNullLogger.cs @@ -36,7 +36,7 @@ public void Error(string formatString, params object[] args) } /// - public void Error(string formatString, Exception exception) + public void Error(string message, Exception exception) { // Log nothing } diff --git a/src/WireMock.Net/Server/WireMockServer.Admin.cs b/src/WireMock.Net/Server/WireMockServer.Admin.cs index a7cf33ca..8f39a9a7 100644 --- a/src/WireMock.Net/Server/WireMockServer.Admin.cs +++ b/src/WireMock.Net/Server/WireMockServer.Admin.cs @@ -178,9 +178,9 @@ public void ReadStaticMappings(string? folder = null) { ReadStaticMappingAndAddOrUpdate(filename); } - catch + catch (Exception exception) { - _settings.Logger.Error("Static MappingFile : '{0}' could not be read. This file will be skipped.", filename); + _settings.Logger.Error($"Static MappingFile : '{filename}' could not be read. This file will be skipped.", exception); } } } From 38c2131472884d8372b124fdd22fd724046215b7 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Tue, 29 Oct 2024 19:55:02 +0100 Subject: [PATCH 2/9] IWireMockLogger.Error(string, Exception) --- src/WireMock.Net/Logging/WireMockConsoleLogger.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WireMock.Net/Logging/WireMockConsoleLogger.cs b/src/WireMock.Net/Logging/WireMockConsoleLogger.cs index 092e54e3..04ba6939 100644 --- a/src/WireMock.Net/Logging/WireMockConsoleLogger.cs +++ b/src/WireMock.Net/Logging/WireMockConsoleLogger.cs @@ -54,13 +54,13 @@ public void Error(string formatString, params object[] args) /// public void Error(string message, Exception exception) { - Console.WriteLine(Format("Error", $"{message} {{0}}", exception.Message)); + Console.WriteLine(Format("Error", $"{message} {{0}}", exception)); if (exception is AggregateException ae) { ae.Handle(ex => { - Console.WriteLine(Format("Error", "Exception {0}", ex.Message)); + Console.WriteLine(Format("Error", "Exception {0}", ex)); return true; }); } From edab3ad7e5e4a25aa298bb3fa08f7f547288aba4 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Fri, 1 Nov 2024 10:31:23 +0100 Subject: [PATCH 3/9] WireMockLogger --- src/dotnet-WireMock.Net/WireMockLogger.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dotnet-WireMock.Net/WireMockLogger.cs b/src/dotnet-WireMock.Net/WireMockLogger.cs index 1115e28d..29a03b70 100644 --- a/src/dotnet-WireMock.Net/WireMockLogger.cs +++ b/src/dotnet-WireMock.Net/WireMockLogger.cs @@ -47,9 +47,9 @@ public void Error(string formatString, params object[] args) } /// - public void Error(string formatString, Exception exception) + public void Error(string message, Exception exception) { - _logger.LogError(exception, formatString); + _logger.LogError(exception, message); } /// From f4103b47aa0b220faf88aadda1082e7673a274e4 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sun, 17 Nov 2024 17:25:21 +0100 Subject: [PATCH 4/9] Fix security issues (#1206) * . * . * x --- Directory.Build.props | 8 +++++++- .../WireMock.Net.Abstractions.csproj | 9 ++++++--- src/WireMock.Net.Aspire/WireMock.Net.Aspire.csproj | 2 +- .../WireMock.Net.OpenApiParser.csproj | 2 +- .../WireMock.Net.RestClient.csproj | 6 +++--- src/WireMock.Net.TUnit/WireMock.Net.TUnit.csproj | 2 +- .../WireMock.Net.Testcontainers.csproj | 2 +- src/WireMock.Net.xUnit/WireMock.Net.xUnit.csproj | 2 +- src/WireMock.Net/WireMock.Net.csproj | 14 ++++++++------ .../WireMock.Org.RestClient.csproj | 4 ++-- .../WireMock.Net.Aspire.TestAppHost.csproj | 2 +- .../WireMock.Net.Aspire.Tests.csproj | 2 +- .../WireMock.Net.TUnitTests.csproj | 2 +- test/WireMock.Net.Tests/WireMock.Net.Tests.csproj | 6 +++--- 14 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 5867ab1e..255a3257 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -43,11 +43,17 @@ + + true + + all + + - + diff --git a/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj b/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj index 7a0d9b4e..85cf222e 100644 --- a/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj +++ b/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj @@ -4,7 +4,7 @@ Commonly used models, enumerations and types. WireMock.Net.Abstractions Stef Heyenrath - net45;net451;net461;netstandard1.0;netstandard1.3;netstandard2.0;netstandard2.1 + net45;net451;net461;netstandard1.3;netstandard2.0;netstandard2.1 true $(NoWarn);1591;8603 WireMock.Net.Abstractions @@ -36,15 +36,18 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/WireMock.Net.Aspire/WireMock.Net.Aspire.csproj b/src/WireMock.Net.Aspire/WireMock.Net.Aspire.csproj index dd1039e3..40d6cc81 100644 --- a/src/WireMock.Net.Aspire/WireMock.Net.Aspire.csproj +++ b/src/WireMock.Net.Aspire/WireMock.Net.Aspire.csproj @@ -35,7 +35,7 @@ - + diff --git a/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj b/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj index 21d0eb7c..4dea3733 100644 --- a/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj +++ b/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj @@ -26,7 +26,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj b/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj index 0a025845..f3802517 100644 --- a/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj +++ b/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj @@ -4,7 +4,7 @@ A RestClient using RestEase to access the admin interface. WireMock.Net.RestClient Stef Heyenrath - net45;netstandard1.1;netstandard2.0;netstandard2.1 + net45;netstandard1.3;netstandard2.0;netstandard2.1 true WireMock.Net.RestClient WireMock.Net.RestClient @@ -30,8 +30,8 @@ - - + + diff --git a/src/WireMock.Net.TUnit/WireMock.Net.TUnit.csproj b/src/WireMock.Net.TUnit/WireMock.Net.TUnit.csproj index 47c9c3c4..71d6bedb 100644 --- a/src/WireMock.Net.TUnit/WireMock.Net.TUnit.csproj +++ b/src/WireMock.Net.TUnit/WireMock.Net.TUnit.csproj @@ -28,7 +28,7 @@ - + diff --git a/src/WireMock.Net.Testcontainers/WireMock.Net.Testcontainers.csproj b/src/WireMock.Net.Testcontainers/WireMock.Net.Testcontainers.csproj index ca55a717..42aacad7 100644 --- a/src/WireMock.Net.Testcontainers/WireMock.Net.Testcontainers.csproj +++ b/src/WireMock.Net.Testcontainers/WireMock.Net.Testcontainers.csproj @@ -28,7 +28,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/WireMock.Net.xUnit/WireMock.Net.xUnit.csproj b/src/WireMock.Net.xUnit/WireMock.Net.xUnit.csproj index e0162f4c..48496be1 100644 --- a/src/WireMock.Net.xUnit/WireMock.Net.xUnit.csproj +++ b/src/WireMock.Net.xUnit/WireMock.Net.xUnit.csproj @@ -3,7 +3,7 @@ Some extensions for xUnit (ITestOutputHelper) WireMock.Net.xUnit Stef Heyenrath - net45;net451;netstandard1.0;netstandard2.0;netstandard2.1 + net45;net451;netstandard1.3;netstandard2.0;netstandard2.1 true WireMock.Net.xUnit WireMock.Net.Xunit diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index 38a90fbc..a55ee930 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -59,13 +59,13 @@ - + - - + + @@ -108,9 +108,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - - @@ -192,6 +189,11 @@ + + + + + diff --git a/src/WireMock.Org.RestClient/WireMock.Org.RestClient.csproj b/src/WireMock.Org.RestClient/WireMock.Org.RestClient.csproj index a6de3c8c..e21ce895 100644 --- a/src/WireMock.Org.RestClient/WireMock.Org.RestClient.csproj +++ b/src/WireMock.Org.RestClient/WireMock.Org.RestClient.csproj @@ -30,8 +30,8 @@ - - + + diff --git a/test/WireMock.Net.Aspire.TestAppHost/WireMock.Net.Aspire.TestAppHost.csproj b/test/WireMock.Net.Aspire.TestAppHost/WireMock.Net.Aspire.TestAppHost.csproj index 114bf78b..bd2cf52a 100644 --- a/test/WireMock.Net.Aspire.TestAppHost/WireMock.Net.Aspire.TestAppHost.csproj +++ b/test/WireMock.Net.Aspire.TestAppHost/WireMock.Net.Aspire.TestAppHost.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj b/test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj index 62e6f68f..246c1c61 100644 --- a/test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj +++ b/test/WireMock.Net.Aspire.Tests/WireMock.Net.Aspire.Tests.csproj @@ -13,7 +13,7 @@ - + all diff --git a/test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj b/test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj index ad95b7fd..ac4bf011 100644 --- a/test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj +++ b/test/WireMock.Net.TUnitTests/WireMock.Net.TUnitTests.csproj @@ -9,7 +9,7 @@ - + diff --git a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj index 30ff6c6d..9f7f78e4 100644 --- a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj +++ b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj @@ -72,10 +72,10 @@ - + - + @@ -104,7 +104,7 @@ - + From 6f73dfe360c86e897e4531eb5f410bdc6a747911 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Mon, 18 Nov 2024 10:23:00 +0100 Subject: [PATCH 5/9] Use GraphQL 8.2.1 (#1211) --- src/WireMock.Net/Matchers/GraphQLMatcher.cs | 10 ++--- src/WireMock.Net/WireMock.Net.csproj | 3 +- .../Matchers/GraphQLMatcherTests.cs | 42 ++++++++++++------- .../WireMock.Net.Tests.csproj | 1 - 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/WireMock.Net/Matchers/GraphQLMatcher.cs b/src/WireMock.Net/Matchers/GraphQLMatcher.cs index 305b973e..2227b371 100644 --- a/src/WireMock.Net/Matchers/GraphQLMatcher.cs +++ b/src/WireMock.Net/Matchers/GraphQLMatcher.cs @@ -113,16 +113,16 @@ public MatchResult IsMatch(string? input) { try { - var executionResult = new DocumentExecuter().ExecuteAsync(_ => + var executionResult = new DocumentExecuter().ExecuteAsync(eo => { - _.ThrowOnUnhandledException = true; + eo.ThrowOnUnhandledException = true; - _.Schema = _schema; - _.Query = graphQLRequest.Query; + eo.Schema = _schema; + eo.Query = graphQLRequest.Query; if (graphQLRequest.Variables != null) { - _.Variables = new Inputs(graphQLRequest.Variables); + eo.Variables = new Inputs(graphQLRequest.Variables); } }).GetAwaiter().GetResult(); diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index a55ee930..17711cbc 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -144,8 +144,7 @@ - - + diff --git a/test/WireMock.Net.Tests/Matchers/GraphQLMatcherTests.cs b/test/WireMock.Net.Tests/Matchers/GraphQLMatcherTests.cs index ac1ddfb3..1091c957 100644 --- a/test/WireMock.Net.Tests/Matchers/GraphQLMatcherTests.cs +++ b/test/WireMock.Net.Tests/Matchers/GraphQLMatcherTests.cs @@ -107,22 +107,32 @@ public void GraphQLMatcher_For_ValidSchema_And_CorrectGraphQL_Mutation_IsMatch() public void GraphQLMatcher_For_ValidSchema_And_CorrectGraphQL_UsingCustomType_Mutation_IsMatch() { // Arrange - const string testSchema = @" - scalar DateTime - scalar MyCustomScalar - - type Message { - id: ID! - } - - type Mutation { - createMessage(x: MyCustomScalar, dt: DateTime): Message - }"; - - var input = @"{ - ""query"": ""mutation CreateMessage($x: MyCustomScalar!, $dt: DateTime!) { createMessage(x: $x, dt: $dt) { id } }"", - ""variables"": { ""x"": 100, ""dt"": ""2007-12-03T10:15:30Z"" } -}"; + // Query is provided here: https://stackoverflow.com/questions/59608833/apollo-graphql-error-query-root-type-must-be-provided + const string testSchema = + """ + scalar DateTime + scalar MyCustomScalar + + type Query { + _empty: String + } + + type Message { + id: ID! + } + + type Mutation { + createMessage(x: MyCustomScalar, dt: DateTime): Message + } + """; + + const string input = + """ + { + "query": "mutation CreateMessage($x: MyCustomScalar!, $dt: DateTime!) { createMessage(x: $x, dt: $dt) { id } }", + "variables": { "x": 100, "dt": "2007-12-03T10:15:30Z" } + } + """; var customScalars = new Dictionary { { "MyCustomScalar", typeof(int) } }; diff --git a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj index 9f7f78e4..2468b7e4 100644 --- a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj +++ b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj @@ -105,7 +105,6 @@ - From 4aaed2a6caf6d293943a68d64457d46a9a168bfb Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Fri, 22 Nov 2024 07:58:23 +0100 Subject: [PATCH 6/9] Fix HandlebarsContext ParseAndEvaluate method (#1213) * Fix HandlebarsContext ParseAndEvaluate method * test * xxx --- WireMock.Net Solution.sln | 3 +++ .../Handlebars/HandlebarsContext.cs | 4 +++- test/Directory.Build.props | 8 +++++++ .../ResponseWithTransformerTests.cs | 23 +++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/Directory.Build.props diff --git a/WireMock.Net Solution.sln b/WireMock.Net Solution.sln index ea1480ff..168771e8 100644 --- a/WireMock.Net Solution.sln +++ b/WireMock.Net Solution.sln @@ -6,6 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8F890C6F-9ACC-438D-928A-AD61CDA862F2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0BB8B634-407A-4610-A91F-11586990767A}" + ProjectSection(SolutionItems) = preProject + test\Directory.Build.props = test\Directory.Build.props + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net", "src\WireMock.Net\WireMock.Net.csproj", "{D3804228-91F4-4502-9595-39584E5A01AD}" EndProject diff --git a/src/WireMock.Net/Transformers/Handlebars/HandlebarsContext.cs b/src/WireMock.Net/Transformers/Handlebars/HandlebarsContext.cs index cfc998f9..5907e188 100644 --- a/src/WireMock.Net/Transformers/Handlebars/HandlebarsContext.cs +++ b/src/WireMock.Net/Transformers/Handlebars/HandlebarsContext.cs @@ -27,7 +27,9 @@ public string ParseAndRender(string text, object model) public object? ParseAndEvaluate(string text, object model) { - if (Handlebars.TryEvaluate(text, model, out var result) && result is not UndefinedBindingResult) + if (text.StartsWith("{{") && text.EndsWith("}}") && + Handlebars.TryEvaluate(text, model, out var result) && + result is not UndefinedBindingResult) { return result; } diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 00000000..c6070279 --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithTransformerTests.cs b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithTransformerTests.cs index 278d4615..d6727acd 100644 --- a/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithTransformerTests.cs +++ b/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithTransformerTests.cs @@ -130,6 +130,29 @@ public async Task Response_ProvideResponse_Handlebars_PathSegments() Check.That(response.Message.BodyData!.BodyAsString).Equals("a wiremock"); } + [Theory] + [InlineData("{{request.PathSegments.[0]}}", "a")] + [InlineData("prefix_{{request.PathSegments.[0]}}", "prefix_a")] + [InlineData("{{request.PathSegments.[0]}}_postfix", "a_postfix")] + [InlineData("prefix_{{request.PathSegments.[0]}}_postfix", "prefix_a_postfix")] + public async Task Response_ProvideResponse_Handlebars_BodyAsJson_PathSegments(string field, string expected) + { + // Assign + var urlDetails = UrlUtils.Parse(new Uri("http://localhost/wiremock/a/b"), new PathString("/wiremock")); + var request = new RequestMessage(urlDetails, "POST", ClientIp); + + var responseBuilder = Response.Create() + .WithBodyAsJson(new { field }) + .WithTransformer(); + + // Act + var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false); + + // Assert + var json = (JObject)response.Message.BodyData!.BodyAsJson!; + Check.That(json["field"]!.Value()).Equals(expected); + } + [Theory(Skip = "Invalid token `OpenBracket`")] [InlineData(TransformerType.Scriban)] [InlineData(TransformerType.ScribanDotLiquid)] From 4b3e9feca070320702cd8237b40865ad17d05d5a Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sun, 24 Nov 2024 16:22:32 +0100 Subject: [PATCH 7/9] 1.6.8 --- CHANGELOG.md | 9 +++++++++ Directory.Build.props | 2 +- Generate-ReleaseNotes.cmd | 2 +- PackageReleaseNotes.txt | 17 ++++++++--------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d151c059..a4d9aec8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# 1.6.8 (23 November 2024) +- [#1202](https://github.com/WireMock-Net/WireMock.Net/pull/1202) - Log exception when (static) mapping file cannot be read [feature] contributed by [StefH](https://github.com/StefH) +- [#1206](https://github.com/WireMock-Net/WireMock.Net/pull/1206) - Fix security issues [bug] contributed by [StefH](https://github.com/StefH) +- [#1211](https://github.com/WireMock-Net/WireMock.Net/pull/1211) - Use GraphQL 8.2.1 [feature] contributed by [StefH](https://github.com/StefH) +- [#1213](https://github.com/WireMock-Net/WireMock.Net/pull/1213) - Fix HandlebarsContext ParseAndEvaluate method [bug] contributed by [StefH](https://github.com/StefH) +- [#1201](https://github.com/WireMock-Net/WireMock.Net/issues/1201) - Mapping file parse errors are not logged to the console [feature] +- [#1209](https://github.com/WireMock-Net/WireMock.Net/issues/1209) - Upgrade of GraphQL libs to the latest [feature] +- [#1212](https://github.com/WireMock-Net/WireMock.Net/issues/1212) - Response Body Does Not Include Text After Path Segment [bug] + # 1.6.7 (17 October 2024) - [#1161](https://github.com/WireMock-Net/WireMock.Net/pull/1161) - Use latest ProtoBufJsonConverter to support WellKnownTypes [bug] contributed by [StefH](https://github.com/StefH) - [#1190](https://github.com/WireMock-Net/WireMock.Net/pull/1190) - Bump System.Text.Json from 8.0.4 to 8.0.5 in /examples/WireMock.Net.Console.Net472.Classic [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot) diff --git a/Directory.Build.props b/Directory.Build.props index 255a3257..7b0b9c21 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ - 1.6.7 + 1.6.8 WireMock.Net-Logo.png https://github.com/WireMock-Net/WireMock.Net Apache-2.0 diff --git a/Generate-ReleaseNotes.cmd b/Generate-ReleaseNotes.cmd index 17e7e420..28d76a38 100644 --- a/Generate-ReleaseNotes.cmd +++ b/Generate-ReleaseNotes.cmd @@ -1,6 +1,6 @@ rem https://github.com/StefH/GitHubReleaseNotes -SET version=1.6.7 +SET version=1.6.8 GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels test question invalid doc duplicate example environment --version %version% --token %GH_TOKEN% diff --git a/PackageReleaseNotes.txt b/PackageReleaseNotes.txt index 869f06c6..96b08418 100644 --- a/PackageReleaseNotes.txt +++ b/PackageReleaseNotes.txt @@ -1,11 +1,10 @@ -# 1.6.7 (17 October 2024) -- #1161 Use latest ProtoBufJsonConverter to support WellKnownTypes [bug] -- #1190 Bump System.Text.Json from 8.0.4 to 8.0.5 in /examples/WireMock.Net.Console.Net472.Classic [dependencies] -- #1194 Upgrade System.Text.RegularExpressions to 4.3.1 to solve CVE-2019-0820 [bug] -- #1197 Bump System.Text.Json from 8.0.4 to 8.0.5 in /src/dotnet-WireMock.Net [dependencies] -- #1198 Fix Google.Protobuf.WellKnownTypes.Value [bug] -- #1144 Using google.protobuf.Empty as response results in a bad gRPC response [bug] -- #1153 Grpc support for multiple proto files [feature] -- #1193 Snyk issue : Regular Expression Denial of Service [bug] +# 1.6.8 (23 November 2024) +- #1202 Log exception when (static) mapping file cannot be read [feature] +- #1206 Fix security issues [bug] +- #1211 Use GraphQL 8.2.1 [feature] +- #1213 Fix HandlebarsContext ParseAndEvaluate method [bug] +- #1201 Mapping file parse errors are not logged to the console [feature] +- #1209 Upgrade of GraphQL libs to the latest [feature] +- #1212 Response Body Does Not Include Text After Path Segment [bug] The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md \ No newline at end of file From 7f640dfa0d9be09e867431d337706d62b9e452aa Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Fri, 6 Dec 2024 09:23:31 +0100 Subject: [PATCH 8/9] Fix JsonPartialMatcher when using property names with dot (#1216) Fix JsonPartialMatcher when using property names with dot (#1216) --- .../Matchers/AbstractJsonPartialMatcher.cs | 2 +- .../Matchers/JsonPartialMatcherTests.cs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/WireMock.Net/Matchers/AbstractJsonPartialMatcher.cs b/src/WireMock.Net/Matchers/AbstractJsonPartialMatcher.cs index f3449458..234c6a85 100644 --- a/src/WireMock.Net/Matchers/AbstractJsonPartialMatcher.cs +++ b/src/WireMock.Net/Matchers/AbstractJsonPartialMatcher.cs @@ -82,7 +82,7 @@ protected override bool IsMatch(JToken value, JToken? input) case JTokenType.Object: var nestedValues = value.ToObject>(); return nestedValues?.Any() != true || - nestedValues.All(pair => IsMatch(pair.Value, input.SelectToken(pair.Key))); + nestedValues.All(pair => IsMatch(pair.Value, input.SelectToken(pair.Key) ?? input[pair.Key])); // First try to select based on JPath expression, else just get the value. case JTokenType.Array: var valuesArray = value.ToObject(); diff --git a/test/WireMock.Net.Tests/Matchers/JsonPartialMatcherTests.cs b/test/WireMock.Net.Tests/Matchers/JsonPartialMatcherTests.cs index 0b3ff78f..7b3802d1 100644 --- a/test/WireMock.Net.Tests/Matchers/JsonPartialMatcherTests.cs +++ b/test/WireMock.Net.Tests/Matchers/JsonPartialMatcherTests.cs @@ -293,6 +293,23 @@ public void JsonPartialMatcher_IsMatch_JObjectAsString() Assert.Equal(1.0, match); } + [Fact] + public void JsonPartialMatcher_IsMatch_JObjectAsStringWithDottedPropertyName() + { + // Assign + var matcher = new JsonPartialMatcher("{ \"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User\" : \"Test\" }"); + + // Act + var jObject = new JObject + { + { "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User", new JValue("Test") } + }; + var match = matcher.IsMatch(jObject).Score; + + // Assert + Assert.Equal(1.0, match); + } + [Fact] public void JsonPartialMatcher_IsMatch_GuidAsString() { From c548600dea7aa0c826f07059715b526c5ed9129f Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Fri, 6 Dec 2024 19:22:25 +0100 Subject: [PATCH 9/9] 1.6.9 --- CHANGELOG.md | 6 +++++- Directory.Build.props | 2 +- Generate-ReleaseNotes.cmd | 2 +- PackageReleaseNotes.txt | 11 +++-------- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4d9aec8..6ab52fc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -# 1.6.8 (23 November 2024) +# 1.6.9 (06 December 2024) +- [#1216](https://github.com/WireMock-Net/WireMock.Net/pull/1216) - Fix JsonPartialMatcher when using property names with dot [bug] contributed by [StefH](https://github.com/StefH) +- [#1210](https://github.com/WireMock-Net/WireMock.Net/issues/1210) - JsonPartialMatcher fails to match on property name that JsonMatcher matches [bug] + +# 1.6.8 (24 November 2024) - [#1202](https://github.com/WireMock-Net/WireMock.Net/pull/1202) - Log exception when (static) mapping file cannot be read [feature] contributed by [StefH](https://github.com/StefH) - [#1206](https://github.com/WireMock-Net/WireMock.Net/pull/1206) - Fix security issues [bug] contributed by [StefH](https://github.com/StefH) - [#1211](https://github.com/WireMock-Net/WireMock.Net/pull/1211) - Use GraphQL 8.2.1 [feature] contributed by [StefH](https://github.com/StefH) diff --git a/Directory.Build.props b/Directory.Build.props index 7b0b9c21..8cf292f9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ - 1.6.8 + 1.6.9 WireMock.Net-Logo.png https://github.com/WireMock-Net/WireMock.Net Apache-2.0 diff --git a/Generate-ReleaseNotes.cmd b/Generate-ReleaseNotes.cmd index 28d76a38..eca608a4 100644 --- a/Generate-ReleaseNotes.cmd +++ b/Generate-ReleaseNotes.cmd @@ -1,6 +1,6 @@ rem https://github.com/StefH/GitHubReleaseNotes -SET version=1.6.8 +SET version=1.6.9 GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels test question invalid doc duplicate example environment --version %version% --token %GH_TOKEN% diff --git a/PackageReleaseNotes.txt b/PackageReleaseNotes.txt index 96b08418..96367cb8 100644 --- a/PackageReleaseNotes.txt +++ b/PackageReleaseNotes.txt @@ -1,10 +1,5 @@ -# 1.6.8 (23 November 2024) -- #1202 Log exception when (static) mapping file cannot be read [feature] -- #1206 Fix security issues [bug] -- #1211 Use GraphQL 8.2.1 [feature] -- #1213 Fix HandlebarsContext ParseAndEvaluate method [bug] -- #1201 Mapping file parse errors are not logged to the console [feature] -- #1209 Upgrade of GraphQL libs to the latest [feature] -- #1212 Response Body Does Not Include Text After Path Segment [bug] +# 1.6.9 (06 December 2024) +- #1216 Fix JsonPartialMatcher when using property names with dot [bug] +- #1210 JsonPartialMatcher fails to match on property name that JsonMatcher matches [bug] The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md \ No newline at end of file