mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-13 22:03:35 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb1d2a5294 | ||
|
|
4b435faf0b | ||
|
|
5e7cb44525 | ||
|
|
444298c28c | ||
|
|
6f42aa99bc | ||
|
|
8a9ea1b843 | ||
|
|
dade24de37 | ||
|
|
6beaa631f4 | ||
|
|
282281aa7f | ||
|
|
4052a0ef3b |
4
.github/FUNDING.yml
vendored
4
.github/FUNDING.yml
vendored
@@ -1,8 +1,8 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
github: [StefH]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
open_collective: # wiremocknet
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
|
||||
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,3 +1,13 @@
|
||||
# 1.4.18 (10 July 2021)
|
||||
- [#619](https://github.com/WireMock-Net/WireMock.Net/pull/619) - Update Handlebars.Net.Helpers.XPath to fix issue with 'xml version' contributed by [StefH](https://github.com/StefH)
|
||||
- [#618](https://github.com/WireMock-Net/WireMock.Net/issues/618) - Trying to use attribute of the request object while creating response while mocking a soap service [bug]
|
||||
|
||||
# 1.4.17 (07 July 2021)
|
||||
- [#617](https://github.com/WireMock-Net/WireMock.Net/pull/617) - Add support for Handlebars.Net.Helpers.Humanizer [feature] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
# 1.4.16 (05 June 2021)
|
||||
- [#616](https://github.com/WireMock-Net/WireMock.Net/pull/616) - Upgrade Handlebars.Net.Helpers to 2.19 [feature] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
# 1.4.15 (19 May 2021)
|
||||
- [#615](https://github.com/WireMock-Net/WireMock.Net/pull/615) - Add support for multiple webhooks [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#614](https://github.com/WireMock-Net/WireMock.Net/issues/614) - Is it possible to some how send multiple webhooks? [feature]
|
||||
@@ -81,6 +91,7 @@
|
||||
- [#549](https://github.com/WireMock-Net/WireMock.Net/issues/549) - WithProxy(...) does not save the mappings to file [bug]
|
||||
|
||||
# 1.3.8 (03 December 2020)
|
||||
- [#539](https://github.com/WireMock-Net/WireMock.Net/pull/539) - Support for partial JSON matching contributed by [gleb-osokin](https://github.com/gleb-osokin)
|
||||
- [#542](https://github.com/WireMock-Net/WireMock.Net/pull/542) - Create dotnet-wiremock tool [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#543](https://github.com/WireMock-Net/WireMock.Net/pull/543) - Add support for .NET 5 [feature] contributed by [StefH](https://github.com/StefH)
|
||||
- [#544](https://github.com/WireMock-Net/WireMock.Net/pull/544) - Use Java 11 in Azure Pipelines (needed for SonarCloud) [feature] contributed by [StefH](https://github.com/StefH)
|
||||
@@ -88,9 +99,6 @@
|
||||
- [#547](https://github.com/WireMock-Net/WireMock.Net/pull/547) - Fix Proxying with SSL and NetCoreApp3.1 [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#524](https://github.com/WireMock-Net/WireMock.Net/issues/524) - Proxying with SSL Not Working in .NET Core 3.1 [bug]
|
||||
|
||||
# 1.3.7 (17 November 2020)
|
||||
- [#539](https://github.com/WireMock-Net/WireMock.Net/pull/539) - Support for partial JSON matching contributed by [gleb-osokin](https://github.com/gleb-osokin)
|
||||
|
||||
# 1.3.6 (10 November 2020)
|
||||
- [#529](https://github.com/WireMock-Net/WireMock.Net/pull/529) - Add assertions for ClientIP, Url and ProxyUrl [feature] contributed by [akamud](https://github.com/akamud)
|
||||
- [#535](https://github.com/WireMock-Net/WireMock.Net/pull/535) - WithCallback should use also use enum HttpStatusCode [bug] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.4.15</VersionPrefix>
|
||||
<VersionPrefix>1.4.18</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 --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.4.15
|
||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.4.18
|
||||
@@ -121,13 +121,16 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Handlebars.Net.Helpers" Version="2.1.2" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.1.2" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.1.2" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.1.2" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.1.2" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.1.2" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers" Version="2.2.1" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.DynamicLinq" Version="2.2.1" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Humanizer" Version="2.2.1" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Json" Version="2.2.1" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.XPath" Version="2.2.1" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Xeger" Version="2.2.1" />
|
||||
<PackageReference Include="Handlebars.Net.Helpers.Random" Version="2.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NFluent;
|
||||
using WireMock.Handlers;
|
||||
using WireMock.Models;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Settings;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
public class ResponseWithHandlebarsHumanizerTests
|
||||
{
|
||||
private const string ClientIp = "::1";
|
||||
|
||||
private readonly Mock<IFileSystemHandler> _filesystemHandlerMock;
|
||||
private readonly WireMockServerSettings _settings = new WireMockServerSettings();
|
||||
|
||||
public ResponseWithHandlebarsHumanizerTests()
|
||||
{
|
||||
_filesystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||
_filesystemHandlerMock.Setup(fs => fs.ReadResponseBodyAsString(It.IsAny<string>())).Returns("abc");
|
||||
|
||||
_settings.FileSystemHandler = _filesystemHandlerMock.Object;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponseAsync_Handlebars_Humanizer()
|
||||
{
|
||||
// Assign
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp);
|
||||
|
||||
var responseBuilder = Response.Create()
|
||||
.WithBodyAsJson(new
|
||||
{
|
||||
DateTime = string.Format("{{{{[Humanizer.Humanize] \"{0}\" }}}}", DateTime.UtcNow.AddHours(-30).ToString("O"))
|
||||
})
|
||||
.WithTransformer();
|
||||
|
||||
// Act
|
||||
var response = await responseBuilder.ProvideResponseAsync(request, _settings);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
|
||||
Check.That(j["DateTime"].Value<string>()).IsEqualTo("yesterday");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,25 +65,6 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
Check.That(response.Message.BodyData.BodyAsString).Equals("");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponseAsync_Handlebars_RegexMatch_NoMatch_WithDefaultValue()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsString = "abc", DetectedBodyType = BodyType.String };
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
var responseBuilder = Response.Create()
|
||||
.WithBody("{{Regex.Match request.body \"^?0$\" \"d\"}}")
|
||||
.WithTransformer();
|
||||
|
||||
// Act
|
||||
var response = await responseBuilder.ProvideResponseAsync(request, _settings);
|
||||
|
||||
// assert
|
||||
Check.That(response.Message.BodyData.BodyAsString).Equals("d");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponseAsync_Handlebars_RegexMatch2()
|
||||
{
|
||||
@@ -122,25 +103,6 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
Check.That(response.Message.BodyData.BodyAsString).Equals("");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponseAsync_Handlebars_RegexMatch2_NoMatch_WithDefaultValue()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsString = "{{\\test", DetectedBodyType = BodyType.String };
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
var responseBuilder = Response.Create()
|
||||
.WithBody("{{#Regex.Match request.body \"^(?<proto>\\w+)://[^/]+?(?<port>\\d+)/?\" \"x\"}}{{this}}{{/Regex.Match}}")
|
||||
.WithTransformer();
|
||||
|
||||
// Act
|
||||
var response = await responseBuilder.ProvideResponseAsync(request, _settings);
|
||||
|
||||
// assert
|
||||
Check.That(response.Message.BodyData.BodyAsString).Equals("x");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Response_ProvideResponseAsync_Handlebars_RegexMatch2_Throws()
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ using WireMock.Util;
|
||||
using Xunit;
|
||||
using Moq;
|
||||
using WireMock.Handlers;
|
||||
using FluentAssertions;
|
||||
#if !NETSTANDARD1_3
|
||||
using Wmhelp.XPath2;
|
||||
#endif
|
||||
@@ -119,6 +120,62 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
Check.That(nodes.Count + 1).IsEqualTo(3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponse_Handlebars_XPath_SelectSingleNode_Request_SoapXML_BodyAsString()
|
||||
{
|
||||
// Assign
|
||||
string soap = @"
|
||||
<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ns=""http://www.Test.nl/XMLHeader/10"" xmlns:req=""http://www.Test.nl/Betalen/COU/Services/RdplDbTknLystByOvkLyst/8/Req"">
|
||||
<soapenv:Header>
|
||||
<ns:TestHeader>
|
||||
<ns:HeaderVersion>10</ns:HeaderVersion>
|
||||
<ns:MessageId>MsgId10</ns:MessageId>
|
||||
<ns:ServiceRequestorDomain>Betalen</ns:ServiceRequestorDomain>
|
||||
<ns:ServiceRequestorId>CRM</ns:ServiceRequestorId>
|
||||
<ns:ServiceProviderDomain>COU</ns:ServiceProviderDomain>
|
||||
<ns:ServiceId>RdplDbTknLystByOvkLyst</ns:ServiceId>
|
||||
<ns:ServiceVersion>8</ns:ServiceVersion>
|
||||
<ns:FaultIndication>N</ns:FaultIndication>
|
||||
<ns:MessageTimestamp>?</ns:MessageTimestamp>
|
||||
</ns:TestHeader>
|
||||
</soapenv:Header>
|
||||
<soapenv:Body>
|
||||
<req:RdplDbTknLystByOvkLyst_REQ>
|
||||
<req:AanleveraarCode>CRM</req:AanleveraarCode>
|
||||
<!--Optional:-->
|
||||
<req:AanleveraarDetail>CRMi</req:AanleveraarDetail>
|
||||
<req:BerichtId>BerId</req:BerichtId>
|
||||
<req:BerichtType>RdplDbTknLystByOvkLyst</req:BerichtType>
|
||||
<!--Optional:-->
|
||||
<req:OpgenomenBedragenGewenstIndicatie>N</req:OpgenomenBedragenGewenstIndicatie>
|
||||
<req:TokenIdLijst>
|
||||
<!--1 to 10 repetitions:-->
|
||||
<req:TokenId>0000083256</req:TokenId>
|
||||
<req:TokenId>0000083259</req:TokenId>
|
||||
</req:TokenIdLijst>
|
||||
</req:RdplDbTknLystByOvkLyst_REQ>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>";
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = soap,
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
var responseBuilder = Response.Create()
|
||||
.WithHeader("Content-Type", "application/xml")
|
||||
.WithBody("<response>{{XPath.SelectSingleNode request.body \"//*[local-name()='TokenIdLijst']\"}}</response>")
|
||||
.WithTransformer();
|
||||
|
||||
// Act
|
||||
var response = await responseBuilder.ProvideResponseAsync(request, _settings);
|
||||
|
||||
// Assert
|
||||
response.Message.BodyData.BodyAsString.Should().Contain("TokenIdLijst").And.Contain("0000083256").And.Contain("0000083259");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponse_Handlebars_XPath_Evaluate_Request_BodyAsString()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user