mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-14 22:33:35 +01:00
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using NFluent;
|
|
using WireMock.Matchers;
|
|
using WireMock.Owin;
|
|
using WireMock.Server;
|
|
using Xunit;
|
|
|
|
namespace WireMock.Net.Tests
|
|
{
|
|
public class WireMockServerAuthenticationTests
|
|
{
|
|
[Fact]
|
|
public void WireMockServer_Authentication_SetBasicAuthentication()
|
|
{
|
|
// Assign
|
|
var server = WireMockServer.Start();
|
|
|
|
// Act
|
|
server.SetBasicAuthentication("x", "y");
|
|
|
|
// Assert
|
|
var options = server.GetPrivateFieldValue<IWireMockMiddlewareOptions>("_options");
|
|
Check.That(options.AuthorizationMatcher.Name).IsEqualTo("RegexMatcher");
|
|
Check.That(options.AuthorizationMatcher.MatchBehaviour).IsEqualTo(MatchBehaviour.AcceptOnMatch);
|
|
Check.That(options.AuthorizationMatcher.GetPatterns()).ContainsExactly("^(?i)BASIC eDp5$");
|
|
|
|
server.Stop();
|
|
}
|
|
|
|
[Fact]
|
|
public void WireMockServer_Authentication_RemoveBasicAuthentication()
|
|
{
|
|
// Assign
|
|
var server = WireMockServer.Start();
|
|
server.SetBasicAuthentication("x", "y");
|
|
|
|
// Act
|
|
server.RemoveBasicAuthentication();
|
|
|
|
// Assert
|
|
var options = server.GetPrivateFieldValue<IWireMockMiddlewareOptions>("_options");
|
|
Check.That(options.AuthorizationMatcher).IsNull();
|
|
|
|
server.Stop();
|
|
}
|
|
}
|
|
} |