Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8151119cca | ||
|
|
77000372c6 | ||
|
|
ec248a9a78 | ||
|
|
2f7e3a3178 | ||
|
|
ac9c51e34e | ||
|
|
8ba243ddcd | ||
|
|
d4b95e73ea | ||
|
|
f9ae045847 |
@@ -1,3 +1,10 @@
|
||||
# 1.8.11 (11 June 2025)
|
||||
- [#1311](https://github.com/wiremock/WireMock.Net/pull/1311) - Bump Testcontainers version to 4.5.0 [feature] contributed by [scrocquesel](https://github.com/scrocquesel)
|
||||
- [#1313](https://github.com/wiremock/WireMock.Net/pull/1313) - Update RandomDataGenerator.Net to 1.0.19 [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1315](https://github.com/wiremock/WireMock.Net/pull/1315) - Fix for WithTransformer and JsonBody as list [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1310](https://github.com/wiremock/WireMock.Net/issues/1310) - Binary compat issue with testcontainers 4.5.0 [bug]
|
||||
- [#1312](https://github.com/wiremock/WireMock.Net/issues/1312) - WithTransformer breaks when the response BodyAsJson is a List [bug]
|
||||
|
||||
# 1.8.10 (10 June 2025)
|
||||
- [#1306](https://github.com/wiremock/WireMock.Net/pull/1306) - Update RequestModelBuilder (add WithHeader) [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1308](https://github.com/wiremock/WireMock.Net/pull/1308) - For some projects, change dependency to WireMock.Net.Minimal [feature] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.8.10</VersionPrefix>
|
||||
<VersionPrefix>1.8.11</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=1.8.10
|
||||
SET version=1.8.11
|
||||
|
||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels wontfix test question invalid doc duplicate example environment --version %version% --token %GH_TOKEN%
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# 1.8.10 (10 June 2025)
|
||||
- #1306 Update RequestModelBuilder (add WithHeader) [feature]
|
||||
- #1308 For some projects, change dependency to WireMock.Net.Minimal [feature]
|
||||
- #1309 Update AwesomeAssertions to version 9 [feature]
|
||||
- #1305 AdminApiMappingBuilder do not expose WithHeader for Request [feature]
|
||||
- #1307 Update WireMock.Net.AwesomeAssertions to use latest version from AwesomeAssertions [feature]
|
||||
# 1.8.11 (11 June 2025)
|
||||
- #1311 Bump Testcontainers version to 4.5.0 [feature]
|
||||
- #1313 Update RandomDataGenerator.Net to 1.0.19 [feature]
|
||||
- #1315 Fix for WithTransformer and JsonBody as list [bug]
|
||||
- #1310 Binary compat issue with testcontainers 4.5.0 [bug]
|
||||
- #1312 WithTransformer breaks when the response BodyAsJson is a List [bug]
|
||||
|
||||
The full release notes can be found here: https://github.com/wiremock/WireMock.Net/blob/master/CHANGELOG.md
|
||||
@@ -1,4 +1,4 @@
|
||||
# WireMock.Net
|
||||
#  WireMock.Net
|
||||
A C# .NET version based on [mock4net](https://github.com/alexvictoor/mock4net) which mimics the functionality from the JAVA based [WireMock](http://wiremock.org).
|
||||
|
||||
For more info, see also this WIKI page: [What is WireMock.Net](https://github.com/wiremock/WireMock.Net/wiki/What-Is-WireMock.Net).
|
||||
|
||||
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 12 KiB |
BIN
resources/logo_32x32.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
@@ -1,6 +1,7 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HandlebarsDotNet.Helpers.Models;
|
||||
@@ -170,8 +171,8 @@ internal class Transformer : ITransformer
|
||||
WalkNode(transformerContext, options, jToken, model);
|
||||
break;
|
||||
|
||||
case Array bodyAsArray:
|
||||
jToken = JArray.FromObject(bodyAsArray, _jsonSerializer);
|
||||
case var bodyAsEnumerable when bodyAsEnumerable is IEnumerable and not string:
|
||||
jToken = JArray.FromObject(bodyAsEnumerable, _jsonSerializer);
|
||||
WalkNode(transformerContext, options, jToken, model);
|
||||
break;
|
||||
|
||||
|
||||
@@ -157,13 +157,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Handlebars.Net.Helpers" Version="2.5.0" />
|
||||
<!--<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.5.0" />-->
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Humanizer" Version="2.5.0" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.5.0" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.5.0" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.5.0" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.5.0" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers" Version="2.5.2" />
|
||||
<!--<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.5.2" />-->
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Humanizer" Version="2.5.2" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.5.2" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.5.2" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.5.2" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.5.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard1.3' and '$(TargetFramework)' != 'net451' and '$(TargetFramework)' != 'net452' ">
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="RamlToOpenApiConverter.SourceOnly" Version="0.8.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="8.1.0" />
|
||||
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.18" />
|
||||
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.19" />
|
||||
<PackageReference Include="Stef.Validation" Version="0.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -39,11 +39,11 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Stef.Validation" Version="0.1.1" />
|
||||
<PackageReference Include="Testcontainers" Version="4.0.0" />
|
||||
<PackageReference Include="Testcontainers" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WireMock.Net.RestClient\WireMock.Net.RestClient.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
@@ -69,7 +69,7 @@ public partial class TestcontainersTests
|
||||
}
|
||||
finally
|
||||
{
|
||||
await wireMockContainer.StopAsync();
|
||||
await StopAsync(wireMockContainer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public partial class TestcontainersTests
|
||||
}
|
||||
finally
|
||||
{
|
||||
await wireMockContainer.StopAsync();
|
||||
await StopAsync(wireMockContainer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public partial class TestcontainersTests
|
||||
|
||||
Then_ReplyMessage_Should_BeCorrect(reply);
|
||||
|
||||
await wireMockContainer.StopAsync();
|
||||
await StopAsync(wireMockContainer);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -150,7 +150,7 @@ public partial class TestcontainersTests
|
||||
|
||||
Then_ReplyMessage_Should_BeCorrect(reply);
|
||||
|
||||
await wireMockContainer.StopAsync();
|
||||
await StopAsync(wireMockContainer);
|
||||
}
|
||||
|
||||
private static async Task<WireMockContainer> Given_WireMockContainerIsStartedForHttpAndGrpcAsync()
|
||||
|
||||
@@ -11,10 +11,11 @@ using WireMock.Net.Testcontainers;
|
||||
using WireMock.Net.Testcontainers.Utils;
|
||||
using WireMock.Net.Tests.Facts;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace WireMock.Net.Tests.Testcontainers;
|
||||
|
||||
public partial class TestcontainersTests
|
||||
public partial class TestcontainersTests(ITestOutputHelper testOutputHelper)
|
||||
{
|
||||
[Fact]
|
||||
public async Task WireMockContainer_Build_And_StartAsync_and_StopAsync()
|
||||
@@ -28,7 +29,8 @@ public partial class TestcontainersTests
|
||||
.WithAdminUserNameAndPassword(adminUsername, adminPassword)
|
||||
.Build();
|
||||
|
||||
await StartTestAndStopAsync(wireMockContainer);
|
||||
await StartTestAsync(wireMockContainer);
|
||||
await StopAsync(wireMockContainer);
|
||||
}
|
||||
|
||||
// https://github.com/testcontainers/testcontainers-dotnet/issues/1322
|
||||
@@ -48,7 +50,8 @@ public partial class TestcontainersTests
|
||||
.WithCleanUp(true)
|
||||
.Build();
|
||||
|
||||
await StartTestAndStopAsync(wireMockContainer);
|
||||
await StartTestAsync(wireMockContainer);
|
||||
await StopAsync(wireMockContainer);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -74,7 +77,8 @@ public partial class TestcontainersTests
|
||||
|
||||
var wireMockContainer = wireMockContainerBuilder.Build();
|
||||
|
||||
await StartTestAndStopAsync(wireMockContainer);
|
||||
await StartTestAsync(wireMockContainer);
|
||||
await StopAsync(wireMockContainer);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -100,31 +104,48 @@ public partial class TestcontainersTests
|
||||
|
||||
var wireMockContainer = wireMockContainerBuilder.Build();
|
||||
|
||||
await StartTestAndStopAsync(wireMockContainer);
|
||||
await StartTestAsync(wireMockContainer);
|
||||
await StopAsync(wireMockContainer);
|
||||
}
|
||||
|
||||
private static async Task StartTestAndStopAsync(WireMockContainer wireMockContainer)
|
||||
private static async Task StartTestAsync(WireMockContainer wireMockContainer)
|
||||
{
|
||||
// Start
|
||||
await wireMockContainer.StartAsync().ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
using (new AssertionScope())
|
||||
{
|
||||
var url = wireMockContainer.GetPublicUrl();
|
||||
url.Should().NotBeNullOrWhiteSpace();
|
||||
|
||||
var adminClient = wireMockContainer.CreateWireMockAdminClient();
|
||||
|
||||
var settings = await adminClient.GetSettingsAsync();
|
||||
settings.Should().NotBeNull();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task StopAsync(WireMockContainer wireMockContainer)
|
||||
{
|
||||
try
|
||||
{
|
||||
await wireMockContainer.StartAsync().ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
using (new AssertionScope())
|
||||
{
|
||||
var url = wireMockContainer.GetPublicUrl();
|
||||
url.Should().NotBeNullOrWhiteSpace();
|
||||
|
||||
var adminClient = wireMockContainer.CreateWireMockAdminClient();
|
||||
|
||||
var settings = await adminClient.GetSettingsAsync();
|
||||
settings.Should().NotBeNull();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
await wireMockContainer.StopAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Sometimes we get this exception, so for now ignore it.
|
||||
/*
|
||||
Failed WireMock.Net.Tests.Testcontainers.TestcontainersTests.WireMockContainer_Build_WithImageAsText_And_StartAsync_and_StopAsync [9 s]
|
||||
Error Message:
|
||||
System.NullReferenceException : Object reference not set to an instance of an object.
|
||||
Stack Trace:
|
||||
at DotNet.Testcontainers.Containers.DockerContainer.UnsafeStopAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 567
|
||||
at DotNet.Testcontainers.Containers.DockerContainer.StopAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 319
|
||||
*/
|
||||
|
||||
testOutputHelper.WriteLine($"Exception during StopAsync: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -102,7 +102,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net452'">
|
||||
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
|
||||
<PackageReference Include="System.Net.Http.Json" Version="8.0.1" />
|
||||
<PackageReference Include="JsonConverter.System.Text.Json" Version="0.7.0" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.25.1" />
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.60.0" />
|
||||
|
||||
@@ -924,49 +924,4 @@ public class WireMockServerProxyTests
|
||||
server.LogEntries.Should().HaveCount(1);
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_ProxyAndRecordSettings_SameRequest_ShouldProxyAll()
|
||||
{
|
||||
//Arrange
|
||||
var wireMockServerSettings = new WireMockServerSettings
|
||||
{
|
||||
Urls = new[] { "http://localhost:19091" },
|
||||
ProxyAndRecordSettings = new ProxyAndRecordSettings
|
||||
{
|
||||
Url = "http://postman-echo.com",
|
||||
SaveMapping = true,
|
||||
ProxyAll = true,
|
||||
SaveMappingToFile = false,
|
||||
ExcludedHeaders = new[] { "Postman-Token" },
|
||||
ExcludedCookies = new[] { "sails.sid" }
|
||||
}
|
||||
};
|
||||
|
||||
var server = WireMockServer.Start(wireMockServerSettings);
|
||||
|
||||
var requestBody = "{\"key1\": \"value1\", \"key2\": \"value2\"}";
|
||||
var request = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri("http://localhost:19091/post"),
|
||||
Content = new StringContent(requestBody)
|
||||
};
|
||||
var request2 = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri("http://localhost:19091/post"),
|
||||
Content = new StringContent(requestBody)
|
||||
};
|
||||
server.ResetMappings();
|
||||
|
||||
//Act
|
||||
await new HttpClient().SendAsync(request);
|
||||
await new HttpClient().SendAsync(request2);
|
||||
|
||||
//Assert
|
||||
Check.That(server.Mappings.Count()).IsEqualTo(3);
|
||||
|
||||
server.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Server;
|
||||
using Xunit;
|
||||
|
||||
@@ -44,6 +43,78 @@ public partial class WireMockServerTests
|
||||
response.Should().Contain("Hello, Stef!");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithTransformer_WithJsonBodyAsArray_ShouldWork()
|
||||
{
|
||||
// Arrange
|
||||
using var server = WireMockServer.Start();
|
||||
server
|
||||
.WhenRequest(req => req
|
||||
.WithPath("/withbody")
|
||||
.UsingPost()
|
||||
)
|
||||
.ThenRespondWith(rsp => rsp
|
||||
.WithSuccess()
|
||||
.WithBodyAsJson(new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
test = "test",
|
||||
secret = true
|
||||
},
|
||||
new
|
||||
{
|
||||
test = "123",
|
||||
secret = false
|
||||
}
|
||||
}
|
||||
)
|
||||
.WithTransformer()
|
||||
);
|
||||
|
||||
// Act
|
||||
var response = await GetResponseAsync(server, "/withbody");
|
||||
|
||||
// Assert
|
||||
response.Should().Be("""[{"test":"test","secret":true},{"test":"123","secret":false}]""");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithTransformer_WithJsonBodyAsList_ShouldWork()
|
||||
{
|
||||
// Arrange
|
||||
using var server = WireMockServer.Start();
|
||||
server
|
||||
.WhenRequest(req => req
|
||||
.WithPath("/withbody")
|
||||
.UsingPost()
|
||||
)
|
||||
.ThenRespondWith(rsp => rsp
|
||||
.WithSuccess()
|
||||
.WithBodyAsJson(
|
||||
new List<object>
|
||||
{
|
||||
new
|
||||
{
|
||||
test = "test",
|
||||
secret = true
|
||||
},
|
||||
new
|
||||
{
|
||||
test = "123",
|
||||
secret = false
|
||||
}
|
||||
})
|
||||
.WithTransformer()
|
||||
);
|
||||
|
||||
// Act
|
||||
var response = await GetResponseAsync(server, "/withbody");
|
||||
|
||||
// Assert
|
||||
response.Should().Be("""[{"test":"test","secret":true},{"test":"123","secret":false}]""");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithTransformerBefore_WithBodyFromFile_ShouldWork()
|
||||
{
|
||||
@@ -88,8 +159,7 @@ public partial class WireMockServerTests
|
||||
|
||||
private static async Task<string> GetResponseAsync(WireMockServer server, string relativePath)
|
||||
{
|
||||
using HttpClient httpClient = new HttpClient();
|
||||
httpClient.BaseAddress = new Uri(server.Urls[0]);
|
||||
using var httpClient = server.CreateClient();
|
||||
|
||||
using var requestContent = new StringContent(RequestXml);
|
||||
using var responseMsg = await httpClient.PostAsync(relativePath, requestContent);
|
||||
|
||||