Allow mapping without Path or Url (#1169)

This commit is contained in:
Stef Heyenrath
2024-09-09 20:48:09 +02:00
committed by GitHub
parent af124d556d
commit 7d7f1f8fbb
3 changed files with 42 additions and 23 deletions

View File

@@ -11,9 +11,11 @@ using FluentAssertions;
using Moq;
using Newtonsoft.Json;
using NFluent;
using WireMock.Admin.Settings;
using RestEase;
using WireMock.Client;
using WireMock.Handlers;
using WireMock.Logging;
using WireMock.Matchers.Request;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;
@@ -244,6 +246,38 @@ public class WireMockServerAdminTests
loggerMock.Verify(l => l.Info(It.Is<string>(s => s.StartsWith("The Static Mapping folder")), It.IsAny<object[]>()), Times.Once);
}
[Fact]
public async Task WireMockServer_Admin_Mapping_WithoutPathOrUrl()
{
// Arrange
using var server = WireMockServer.StartWithAdminInterface();
// Act
server.Given(Request.Create().UsingGet())
.RespondWith(Response.Create());
// Assert
var mapping = server.Mappings.First(m => !m.IsAdminInterface);
var request = (Request) mapping.RequestMatcher;
var pathMatcher = request.GetRequestMessageMatcher<RequestMessagePathMatcher>();
pathMatcher.Should().BeNull();
var api = RestClient.For<IWireMockAdminApi>(server.Url);
var mappingModels = await api.GetMappingsAsync();
var mappingModel = mappingModels.First();
mappingModel.Request.Path.Should().BeNull();
mappingModel.Request.Url.Should().BeNull();
await api.DeleteMappingsAsync();
await api.PostMappingAsync(mappingModel);
await api.GetMappingsAsync();
mappingModels = await api.GetMappingsAsync();
mappingModel = mappingModels.First();
mappingModel.Request.Path.Should().BeNull();
mappingModel.Request.Url.Should().BeNull();
}
[Fact]
public void WireMockServer_Admin_Mappings_WithGuid_Get()
{