Additional host matching tests (#16680)

This commit is contained in:
James Newton-King 2019-10-31 13:26:42 +13:00 committed by GitHub
parent 76193ecdfd
commit 78b9b2e23e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 66 additions and 2 deletions

View File

@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.Routing.Matching
}
[Fact]
public async Task Match_HostWithWildcard()
public async Task Match_HostWithWildcard_Unicode()
{
// Arrange
var endpoint = CreateEndpoint("/hello", hosts: new string[] { "*.contoso.com:8080", });
@ -114,7 +114,23 @@ namespace Microsoft.AspNetCore.Routing.Matching
}
[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
var endpoint = CreateEndpoint("/hello", hosts: new string[] { "*.contoso.com:8080", });
@ -129,6 +145,54 @@ namespace Microsoft.AspNetCore.Routing.Matching
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]
public async Task Match_Host_CaseInsensitive()
{