mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-21 00:28:59 +01:00
Allow mapping without Path or Url (#1169)
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user