mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-07-18 11:01:23 +02:00
* Fix: Fully respect configured custom admin path * Add tests for custom admin path behaviour * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Peter Benko <peter.benko@gmail.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Stef Heyenrath <Stef.Heyenrath@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -50,6 +50,9 @@ public class WireMockMiddlewareTests
|
||||
_guidUtilsMock = new Mock<IGuidUtils>();
|
||||
_guidUtilsMock.Setup(g => g.NewGuid()).Returns(NewGuid);
|
||||
|
||||
var adminPathsMock = new Mock<IAdminPaths>();
|
||||
adminPathsMock.Setup(a => a.Includes(It.IsAny<string?>())).Returns((string? path) => path?.StartsWith("/__admin/") == true);
|
||||
|
||||
_dateTimeUtilsMock = new Mock<IDateTimeUtils>();
|
||||
_dateTimeUtilsMock.Setup(d => d.UtcNow).Returns(UtcNow);
|
||||
|
||||
@@ -89,6 +92,7 @@ public class WireMockMiddlewareTests
|
||||
_sut = new WireMockMiddleware(
|
||||
_ => Task.CompletedTask,
|
||||
_optionsMock.Object,
|
||||
adminPathsMock.Object,
|
||||
_requestMapperMock.Object,
|
||||
_responseMapperMock.Object,
|
||||
_matcherMock.Object,
|
||||
|
||||
@@ -648,4 +648,24 @@ public class WireMockServerAdminTests(ITestOutputHelper output, ITestContextAcce
|
||||
// Assert
|
||||
settings.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WireMockServer_WithCustomAdminPath_AdminRequestsNotInLogEntries()
|
||||
{
|
||||
// Arrange
|
||||
var cancellationToken = TestContext.Current.CancellationToken;
|
||||
using var server = WireMockServer.Start(w =>
|
||||
{
|
||||
w.Logger = new TestOutputHelperWireMockLogger(output);
|
||||
w.StartAdminInterface = true;
|
||||
w.AdminPath = "/custom/__admin";
|
||||
});
|
||||
var client = server.CreateClient();
|
||||
|
||||
// Act
|
||||
await client.GetAsync($"{server.Url}/custom/__admin/settings", cancellationToken);
|
||||
|
||||
// Assert
|
||||
server.LogEntries.Should().BeEmpty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user