mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-21 08:17:52 +01:00
Compare commits
1 Commits
1.5.11
...
stef-847-r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04cba25bdf |
@@ -1,8 +1,3 @@
|
||||
# 1.5.11 (24 November 2022)
|
||||
- [#836](https://github.com/WireMock-Net/WireMock.Net/pull/836) - Add Settings.QueryParameterMultipleValueSupport [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#848](https://github.com/WireMock-Net/WireMock.Net/pull/848) - Use try-catch when adding or removing logEntry [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#846](https://github.com/WireMock-Net/WireMock.Net/issues/846) - Exception ArgumentOutOfRangeException [bug]
|
||||
|
||||
# 1.5.10 (06 November 2022)
|
||||
- [#843](https://github.com/WireMock-Net/WireMock.Net/pull/843) - Webhook Templating: Use the transformed URL to create the HttpRequestMessage contributed by [ggradnig](https://github.com/ggradnig)
|
||||
- [#845](https://github.com/WireMock-Net/WireMock.Net/pull/845) - Add WireMockNullLogger as valid commandline logger option [feature] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.5.11</VersionPrefix>
|
||||
<VersionPrefix>1.5.10</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.5.11
|
||||
SET version=1.5.10
|
||||
|
||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate --version %version% --token %GH_TOKEN%
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# 1.5.11 (24 November 2022)
|
||||
- #836 Add Settings.QueryParameterMultipleValueSupport [feature]
|
||||
- #848 Use try-catch when adding or removing logEntry [bug]
|
||||
- #846 Exception ArgumentOutOfRangeException [bug]
|
||||
# 1.5.10 (06 November 2022)
|
||||
- #843 Webhook Templating: Use the transformed URL to create the HttpRequestMessage
|
||||
- #845 Add WireMockNullLogger as valid commandline logger option [feature]
|
||||
|
||||
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md
|
||||
@@ -269,55 +269,29 @@ namespace WireMock.Owin
|
||||
{
|
||||
_options.Logger.DebugRequestResponse(_logEntryMapper.Map(entry), entry.RequestMessage.Path.StartsWith("/__admin/"));
|
||||
|
||||
// If addRequest is set to true and MaxRequestLogCount is null or does have a value greater than 0, try to add a new request log.
|
||||
if (addRequest && _options.MaxRequestLogCount is null or > 0)
|
||||
if (addRequest)
|
||||
{
|
||||
TryAddLogEntry(entry);
|
||||
_options.LogEntries.Add(entry);
|
||||
}
|
||||
|
||||
// In case MaxRequestLogCount has a value greater than 0, try to delete existing request logs based on the count.
|
||||
if (_options.MaxRequestLogCount is > 0)
|
||||
if (_options.MaxRequestLogCount != null)
|
||||
{
|
||||
var logEntries = _options.LogEntries.ToList();
|
||||
foreach (var logEntry in logEntries.OrderBy(le => le.RequestMessage.DateTime).Take(logEntries.Count - _options.MaxRequestLogCount.Value))
|
||||
{
|
||||
TryRemoveLogEntry(logEntry);
|
||||
_options.LogEntries.Remove(logEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// In case RequestLogExpirationDuration has a value greater than 0, try to delete existing request logs based on the date.
|
||||
if (_options.RequestLogExpirationDuration is > 0)
|
||||
if (_options.RequestLogExpirationDuration != null)
|
||||
{
|
||||
var checkTime = DateTime.UtcNow.AddHours(-_options.RequestLogExpirationDuration.Value);
|
||||
|
||||
foreach (var logEntry in _options.LogEntries.ToList().Where(le => le.RequestMessage.DateTime < checkTime))
|
||||
{
|
||||
TryRemoveLogEntry(logEntry);
|
||||
_options.LogEntries.Remove(logEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TryAddLogEntry(LogEntry logEntry)
|
||||
{
|
||||
try
|
||||
{
|
||||
_options.LogEntries.Add(logEntry);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore exception (can happen during stress testing)
|
||||
}
|
||||
}
|
||||
|
||||
private void TryRemoveLogEntry(LogEntry logEntry)
|
||||
{
|
||||
try
|
||||
{
|
||||
_options.LogEntries.Remove(logEntry);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore exception (can happen during stress testing)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using NFluent;
|
||||
using WireMock.Matchers;
|
||||
using Xunit;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.Matchers.Request;
|
||||
using WireMock.Models;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.Util;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests
|
||||
{
|
||||
@@ -19,11 +19,11 @@ namespace WireMock.Net.Tests
|
||||
// Assign
|
||||
var spec = Request.Create().WithPath("/path/a b").UsingAnyMethod();
|
||||
|
||||
// when
|
||||
// Act
|
||||
var body = new BodyData();
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/path/a b"), "GET", ClientIp, body);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -31,17 +31,17 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Request_WithPath_WithHeader_Match()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath("/foo").UsingAnyMethod().WithHeader("X-toto", "tata");
|
||||
|
||||
// when
|
||||
// Act
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "abc"
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, new Dictionary<string, string[]> { { "X-toto", new[] { "tata" } } });
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -49,13 +49,13 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Request_WithPath()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath("/foo");
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "blabla", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -76,13 +76,13 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Request_WithPathFunc()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath(url => url.EndsWith("/foo"));
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "blabla", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -90,13 +90,13 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Request_WithPathRegexMatcher_HasMatch()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath(new RegexMatcher("^/foo"));
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo/bar"), "blabla", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -104,13 +104,13 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Request_WithPathRegexMatcher_HasNoMatch()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath("/foo");
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/bar"), "blabla", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsNotEqualTo(1.0);
|
||||
}
|
||||
@@ -126,10 +126,10 @@ namespace WireMock.Net.Tests
|
||||
};
|
||||
var spec = Request.Create().WithPath(new RegexMatcher(pattern));
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo/bar"), "blabla", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -137,17 +137,17 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Should_specify_requests_matching_given_path_and_method_delete()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath("/foo").UsingDelete();
|
||||
|
||||
// when
|
||||
// Act
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "whatever"
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "Delete", ClientIp, body);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -155,13 +155,13 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Should_specify_requests_matching_given_path_and_method_get()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath("/foo").UsingGet();
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "GET", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -169,13 +169,13 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Should_specify_requests_matching_given_path_and_method_head()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath("/foo").UsingHead();
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "HEAD", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -183,13 +183,13 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Should_specify_requests_matching_given_path_and_method_post()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath("/foo").UsingPost();
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -197,13 +197,13 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Should_specify_requests_matching_given_path_and_method_put()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath("/foo").UsingPut();
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -211,13 +211,13 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Should_specify_requests_matching_given_path_and_method_patch()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath("/foo").UsingPatch();
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PATCH", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
@@ -225,13 +225,13 @@ namespace WireMock.Net.Tests
|
||||
[Fact]
|
||||
public void Should_exclude_requests_matching_given_path_but_not_http_method()
|
||||
{
|
||||
// given
|
||||
// Arrange
|
||||
var spec = Request.Create().WithPath("/foo").UsingPut();
|
||||
|
||||
// when
|
||||
// Act
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "HEAD", ClientIp);
|
||||
|
||||
// then
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsNotEqualTo(1.0);
|
||||
}
|
||||
|
||||
30
test/WireMock.Net.Tests/RequestWithUrlTests.cs
Normal file
30
test/WireMock.Net.Tests/RequestWithUrlTests.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using FluentAssertions;
|
||||
using WireMock.Matchers;
|
||||
using Xunit;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.Matchers.Request;
|
||||
using WireMock.Models;
|
||||
using WireMock.Util;
|
||||
|
||||
namespace WireMock.Net.Tests
|
||||
{
|
||||
public class RequestWithUrlTests
|
||||
{
|
||||
private const string ClientIp = "::1";
|
||||
|
||||
[Fact]
|
||||
public void Request_WithUrl_Regex()
|
||||
{
|
||||
// Assign
|
||||
var spec = Request.Create().WithUrl(new RegexMatcher("(some\\/service\\/v1\\/name)([?]{1})(param.source=SYSTEM){1}([&]{1})(param.id=123457890){1}$")).UsingAnyMethod();
|
||||
|
||||
// Act
|
||||
var body = new BodyData();
|
||||
var request = new RequestMessage(new UrlDetails("https://localhost/some/service/v1/name?param.source=SYSTEM¶m.id=123457890"), "POST", ClientIp, body);
|
||||
|
||||
// Assert
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
spec.GetMatchingScore(request, requestMatchResult).Should().Be(1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
using NFluent;
|
||||
@@ -375,26 +374,6 @@ public class WireMockServerAdminTests
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_Admin_Logging_SetMaxRequestLogCount_To_0_Should_Not_AddLogging()
|
||||
{
|
||||
// Assign
|
||||
var client = new HttpClient();
|
||||
|
||||
// Act
|
||||
var server = WireMockServer.Start();
|
||||
server.SetMaxRequestLogCount(0);
|
||||
|
||||
await client.GetAsync("http://localhost:" + server.Port + "/foo1").ConfigureAwait(false);
|
||||
await client.GetAsync("http://localhost:" + server.Port + "/foo2").ConfigureAwait(false);
|
||||
await client.GetAsync("http://localhost:" + server.Port + "/foo3").ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
server.LogEntries.Should().BeEmpty();
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WireMockServer_Admin_WatchStaticMappings()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user