mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-03 21:10:09 +01:00
Compare commits
6 Commits
1.6.2
...
stef-aspir
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0406f642e8 | ||
|
|
11d090037e | ||
|
|
af124d556d | ||
|
|
60931f6273 | ||
|
|
b99a80e782 | ||
|
|
07c9aebf44 |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,3 +1,14 @@
|
||||
# 1.6.3 (07 September 2024)
|
||||
- [#1165](https://github.com/WireMock-Net/WireMock.Net/pull/1165) - Fix listen on AnyIP for url 0.0.0.0 contributed by [cocoon](https://github.com/cocoon)
|
||||
- [#1154](https://github.com/WireMock-Net/WireMock.Net/issues/1154) - Listen on all ips [bug]
|
||||
|
||||
# 1.6.2 (04 September 2024)
|
||||
- [#1152](https://github.com/WireMock-Net/WireMock.Net/pull/1152) - Update MappingConverter to correctly write the Matcher as C# code [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1163](https://github.com/WireMock-Net/WireMock.Net/pull/1163) - Upgrade Aspire to version 8.2.0 [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1166](https://github.com/WireMock-Net/WireMock.Net/pull/1166) - Also update IWireMockMiddlewareOptions when settings are updated via admin interface [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1151](https://github.com/WireMock-Net/WireMock.Net/issues/1151) - MappingsToCSharpCode should use RegexMatcher when specified [bug]
|
||||
- [#1164](https://github.com/WireMock-Net/WireMock.Net/issues/1164) - WithParam not working. [bug]
|
||||
|
||||
# 1.6.1 (22 August 2024)
|
||||
- [#1160](https://github.com/WireMock-Net/WireMock.Net/pull/1160) - Use default timeout for Regex [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#1159](https://github.com/WireMock-Net/WireMock.Net/issues/1159) - RegexMatchTimeoutException when trying to parse HTTP version [bug]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.6.1</VersionPrefix>
|
||||
<VersionPrefix>1.6.3</VersionPrefix>
|
||||
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
|
||||
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
|
||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
rem https://github.com/StefH/GitHubReleaseNotes
|
||||
|
||||
SET version=1.6.1
|
||||
SET version=1.6.3
|
||||
|
||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate example environment --version %version% --token %GH_TOKEN%
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 1.6.1 (22 August 2024)
|
||||
- #1160 Use default timeout for Regex [bug]
|
||||
- #1159 RegexMatchTimeoutException when trying to parse HTTP version [bug]
|
||||
# 1.6.3 (07 September 2024)
|
||||
- #1165 Fix listen on AnyIP for url 0.0.0.0
|
||||
- #1154 Listen on all ips [bug]
|
||||
|
||||
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md
|
||||
20
README.md
20
README.md
@@ -39,16 +39,16 @@ For more info, see also this WIKI page: [What is WireMock.Net](https://github.co
|
||||
|
||||
| | Official | Preview [:information_source:](https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions) |
|
||||
| - | - | - |
|
||||
| **WireMock.Net** | [](https://www.nuget.org/packages/WireMock.Net) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net)
|
||||
| **WireMock.Net.StandAlone** | [](https://www.nuget.org/packages/WireMock.Net.StandAlone) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.StandAlone)
|
||||
| **WireMock.Net.FluentAssertions** | [](https://www.nuget.org/packages/WireMock.Net.FluentAssertions) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.FluentAssertions)
|
||||
| **WireMock.Net.Matchers.CSharpCode** | [](https://www.nuget.org/packages/WireMock.Net.Matchers.CSharpCode) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Matchers.CSharpCode)
|
||||
| **WireMock.Net.OpenApiParser** | [](https://www.nuget.org/packages/WireMock.Net.OpenApiParser) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.OpenApiParser)
|
||||
| **WireMock.Net.RestClient** | [](https://www.nuget.org/packages/WireMock.Net.RestClient) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.RestClient)
|
||||
| **WireMock.Net.xUnit** | [](https://www.nuget.org/packages/WireMock.Net.xUnit) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.xUnit)
|
||||
| **WireMock.Net.Testcontainers** | [](https://www.nuget.org/packages/WireMock.Net.Testcontainers) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Testcontainers)
|
||||
| **WireMock.Net.Aspire** | [](https://www.nuget.org/packages/WireMock.Net.Aspire) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Aspire)
|
||||
| **WireMock.Org.RestClient** | [](https://www.nuget.org/packages/WireMock.Org.RestClient) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Org.RestClient)
|
||||
| **WireMock.Net** | [](https://www.nuget.org/packages/WireMock.Net) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net)
|
||||
| **WireMock.Net.StandAlone** | [](https://www.nuget.org/packages/WireMock.Net.StandAlone) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.StandAlone)
|
||||
| **WireMock.Net.FluentAssertions** | [](https://www.nuget.org/packages/WireMock.Net.FluentAssertions) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.FluentAssertions)
|
||||
| **WireMock.Net.Matchers.CSharpCode** | [](https://www.nuget.org/packages/WireMock.Net.Matchers.CSharpCode) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Matchers.CSharpCode)
|
||||
| **WireMock.Net.OpenApiParser** | [](https://www.nuget.org/packages/WireMock.Net.OpenApiParser) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.OpenApiParser)
|
||||
| **WireMock.Net.RestClient** | [](https://www.nuget.org/packages/WireMock.Net.RestClient) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.RestClient)
|
||||
| **WireMock.Net.xUnit** | [](https://www.nuget.org/packages/WireMock.Net.xUnit) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.xUnit)
|
||||
| **WireMock.Net.Testcontainers** | [](https://www.nuget.org/packages/WireMock.Net.Testcontainers) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Testcontainers)
|
||||
| **WireMock.Net.Aspire** | [](https://www.nuget.org/packages/WireMock.Net.Aspire) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net.Aspire)
|
||||
| **WireMock.Org.RestClient** | [](https://www.nuget.org/packages/WireMock.Org.RestClient) | [](https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Org.RestClient)
|
||||
|
||||
|
||||
## :memo: Development
|
||||
|
||||
@@ -75,8 +75,15 @@ namespace WireMock.Owin
|
||||
|
||||
private static void Listen(KestrelServerOptions kestrelOptions, HostUrlDetails urlDetail, Action<ListenOptions> configure)
|
||||
{
|
||||
// Listens on any IP with the given port.
|
||||
if (urlDetail is { Port: > 0, Host: "0.0.0.0" })
|
||||
{
|
||||
kestrelOptions.ListenAnyIP(urlDetail.Port, configure);
|
||||
return;
|
||||
}
|
||||
|
||||
// Listens on ::1 and 127.0.0.1 with the given port.
|
||||
if (urlDetail is { Port: > 0, Host: "localhost" or "127.0.0.1" or "0.0.0.0" or "::1" })
|
||||
if (urlDetail is { Port: > 0, Host: "localhost" or "127.0.0.1" or "::1" })
|
||||
{
|
||||
kestrelOptions.ListenLocalhost(urlDetail.Port, configure);
|
||||
return;
|
||||
@@ -113,4 +120,4 @@ namespace WireMock.Owin
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,7 @@ namespace WireMock.Net.Aspire.Tests;
|
||||
[ExcludeFromCodeCoverage]
|
||||
internal static class DockerUtils
|
||||
{
|
||||
public static bool IsDockerRunningLinuxContainerMode()
|
||||
{
|
||||
return IsDockerRunning() && IsLinuxContainerMode();
|
||||
}
|
||||
public static Lazy<bool> IsDockerRunningLinuxContainerMode => new(() => IsDockerRunning() && IsLinuxContainerMode());
|
||||
|
||||
private static bool IsDockerRunning()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
namespace WireMock.Net.Aspire.Tests.Facts;
|
||||
|
||||
public sealed class DockerIsRunningInLinuxContainerModeFact : FactAttribute
|
||||
{
|
||||
private const string SkipReason = "Docker is not running in Linux container mode. Skipping test.";
|
||||
|
||||
public DockerIsRunningInLinuxContainerModeFact()
|
||||
{
|
||||
if (!DockerUtils.IsDockerRunningLinuxContainerMode.Value)
|
||||
{
|
||||
Skip = SkipReason;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
using System.Net.Http.Json;
|
||||
using FluentAssertions;
|
||||
using Projects;
|
||||
using WireMock.Net.Aspire.Tests.Facts;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace WireMock.Net.Aspire.Tests;
|
||||
@@ -11,15 +12,9 @@ public class IntegrationTests(ITestOutputHelper output)
|
||||
{
|
||||
private record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary);
|
||||
|
||||
[Fact]
|
||||
[DockerIsRunningInLinuxContainerModeFact]
|
||||
public async Task StartAppHostWithWireMockAndCreateHttpClientToCallTheMockedWeatherForecastEndpoint()
|
||||
{
|
||||
if (!DockerUtils.IsDockerRunningLinuxContainerMode())
|
||||
{
|
||||
output.WriteLine("Docker is not running in Linux container mode. Skipping test.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Arrange
|
||||
var appHostBuilder = await DistributedApplicationTestingBuilder.CreateAsync<WireMock_Net_Aspire_TestAppHost>();
|
||||
await using var app = await appHostBuilder.BuildAsync();
|
||||
@@ -44,15 +39,9 @@ public class IntegrationTests(ITestOutputHelper output)
|
||||
weatherForecasts2.Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[DockerIsRunningInLinuxContainerModeFact]
|
||||
public async Task StartAppHostWithWireMockAndCreateWireMockAdminClientToCallTheAdminEndpoint()
|
||||
{
|
||||
if (!DockerUtils.IsDockerRunningLinuxContainerMode())
|
||||
{
|
||||
output.WriteLine("Docker is not running in Linux container mode. Skipping test.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Arrange
|
||||
var appHostBuilder = await DistributedApplicationTestingBuilder.CreateAsync<WireMock_Net_Aspire_TestAppHost>();
|
||||
await using var app = await appHostBuilder.BuildAsync();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Facts;
|
||||
|
||||
public sealed class IgnoreOnContinuousIntegrationFact : FactAttribute
|
||||
{
|
||||
private const string SkipReason = "Ignore when run via CI/CD";
|
||||
private static readonly bool IsContinuousIntegrationAzure = bool.TryParse(Environment.GetEnvironmentVariable("TF_BUILD"), out var isTF) && isTF;
|
||||
private static readonly bool IsContinuousIntegrationGithub = bool.TryParse(Environment.GetEnvironmentVariable("GITHUB_ACTIONS"), out var isGH) && isGH;
|
||||
private static readonly bool IsContinuousIntegration = IsContinuousIntegrationAzure || IsContinuousIntegrationGithub;
|
||||
|
||||
public IgnoreOnContinuousIntegrationFact()
|
||||
{
|
||||
if (IsContinuousIntegration)
|
||||
{
|
||||
Skip = SkipReason;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
@@ -16,6 +18,7 @@ using NFluent;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Http;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Net.Tests.Facts;
|
||||
using WireMock.Net.Tests.Serialization;
|
||||
using WireMock.Net.Xunit;
|
||||
using WireMock.RequestBuilders;
|
||||
@@ -196,6 +199,66 @@ public partial class WireMockServerTests
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
private static string[] GetIPAddressesByFamily(AddressFamily addressFamily)
|
||||
{
|
||||
return NetworkInterface.GetAllNetworkInterfaces()
|
||||
.Where(ni => ni.OperationalStatus == OperationalStatus.Up)
|
||||
.SelectMany(ni => ni.GetIPProperties().UnicastAddresses)
|
||||
.Where(addr => addr.Address.AddressFamily == addressFamily)
|
||||
.Select(addr => addr.Address.ToString())
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
[IgnoreOnContinuousIntegrationFact]
|
||||
public async Task WireMockServer_WithUrl0000_Should_Listen_On_All_IPs_IPv4()
|
||||
{
|
||||
// Arrange
|
||||
var port = PortUtils.FindFreeTcpPort();
|
||||
var IPv4 = GetIPAddressesByFamily(System.Net.Sockets.AddressFamily.InterNetwork);
|
||||
var settings = new WireMockServerSettings
|
||||
{
|
||||
Urls = ["http://0.0.0.0:" + port],
|
||||
};
|
||||
using var server = WireMockServer.Start(settings);
|
||||
|
||||
server.Given(Request.Create().WithPath("/*")).RespondWith(Response.Create().WithBody("x"));
|
||||
|
||||
foreach (var address in IPv4)
|
||||
{
|
||||
// Act
|
||||
var response = await new HttpClient().GetStringAsync("http://" + address + ":" + server.Ports[0] + "/foo").ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response.Should().Be("x");
|
||||
}
|
||||
}
|
||||
|
||||
[IgnoreOnContinuousIntegrationFact]
|
||||
public async Task WireMockServer_WithUrl0000_Should_Listen_On_All_IPs_IPv6()
|
||||
{
|
||||
// Arrange
|
||||
var port = PortUtils.FindFreeTcpPort();
|
||||
var IPv6 = GetIPAddressesByFamily(System.Net.Sockets.AddressFamily.InterNetworkV6);
|
||||
var settings = new WireMockServerSettings
|
||||
{
|
||||
Urls = ["http://0.0.0.0:" + port],
|
||||
};
|
||||
using var server = WireMockServer.Start(settings);
|
||||
|
||||
server.Given(Request.Create().WithPath("/*")).RespondWith(Response.Create().WithBody("x"));
|
||||
|
||||
foreach (var address in IPv6)
|
||||
{
|
||||
// Act
|
||||
var response = await new HttpClient().GetStringAsync("http://[" + address + "]:" + server.Ports[0] + "/foo").ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response.Should().Be("x");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_Should_respond_a_redirect_without_body()
|
||||
{
|
||||
@@ -248,7 +311,7 @@ public partial class WireMockServerTests
|
||||
// Act
|
||||
var response = await new HttpClient().GetStringAsync("http://localhost:" + server.Ports[0] + "/foo").ConfigureAwait(false);
|
||||
|
||||
// Asser.
|
||||
// Assert
|
||||
response.Should().Be("x");
|
||||
|
||||
server.Stop();
|
||||
@@ -274,7 +337,7 @@ public partial class WireMockServerTests
|
||||
await new HttpClient().GetStringAsync("http://localhost:" + server.Ports[0] + "/foo").ConfigureAwait(false);
|
||||
watch.Stop();
|
||||
|
||||
// Asser.
|
||||
// Assert
|
||||
watch.ElapsedMilliseconds.Should().BeGreaterOrEqualTo(0);
|
||||
|
||||
server.Stop();
|
||||
@@ -662,4 +725,4 @@ public partial class WireMockServerTests
|
||||
server.Stop();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user