Add support for Cors (#714)

This commit is contained in:
Stef Heyenrath
2022-01-24 12:26:19 +01:00
committed by GitHub
parent d6c36bc23b
commit ccd433b202
15 changed files with 173 additions and 35 deletions

View File

@@ -17,6 +17,7 @@ using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;
using WireMock.Settings;
using WireMock.Types;
using WireMock.Util;
using Xunit;
@@ -97,6 +98,29 @@ namespace WireMock.Net.Tests
server.Stop();
}
#if NETCOREAPP3_1_OR_GREATER
[Fact]
public async Task WireMockServer_WithCorsPolicyOptions_Should_Work_Correct()
{
// Arrange
var settings = new WireMockServerSettings
{
CorsPolicyOptions = CorsPolicyOptions.AllowAll
};
var server = WireMockServer.Start(settings);
server.Given(Request.Create().WithPath("/*")).RespondWith(Response.Create().WithBody("x"));
// Act
var response = await new HttpClient().GetStringAsync("http://localhost:" + server.Ports[0] + "/foo").ConfigureAwait(false);
// Asser.
response.Should().Be("x");
server.Stop();
}
#endif
[Fact]
public async Task WireMockServer_Should_delay_responses_for_a_given_route()
{