mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abe996671e | ||
|
|
9f819de696 | ||
|
|
f5d53453e5 | ||
|
|
0e60e3f3f9 | ||
|
|
9cee6dde00 | ||
|
|
c88e7378a7 | ||
|
|
b090296559 |
36
.github/workflows/copilot-setup-steps.yml
vendored
Normal file
36
.github/workflows/copilot-setup-steps.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: "Copilot Setup Steps"
|
||||
|
||||
# Automatically run the setup steps when they are changed to allow for easy validation, and
|
||||
# allow manual testing through the repository's "Actions" tab
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- .github/workflows/copilot-setup-steps.yml
|
||||
pull_request:
|
||||
paths:
|
||||
- .github/workflows/copilot-setup-steps.yml
|
||||
|
||||
jobs:
|
||||
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
|
||||
copilot-setup-steps:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Set the permissions to the lowest permissions possible needed for your steps.
|
||||
# Copilot will be given its own token for its operations.
|
||||
permissions:
|
||||
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
|
||||
contents: read
|
||||
|
||||
# You can define any steps you want, and they will run before the agent starts.
|
||||
# If you do not check out your code, Copilot will do this for you.
|
||||
steps:
|
||||
- name: Install .NET 10.x
|
||||
uses: actions/setup-dotnet@v5
|
||||
with:
|
||||
dotnet-version: |
|
||||
10.x
|
||||
dotnet-quality: preview
|
||||
|
||||
- name: dotnet --info
|
||||
run: dotnet --info
|
||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,3 +1,13 @@
|
||||
# 1.23.0 (05 January 2026)
|
||||
- [#1414](https://github.com/wiremock/WireMock.Net/pull/1414) - Pass the parameter matchOperator in Request.WithPath to its inner calls [bug] contributed by [gbamqzkdyg](https://github.com/gbamqzkdyg)
|
||||
- [#1416](https://github.com/wiremock/WireMock.Net/pull/1416) - Fix: Pass AllowedHandlebarsHelpers configuration to Handlebars.Net.Helpers library contributed by [samlatham](https://github.com/samlatham)
|
||||
- [#1413](https://github.com/wiremock/WireMock.Net/issues/1413) - Parameter `matchOperator` is not respected in the method Request.WithPath [bug]
|
||||
- [#1415](https://github.com/wiremock/WireMock.Net/issues/1415) - HandlebarsSettings AllowedHandlebarsHelpers Configuration Not Applied [bug]
|
||||
|
||||
# 1.22.0 (02 January 2026)
|
||||
- [#1412](https://github.com/wiremock/WireMock.Net/pull/1412) - chore(testcontainers): bump up Testcontainers to version 4.10.0 [feature] contributed by [vhatsura](https://github.com/vhatsura)
|
||||
- [#1411](https://github.com/wiremock/WireMock.Net/issues/1411) - WireMock.Net.Testcontainers isn't compatible with Testcontainers 4.10.0 [bug]
|
||||
|
||||
# 1.21.0 (25 December 2025)
|
||||
- [#1408](https://github.com/wiremock/WireMock.Net/pull/1408) - Fix readyness-check for Testcontainers [bug] contributed by [StefH](https://github.com/StefH)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.21.0</VersionPrefix>
|
||||
<VersionPrefix>1.23.0</VersionPrefix>
|
||||
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
|
||||
<PackageProjectUrl>https://github.com/wiremock/WireMock.Net</PackageProjectUrl>
|
||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
rem https://github.com/StefH/GitHubReleaseNotes
|
||||
|
||||
SET version=1.21.0
|
||||
SET version=1.23.0
|
||||
|
||||
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels wontfix test question invalid doc duplicate example environment --version %version% --token %GH_TOKEN%
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
# 1.21.0 (25 December 2025)
|
||||
- #1408 Fix readyness-check for Testcontainers [bug]
|
||||
# 1.23.0 (05 January 2026)
|
||||
- #1414 Pass the parameter matchOperator in Request.WithPath to its inner calls [bug]
|
||||
- #1416 Fix: Pass AllowedHandlebarsHelpers configuration to Handlebars.Net.Helpers library
|
||||
- #1413 Parameter `matchOperator` is not respected in the method Request.WithPath [bug]
|
||||
- #1415 HandlebarsSettings AllowedHandlebarsHelpers Configuration Not Applied [bug]
|
||||
|
||||
The full release notes can be found here: https://github.com/wiremock/WireMock.Net/blob/master/CHANGELOG.md
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="9.2.0" />
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="13.1.0" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
@@ -18,7 +18,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.2.0" />
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="9.2.0" />
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="13.1.0" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
@@ -15,7 +15,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.2.0" />
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.Testing" Version="8.0.0" />
|
||||
<PackageReference Include="Aspire.Hosting.Testing" Version="13.1.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||
<PackageReference Include="xunit" Version="2.5.3" />
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting" Version="9.2.0" />
|
||||
<PackageReference Include="Aspire.Hosting" Version="13.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -21,7 +21,7 @@ public partial class Request
|
||||
{
|
||||
Guard.NotNullOrEmpty(matchers);
|
||||
|
||||
_requestMatchers.Add(new RequestMessagePathMatcher(MatchBehaviour.AcceptOnMatch, MatchOperator.Or, matchers));
|
||||
_requestMatchers.Add(new RequestMessagePathMatcher(MatchBehaviour.AcceptOnMatch, matchOperator, matchers));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ internal static class WireMockHandlebarsHelpers
|
||||
#endif
|
||||
o.CustomHelperPaths = paths;
|
||||
|
||||
o.Categories = settings.HandlebarsSettings?.AllowedHandlebarsHelpers ?? HandlebarsSettings.DefaultAllowedHandlebarsHelpers;
|
||||
|
||||
o.CustomHelpers = new Dictionary<string, IHelpers>();
|
||||
if (settings.HandlebarsSettings?.AllowedCustomHandlebarsHelpers.HasFlag(CustomHandlebarsHelpers.File) == true)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Stef.Validation" Version="0.1.1" />
|
||||
<PackageReference Include="Testcontainers" Version="4.8.0" />
|
||||
<PackageReference Include="Testcontainers" Version="4.10.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="9.2.0" />
|
||||
<Sdk Name="Aspire.AppHost.Sdk" Version="13.1.0" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
@@ -19,7 +19,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.2.0" />
|
||||
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.Testing" Version="9.2.0" />
|
||||
<PackageReference Include="Aspire.Hosting.Testing" Version="13.1.0" />
|
||||
<PackageReference Include="Codecov" Version="1.13.0" />
|
||||
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
93
test/WireMock.Net.Tests/Settings/HandlebarsSettingsTests.cs
Normal file
93
test/WireMock.Net.Tests/Settings/HandlebarsSettingsTests.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using HandlebarsDotNet;
|
||||
using HandlebarsDotNet.Helpers.Enums;
|
||||
using Moq;
|
||||
using WireMock.Handlers;
|
||||
using WireMock.Models;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Settings;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Settings;
|
||||
|
||||
public class HandlebarsSettingsTests
|
||||
{
|
||||
private const string ClientIp = "::1";
|
||||
|
||||
private readonly WireMockServerSettings _settings;
|
||||
private readonly Mock<IMapping> _mappingMock;
|
||||
private readonly Mock<IFileSystemHandler> _fileSystemHandlerMock;
|
||||
|
||||
public HandlebarsSettingsTests()
|
||||
{
|
||||
_mappingMock = new Mock<IMapping>();
|
||||
|
||||
_fileSystemHandlerMock = new Mock<IFileSystemHandler>(MockBehavior.Strict);
|
||||
|
||||
_settings = new WireMockServerSettings
|
||||
{
|
||||
FileSystemHandler = _fileSystemHandlerMock.Object
|
||||
};
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_HandlebarsHelpers_Environment_NotAllowed_By_Default()
|
||||
{
|
||||
// Arrange
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp);
|
||||
|
||||
var responseBuilder = Response.Create()
|
||||
.WithBody("Username: {{Environment.GetEnvironmentVariable \"USERNAME\"}}")
|
||||
.WithTransformer();
|
||||
|
||||
// Act
|
||||
Func<Task> action = () => responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings);
|
||||
|
||||
// Assert
|
||||
await action.Should().ThrowAsync<HandlebarsRuntimeException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_HandlebarsHelpers_Environment_Allowed_When_Configured()
|
||||
{
|
||||
// Arrange
|
||||
var settingsWithEnv = new WireMockServerSettings
|
||||
{
|
||||
FileSystemHandler = _fileSystemHandlerMock.Object,
|
||||
HandlebarsSettings = new HandlebarsSettings
|
||||
{
|
||||
AllowedHandlebarsHelpers = HandlebarsSettings.DefaultAllowedHandlebarsHelpers
|
||||
.Concat([Category.Environment])
|
||||
.ToArray()
|
||||
}
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp);
|
||||
|
||||
var responseBuilder = Response.Create()
|
||||
.WithBody("User: {{Environment.GetEnvironmentVariable \"USERNAME\"}}")
|
||||
.WithTransformer();
|
||||
|
||||
// Act
|
||||
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, settingsWithEnv).ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response.Message?.BodyData?.BodyAsString.Should().NotContain("{{Environment.GetEnvironmentVariable");
|
||||
response.Message?.BodyData?.BodyAsString.Should().StartWith("User: ");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultAllowedHandlebarsHelpers_Should_Not_Include_EnvironmentAndDynamicLinq()
|
||||
{
|
||||
// Assert
|
||||
HandlebarsSettings.DefaultAllowedHandlebarsHelpers.Should()
|
||||
.NotContain(Category.Environment)
|
||||
.And
|
||||
.NotContain(Category.DynamicLinq);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user