Additional host matching tests (#16680)
This commit is contained in:
parent
76193ecdfd
commit
78b9b2e23e
|
|
@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Match_HostWithWildcard()
|
public async Task Match_HostWithWildcard_Unicode()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var endpoint = CreateEndpoint("/hello", hosts: new string[] { "*.contoso.com:8080", });
|
var endpoint = CreateEndpoint("/hello", hosts: new string[] { "*.contoso.com:8080", });
|
||||||
|
|
@ -114,7 +114,23 @@ namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Match_HostWithWildcard_Unicode()
|
public async Task Match_HostWithWildcard_NoSubdomain()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var endpoint = CreateEndpoint("/hello", hosts: new string[] { "*.contoso.com:8080", });
|
||||||
|
|
||||||
|
var matcher = CreateMatcher(endpoint);
|
||||||
|
var httpContext = CreateContext("/hello", "contoso.com:8080");
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await matcher.MatchAsync(httpContext);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
MatcherAssert.AssertNotMatch(httpContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Match_HostWithWildcard_Subdomain()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var endpoint = CreateEndpoint("/hello", hosts: new string[] { "*.contoso.com:8080", });
|
var endpoint = CreateEndpoint("/hello", hosts: new string[] { "*.contoso.com:8080", });
|
||||||
|
|
@ -129,6 +145,54 @@ namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
MatcherAssert.AssertMatch(httpContext, endpoint);
|
MatcherAssert.AssertMatch(httpContext, endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Match_HostWithWildcard_MultipleSubdomains()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var endpoint = CreateEndpoint("/hello", hosts: new string[] { "*.contoso.com:8080", });
|
||||||
|
|
||||||
|
var matcher = CreateMatcher(endpoint);
|
||||||
|
var httpContext = CreateContext("/hello", "www.blog.contoso.com:8080");
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await matcher.MatchAsync(httpContext);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
MatcherAssert.AssertMatch(httpContext, endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Match_HostWithWildcard_PrefixNotInSubdomain()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var endpoint = CreateEndpoint("/hello", hosts: new string[] { "*.contoso.com:8080", });
|
||||||
|
|
||||||
|
var matcher = CreateMatcher(endpoint);
|
||||||
|
var httpContext = CreateContext("/hello", "mycontoso.com:8080");
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await matcher.MatchAsync(httpContext);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
MatcherAssert.AssertNotMatch(httpContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Match_HostAndHostWithWildcard_NoSubdomain()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var endpoint = CreateEndpoint("/hello", hosts: new string[] { "contoso.com:8080", "*.contoso.com:8080", });
|
||||||
|
|
||||||
|
var matcher = CreateMatcher(endpoint);
|
||||||
|
var httpContext = CreateContext("/hello", "contoso.com:8080");
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await matcher.MatchAsync(httpContext);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
MatcherAssert.AssertMatch(httpContext, endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Match_Host_CaseInsensitive()
|
public async Task Match_Host_CaseInsensitive()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue