mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-22 16:58:06 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09a302baf2 | ||
|
|
f0139eb837 | ||
|
|
8adf34fb56 | ||
|
|
fd816f0952 | ||
|
|
205c1d598b | ||
|
|
b986633eca |
@@ -1,3 +1,11 @@
|
||||
# 1.5.35 (19 August 2023)
|
||||
- [#992](https://github.com/WireMock-Net/WireMock.Net/pull/992) - Add extra unit test for WithParam multiple values comma [test] contributed by [StefH](https://github.com/StefH)
|
||||
- [#993](https://github.com/WireMock-Net/WireMock.Net/pull/993) - Update JSONPathMatcher.cs to cover the string path selection to a child contributed by [DayLightDancer](https://github.com/DayLightDancer)
|
||||
|
||||
# 1.5.34 (04 August 2023)
|
||||
- [#989](https://github.com/WireMock-Net/WireMock.Net/pull/989) - Fix MimeKitLite NuGet include [bug] contributed by [StefH](https://github.com/StefH)
|
||||
- [#988](https://github.com/WireMock-Net/WireMock.Net/issues/988) - v1.5.33 Returns always StatusCode 500 [bug]
|
||||
|
||||
# 1.5.33 (03 August 2023)
|
||||
- [#972](https://github.com/WireMock-Net/WireMock.Net/pull/972) - JsonPartialMatcher - match guid and string contributed by [timurnes](https://github.com/timurnes)
|
||||
- [#976](https://github.com/WireMock-Net/WireMock.Net/pull/976) - Upgrade to Handlebars.Net.Helpers 2.4.0 to update XPath.SelectTokens and XPath.EvaluateToString [feature] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.5.33</VersionPrefix>
|
||||
<VersionPrefix>1.5.35</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.33
|
||||
SET version=1.5.35
|
||||
|
||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate --version %version% --token %GH_TOKEN%
|
||||
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
# 1.5.33 (03 August 2023)
|
||||
- #972 JsonPartialMatcher - match guid and string
|
||||
- #976 Upgrade to Handlebars.Net.Helpers 2.4.0 to update XPath.SelectTokens and XPath.EvaluateToString [feature]
|
||||
- #981 Add MultiPart/MimePart Request Matcher [feature]
|
||||
- #968 Using request multipart in response template [feature]
|
||||
- #969 Multipart validation [feature]
|
||||
- #970 Loop through xml elements in handlebars template [feature]
|
||||
- #971 JsonPartialMatcher - match guid and string [feature]
|
||||
# 1.5.35 (19 August 2023)
|
||||
- #992 Add extra unit test for WithParam multiple values comma [test]
|
||||
- #993 Update JSONPathMatcher.cs to cover the string path selection to a child
|
||||
|
||||
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md
|
||||
@@ -117,7 +117,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Testcontainers
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{0147029F-FA4A-44B3-B79A-3C3574054EE4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultipartUploader", "tools\MultipartUploader\MultipartUploader.csproj", "{07C30227-ADEC-4BDE-8CDC-849D85A690BB}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultipartUploader", "tools\MultipartUploader\MultipartUploader.csproj", "{07C30227-ADEC-4BDE-8CDC-849D85A690BB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.NET7.UsingNuGet", "examples\WireMock.Net.Console.NET7.UsingNuGet\WireMock.Net.Console.NET7.UsingNuGet.csproj", "{941229D6-191B-4B5E-AC81-0905EBF4F19D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -285,6 +287,10 @@ Global
|
||||
{07C30227-ADEC-4BDE-8CDC-849D85A690BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{07C30227-ADEC-4BDE-8CDC-849D85A690BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{07C30227-ADEC-4BDE-8CDC-849D85A690BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{941229D6-191B-4B5E-AC81-0905EBF4F19D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{941229D6-191B-4B5E-AC81-0905EBF4F19D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{941229D6-191B-4B5E-AC81-0905EBF4F19D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{941229D6-191B-4B5E-AC81-0905EBF4F19D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -332,6 +338,7 @@ Global
|
||||
{12B016A5-9D8B-4EFE-96C2-CA51BE43367D} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||
{56A38798-C48B-4A4A-B805-071E05C02CE1} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||
{07C30227-ADEC-4BDE-8CDC-849D85A690BB} = {0147029F-FA4A-44B3-B79A-3C3574054EE4}
|
||||
{941229D6-191B-4B5E-AC81-0905EBF4F19D} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||
<PackageReference Include="log4net" Version="2.0.15" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
|
||||
<PackageReference Include="MimeKitLite" Version="4.1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
34
examples/WireMock.Net.Console.NET7.UsingNuGet/Program.cs
Normal file
34
examples/WireMock.Net.Console.NET7.UsingNuGet/Program.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using FluentAssertions;
|
||||
using WireMock.Logging;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Server;
|
||||
using WireMock.Settings;
|
||||
|
||||
namespace WireMock.Net.Console.NET7.UsingNuGet;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
var server = WireMockServer.Start(new WireMockServerSettings
|
||||
{
|
||||
Logger = new WireMockConsoleLogger(),
|
||||
});
|
||||
|
||||
server.Given(Request.Create().UsingPost().WithPath("/some/endpoint"))
|
||||
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.Created));
|
||||
|
||||
var httpClient = new HttpClient { BaseAddress = new Uri(server.Url!) };
|
||||
var requestUri = new Uri(httpClient.BaseAddress!, "some/endpoint");
|
||||
var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
|
||||
|
||||
// Act
|
||||
var actual = await httpClient.PostAsync(requestUri, content);
|
||||
|
||||
// Assert
|
||||
actual.StatusCode.Should().Be(HttpStatusCode.Created);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version="6.11.0" />
|
||||
<PackageReference Include="WireMock.Net" Version="1.5.32" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -123,7 +123,9 @@ public class JsonPathMatcher : IStringMatcher, IObjectMatcher
|
||||
{
|
||||
var array = ConvertJTokenToJArrayIfNeeded(jToken);
|
||||
|
||||
return MatchScores.ToScore(_patterns.Select(pattern => array.SelectToken(pattern.GetPattern())?.Any() == true).ToArray(), MatchOperator);
|
||||
// The SelectToken method can accept a string path to a child token ( i.e. "Manufacturers[0].Products[0].Price").
|
||||
// In that case it will return a JValue (some type) which does not implement the IEnumerable interface.
|
||||
return MatchScores.ToScore(_patterns.Select(pattern => array.SelectToken(pattern.GetPattern()) != null).ToArray(), MatchOperator);
|
||||
}
|
||||
|
||||
// https://github.com/WireMock-Net/WireMock.Net/issues/965
|
||||
@@ -138,9 +140,9 @@ public class JsonPathMatcher : IStringMatcher, IObjectMatcher
|
||||
var item = property.First();
|
||||
if (item is JArray)
|
||||
{
|
||||
return jToken;
|
||||
return jToken;
|
||||
}
|
||||
|
||||
|
||||
return new JObject
|
||||
{
|
||||
[property.Path] = new JArray(item)
|
||||
@@ -149,4 +151,4 @@ public class JsonPathMatcher : IStringMatcher, IObjectMatcher
|
||||
|
||||
return jToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard1.3' and '$(TargetFramework)' != 'net451' and '$(TargetFramework)' != 'net452' and '$(TargetFramework)' != 'net46' and '$(TargetFramework)' != 'net461'">
|
||||
<PackageReference Include="GraphQL" Version="7.5.0" />
|
||||
<PackageReference Include="GraphQL.NewtonsoftJson" Version="7.5.0" />
|
||||
<PackageReference Include="MimeKitLite" Version="4.1.0.1" PrivateAssets="all" />
|
||||
<PackageReference Include="MimeKitLite" Version="4.1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
|
||||
|
||||
@@ -200,4 +200,128 @@ public class JsonPathMatcherTests
|
||||
// Assert
|
||||
Check.That(match).IsEqualTo(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonPathMatcher_IsMatch_ArrayOneLevel()
|
||||
{
|
||||
// Arrange
|
||||
var matcher = new JsonPathMatcher("$.arr[0].line1");
|
||||
|
||||
// Act
|
||||
double match = matcher.IsMatch(JObject.Parse(@"{
|
||||
""name"": ""PathSelectorTest"",
|
||||
""test"": ""test"",
|
||||
""test2"": ""test2"",
|
||||
""arr"": [{
|
||||
""line1"": ""line1"",
|
||||
}]
|
||||
}"));
|
||||
|
||||
// Assert
|
||||
Check.That(match).IsEqualTo(1.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonPathMatcher_IsMatch_ObjectMatch()
|
||||
{
|
||||
// Arrange
|
||||
var matcher = new JsonPathMatcher("$.test");
|
||||
|
||||
// Act
|
||||
double match = matcher.IsMatch(JObject.Parse(@"{
|
||||
""name"": ""PathSelectorTest"",
|
||||
""test"": ""test"",
|
||||
""test2"": ""test2"",
|
||||
""arr"": [
|
||||
{
|
||||
""line1"": ""line1"",
|
||||
}
|
||||
]
|
||||
}"));
|
||||
|
||||
// Assert
|
||||
Check.That(match).IsEqualTo(1.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonPathMatcher_IsMatch_DoesntMatch()
|
||||
{
|
||||
// Arrange
|
||||
var matcher = new JsonPathMatcher("$.test3");
|
||||
|
||||
// Act
|
||||
double match = matcher.IsMatch(JObject.Parse(@"{
|
||||
""name"": ""PathSelectorTest"",
|
||||
""test"": ""test"",
|
||||
""test2"": ""test2"",
|
||||
""arr"": [
|
||||
{
|
||||
""line1"": ""line1"",
|
||||
}
|
||||
]
|
||||
}"));
|
||||
|
||||
// Assert
|
||||
Check.That(match).IsEqualTo(0.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonPathMatcher_IsMatch_DoesntMatchInArray()
|
||||
{
|
||||
// Arrange
|
||||
var matcher = new JsonPathMatcher("$arr[0].line1");
|
||||
|
||||
// Act
|
||||
double match = matcher.IsMatch(JObject.Parse(@"{
|
||||
""name"": ""PathSelectorTest"",
|
||||
""test"": ""test"",
|
||||
""test2"": ""test2"",
|
||||
""arr"": []
|
||||
}"));
|
||||
|
||||
// Assert
|
||||
Check.That(match).IsEqualTo(0.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonPathMatcher_IsMatch_DoesntMatchNoObjectsInArray()
|
||||
{
|
||||
// Arrange
|
||||
var matcher = new JsonPathMatcher("$arr[2].line1");
|
||||
|
||||
// Act
|
||||
double match = matcher.IsMatch(JObject.Parse(@"{
|
||||
""name"": ""PathSelectorTest"",
|
||||
""test"": ""test"",
|
||||
""test2"": ""test2"",
|
||||
""arr"": []
|
||||
}"));
|
||||
|
||||
// Assert
|
||||
Check.That(match).IsEqualTo(0.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonPathMatcher_IsMatch_NestedArrays()
|
||||
{
|
||||
// Arrange
|
||||
var matcher = new JsonPathMatcher("$.arr[0].sub[0].subline1");
|
||||
|
||||
// Act
|
||||
double match = matcher.IsMatch(JObject.Parse(@"{
|
||||
""name"": ""PathSelectorTest"",
|
||||
""test"": ""test"",
|
||||
""test2"": ""test2"",
|
||||
""arr"": [{
|
||||
""line1"": ""line1"",
|
||||
""sub"":[
|
||||
{
|
||||
""subline1"":""subline1""
|
||||
}]
|
||||
}]
|
||||
}"));
|
||||
|
||||
// Assert
|
||||
Check.That(match).IsEqualTo(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,6 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Verify.Xunit" Version="19.6.0" />
|
||||
<PackageReference Include="MimeKitLite" Version="4.1.0.1" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net452'">
|
||||
|
||||
@@ -16,6 +16,7 @@ public partial class WireMockServerTests
|
||||
[Theory]
|
||||
[InlineData("SELECT id, value FROM table WHERE id = 1")]
|
||||
[InlineData("select id, name, value from table where id in (1, 2, 3, 4, 5)")]
|
||||
[InlineData("1,2,3")]
|
||||
public async Task WireMockServer_WithParam_QueryParameterMultipleValueSupport_NoComma_Should_Ignore_Comma(string queryValue)
|
||||
{
|
||||
// Arrange
|
||||
@@ -43,4 +44,30 @@ public partial class WireMockServerTests
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithParam_MultiValueComma()
|
||||
{
|
||||
// Arrange
|
||||
var queryValue = "1,2,3";
|
||||
var server = WireMockServer.Start();
|
||||
server.Given(
|
||||
Request.Create()
|
||||
.UsingGet()
|
||||
.WithPath("/foo")
|
||||
.WithParam("query", "1", "2", "3")
|
||||
)
|
||||
.RespondWith(
|
||||
Response.Create().WithStatusCode(200)
|
||||
);
|
||||
|
||||
// Act
|
||||
var requestUri = new Uri($"http://localhost:{server.Port}/foo?query={queryValue}");
|
||||
var response = await server.CreateClient().GetAsync(requestUri).ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user