mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-13 15:13:31 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1750d4e1ad | ||
|
|
94e176dd85 | ||
|
|
65e01937a6 | ||
|
|
c880dcfc31 | ||
|
|
c02dbeb5ee |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,3 +1,13 @@
|
||||
# 1.3.3 (15 October 2020)
|
||||
- [#520](https://github.com/WireMock-Net/WireMock.Net/pull/520) - Make kestrel limits configurable contributed by [eduherminio](https://github.com/eduherminio)
|
||||
- [#521](https://github.com/WireMock-Net/WireMock.Net/issues/521) - Make Kestrel limits configurable [feature]
|
||||
|
||||
# 1.3.2 (14 October 2020)
|
||||
- [#505](https://github.com/WireMock-Net/WireMock.Net/pull/505) - Fix reading JsonMatcher-mapping with object as pattern [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#514](https://github.com/WireMock-Net/WireMock.Net/pull/514) - Update .NET Core 3.1 example contributed by [Crossbow78](https://github.com/Crossbow78)
|
||||
- [#504](https://github.com/WireMock-Net/WireMock.Net/issues/504) - Loading mapping models with `JsonMatcher` is not working correctly [bug]
|
||||
- [#513](https://github.com/WireMock-Net/WireMock.Net/issues/513) - Static mapping break from 1.2.17 to 1.2.18 and higher [bug]
|
||||
|
||||
# 1.3.1 (30 September 2020)
|
||||
- [#509](https://github.com/WireMock-Net/WireMock.Net/pull/509) - Adding netcoreapp3.1 as a target framework [feature] contributed by [APIWT](https://github.com/APIWT)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.3.1</VersionPrefix>
|
||||
<VersionPrefix>1.3.3</VersionPrefix>
|
||||
<PackageReleaseNotes>See CHANGELOG.md</PackageReleaseNotes>
|
||||
<PackageIconUrl>https://raw.githubusercontent.com/WireMock-Net/WireMock.Net/master/WireMock.Net-Logo.png</PackageIconUrl>
|
||||
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
https://github.com/StefH/GitHubReleaseNotes
|
||||
|
||||
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.3.1
|
||||
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.3.3
|
||||
@@ -3,6 +3,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace WireMock.Owin
|
||||
{
|
||||
@@ -34,5 +36,24 @@ namespace WireMock.Owin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class IWebHostBuilderExtensions
|
||||
{
|
||||
internal static IWebHostBuilder ConfigureAppConfigurationUsingEnvironmentVariables(this IWebHostBuilder builder)
|
||||
{
|
||||
return builder.ConfigureAppConfiguration(config =>
|
||||
{
|
||||
config.AddEnvironmentVariables();
|
||||
});
|
||||
}
|
||||
|
||||
internal static IWebHostBuilder ConfigureKestrelServerOptions(this IWebHostBuilder builder)
|
||||
{
|
||||
return builder.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.Configure<KestrelServerOptions>(context.Configuration.GetSection("Kestrel"));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -4,6 +4,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Server.Kestrel;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using WireMock.HttpsCertificate;
|
||||
|
||||
namespace WireMock.Owin
|
||||
@@ -26,5 +28,22 @@ namespace WireMock.Owin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class IWebHostBuilderExtensions
|
||||
{
|
||||
internal static IWebHostBuilder ConfigureAppConfigurationUsingEnvironmentVariables(this IWebHostBuilder builder) => builder;
|
||||
|
||||
internal static IWebHostBuilder ConfigureKestrelServerOptions(this IWebHostBuilder builder)
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.Build();
|
||||
|
||||
return builder.ConfigureServices(services =>
|
||||
{
|
||||
services.Configure<KestrelServerOptions>(configuration.GetSection("Kestrel"));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -58,6 +58,7 @@ namespace WireMock.Owin
|
||||
}
|
||||
|
||||
_host = builder
|
||||
.ConfigureAppConfigurationUsingEnvironmentVariables()
|
||||
.ConfigureServices(services =>
|
||||
{
|
||||
services.AddSingleton(_options);
|
||||
@@ -81,6 +82,7 @@ namespace WireMock.Owin
|
||||
|
||||
SetHttpsAndUrls(options, _urlOptions.GetDetails());
|
||||
})
|
||||
.ConfigureKestrelServerOptions()
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
.UseUrls(_urlOptions.GetDetails().Select(u => u.Url).ToArray())
|
||||
@@ -118,8 +120,10 @@ namespace WireMock.Owin
|
||||
_logger.Info("WireMock.Net server using netstandard2.0");
|
||||
#elif NETSTANDARD2_1
|
||||
_logger.Info("WireMock.Net server using netstandard2.1");
|
||||
#elif NETCOREAPP3_1
|
||||
_logger.Info("WireMock.Net server using .NET Core 3.1");
|
||||
#elif NET46
|
||||
_logger.Info("WireMock.Net server using .net 4.6.1 or higher");
|
||||
_logger.Info("WireMock.Net server using .NET Framework 4.6.1 or higher");
|
||||
#endif
|
||||
|
||||
#if NETSTANDARD1_3
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace WireMock.Serialization
|
||||
string matcherName = parts[0];
|
||||
string matcherType = parts.Length > 1 ? parts[1] : null;
|
||||
|
||||
string[] stringPatterns = matcher.Patterns != null ? matcher.Patterns.OfType<string>().ToArray() : new[] { matcher.Pattern as string };
|
||||
string[] stringPatterns = (matcher.Patterns != null ? matcher.Patterns : new[] { matcher.Pattern }).OfType<string>().ToArray();
|
||||
MatchBehaviour matchBehaviour = matcher.RejectOnMatch == true ? MatchBehaviour.RejectOnMatch : MatchBehaviour.AcceptOnMatch;
|
||||
bool ignoreCase = matcher.IgnoreCase == true;
|
||||
bool throwExceptionWhenMatcherFails = _settings.ThrowExceptionWhenMatcherFails == true;
|
||||
@@ -64,7 +64,8 @@ namespace WireMock.Serialization
|
||||
return new RegexMatcher(matchBehaviour, stringPatterns, ignoreCase, throwExceptionWhenMatcherFails);
|
||||
|
||||
case "JsonMatcher":
|
||||
return new JsonMatcher(matchBehaviour, stringPatterns, ignoreCase, throwExceptionWhenMatcherFails);
|
||||
object value = matcher.Pattern ?? matcher.Patterns;
|
||||
return new JsonMatcher(matchBehaviour, value, ignoreCase, throwExceptionWhenMatcherFails);
|
||||
|
||||
case "JsonPathMatcher":
|
||||
return new JsonPathMatcher(matchBehaviour, throwExceptionWhenMatcherFails, stringPatterns);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Moq;
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NFluent;
|
||||
using System;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Serialization;
|
||||
@@ -26,7 +27,7 @@ namespace WireMock.Net.Tests.Serialization
|
||||
var model = _sut.Map((IMatcher)null);
|
||||
|
||||
// Assert
|
||||
Check.That(model).IsNull();
|
||||
model.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -36,7 +37,7 @@ namespace WireMock.Net.Tests.Serialization
|
||||
var model = _sut.Map((IMatcher[])null);
|
||||
|
||||
// Assert
|
||||
Check.That(model).IsNull();
|
||||
model.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -50,7 +51,7 @@ namespace WireMock.Net.Tests.Serialization
|
||||
var models = _sut.Map(new[] { matcherMock1.Object, matcherMock2.Object });
|
||||
|
||||
// Assert
|
||||
Check.That(models).HasSize(2);
|
||||
models.Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -65,10 +66,10 @@ namespace WireMock.Net.Tests.Serialization
|
||||
var model = _sut.Map(matcherMock.Object);
|
||||
|
||||
// Assert
|
||||
Check.That(model.IgnoreCase).IsNull();
|
||||
Check.That(model.Name).Equals("test");
|
||||
Check.That(model.Pattern).IsNull();
|
||||
Check.That(model.Patterns).ContainsExactly("p1", "p2");
|
||||
model.IgnoreCase.Should().BeNull();
|
||||
model.Name.Should().Be("test");
|
||||
model.Pattern.Should().BeNull();
|
||||
model.Patterns.Should().Contain("p1", "p2");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -82,7 +83,7 @@ namespace WireMock.Net.Tests.Serialization
|
||||
var model = _sut.Map(matcherMock.Object);
|
||||
|
||||
// Assert
|
||||
Check.That(model.IgnoreCase).Equals(true);
|
||||
model.IgnoreCase.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -92,7 +93,7 @@ namespace WireMock.Net.Tests.Serialization
|
||||
var result = _sut.Map((MatcherModel)null);
|
||||
|
||||
// Assert
|
||||
Check.That(result).IsNull();
|
||||
result.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -119,8 +120,8 @@ namespace WireMock.Net.Tests.Serialization
|
||||
var matcher = (LinqMatcher)_sut.Map(model);
|
||||
|
||||
// Assert
|
||||
Check.That(matcher.MatchBehaviour).IsEqualTo(MatchBehaviour.AcceptOnMatch);
|
||||
Check.That(matcher.GetPatterns()).ContainsExactly("p");
|
||||
matcher.MatchBehaviour.Should().Be(MatchBehaviour.AcceptOnMatch);
|
||||
matcher.GetPatterns().Should().Contain("p");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -137,8 +138,88 @@ namespace WireMock.Net.Tests.Serialization
|
||||
var matcher = (LinqMatcher)_sut.Map(model);
|
||||
|
||||
// Assert
|
||||
Check.That(matcher.MatchBehaviour).IsEqualTo(MatchBehaviour.AcceptOnMatch);
|
||||
Check.That(matcher.GetPatterns()).ContainsExactly("p1", "p2");
|
||||
matcher.MatchBehaviour.Should().Be(MatchBehaviour.AcceptOnMatch);
|
||||
matcher.GetPatterns().Should().Contain("p1", "p2");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_JsonMatcher_Pattern_As_String()
|
||||
{
|
||||
// Assign
|
||||
var pattern = "{ \"AccountIds\": [ 1, 2, 3 ] }";
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "JsonMatcher",
|
||||
Pattern = pattern
|
||||
};
|
||||
|
||||
// Act
|
||||
var matcher = (JsonMatcher)_sut.Map(model);
|
||||
|
||||
// Assert
|
||||
matcher.MatchBehaviour.Should().Be(MatchBehaviour.AcceptOnMatch);
|
||||
matcher.Value.Should().BeEquivalentTo(pattern);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_JsonMatcher_Patterns_As_String()
|
||||
{
|
||||
// Assign
|
||||
var pattern1 = "{ \"AccountIds\": [ 1, 2, 3 ] }";
|
||||
var pattern2 = "{ \"X\": \"x\" }";
|
||||
var patterns = new[] { pattern1, pattern2 };
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "JsonMatcher",
|
||||
Pattern = patterns
|
||||
};
|
||||
|
||||
// Act
|
||||
var matcher = (JsonMatcher)_sut.Map(model);
|
||||
|
||||
// Assert
|
||||
matcher.MatchBehaviour.Should().Be(MatchBehaviour.AcceptOnMatch);
|
||||
matcher.Value.Should().BeEquivalentTo(patterns);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_JsonMatcher_Pattern_As_Object()
|
||||
{
|
||||
// Assign
|
||||
var pattern = new { AccountIds = new[] { 1, 2, 3 } };
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "JsonMatcher",
|
||||
Pattern = pattern
|
||||
};
|
||||
|
||||
// Act
|
||||
var matcher = (JsonMatcher)_sut.Map(model);
|
||||
|
||||
// Assert
|
||||
matcher.MatchBehaviour.Should().Be(MatchBehaviour.AcceptOnMatch);
|
||||
matcher.Value.Should().BeEquivalentTo(pattern);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_JsonMatcher_Patterns_As_Object()
|
||||
{
|
||||
// Assign
|
||||
object pattern1 = new { AccountIds = new[] { 1, 2, 3 } };
|
||||
object pattern2 = new { X = "x" };
|
||||
var patterns = new[] { pattern1, pattern2 };
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "JsonMatcher",
|
||||
Patterns = patterns
|
||||
};
|
||||
|
||||
// Act
|
||||
var matcher = (JsonMatcher)_sut.Map(model);
|
||||
|
||||
// Assert
|
||||
matcher.MatchBehaviour.Should().Be(MatchBehaviour.AcceptOnMatch);
|
||||
matcher.Value.Should().BeEquivalentTo(patterns);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user