mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-25 10:31:01 +01:00
Add Custom Certificate settings (#537)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using FluentAssertions;
|
||||
using NFluent;
|
||||
using WireMock.Util;
|
||||
using Xunit;
|
||||
@@ -13,13 +14,14 @@ namespace WireMock.Net.Tests.Util
|
||||
string url = "test";
|
||||
|
||||
// Act
|
||||
bool result = PortUtils.TryExtract(url, out string proto, out string host, out int port);
|
||||
bool result = PortUtils.TryExtract(url, out bool isHttps, out string proto, out string host, out int port);
|
||||
|
||||
// Assert
|
||||
Check.That(result).IsFalse();
|
||||
Check.That(proto).IsNull();
|
||||
Check.That(host).IsNull();
|
||||
Check.That(port).IsEqualTo(default(int));
|
||||
result.Should().BeFalse();
|
||||
isHttps.Should().BeFalse();
|
||||
proto.Should().BeNull();
|
||||
host.Should().BeNull();
|
||||
port.Should().Be(default(int));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -29,39 +31,58 @@ namespace WireMock.Net.Tests.Util
|
||||
string url = "http://0.0.0.0";
|
||||
|
||||
// Act
|
||||
bool result = PortUtils.TryExtract(url, out string proto, out string host, out int port);
|
||||
bool result = PortUtils.TryExtract(url, out bool isHttps, out string proto, out string host, out int port);
|
||||
|
||||
// Assert
|
||||
Check.That(result).IsFalse();
|
||||
Check.That(proto).IsNull();
|
||||
Check.That(host).IsNull();
|
||||
Check.That(port).IsEqualTo(default(int));
|
||||
result.Should().BeFalse();
|
||||
isHttps.Should().BeFalse();
|
||||
proto.Should().BeNull();
|
||||
host.Should().BeNull();
|
||||
port.Should().Be(default(int));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PortUtils_TryExtract_ValidUrl1_Returns_True()
|
||||
public void PortUtils_TryExtract_Http_Returns_True()
|
||||
{
|
||||
// Assign
|
||||
string url = "http://wiremock.net:1234";
|
||||
|
||||
// Act
|
||||
bool result = PortUtils.TryExtract(url, out bool isHttps, out string proto, out string host, out int port);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
isHttps.Should().BeFalse();
|
||||
proto.Should().Be("http");
|
||||
host.Should().Be("wiremock.net");
|
||||
port.Should().Be(1234);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PortUtils_TryExtract_Https_Returns_True()
|
||||
{
|
||||
// Assign
|
||||
string url = "https://wiremock.net:5000";
|
||||
|
||||
// Act
|
||||
bool result = PortUtils.TryExtract(url, out string proto, out string host, out int port);
|
||||
bool result = PortUtils.TryExtract(url, out bool isHttps, out string proto, out string host, out int port);
|
||||
|
||||
// Assert
|
||||
Check.That(result).IsTrue();
|
||||
Check.That(proto).IsEqualTo("https");
|
||||
Check.That(host).IsEqualTo("wiremock.net");
|
||||
Check.That(port).IsEqualTo(5000);
|
||||
result.Should().BeTrue();
|
||||
isHttps.Should().BeTrue();
|
||||
proto.Should().Be("https");
|
||||
host.Should().Be("wiremock.net");
|
||||
port.Should().Be(5000);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PortUtils_TryExtract_ValidUrl2_Returns_True()
|
||||
public void PortUtils_TryExtract_Https0_0_0_0_Returns_True()
|
||||
{
|
||||
// Assign
|
||||
string url = "https://0.0.0.0:5000";
|
||||
|
||||
// Act
|
||||
bool result = PortUtils.TryExtract(url, out string proto, out string host, out int port);
|
||||
bool result = PortUtils.TryExtract(url, out bool isHttps, out string proto, out string host, out int port);
|
||||
|
||||
// Assert
|
||||
Check.That(result).IsTrue();
|
||||
|
||||
Reference in New Issue
Block a user