Add SetIsOriginAllowedToAllowWildcardSubdomains_DoesNotAllowRootDomain test (#23001)

This test makes it clear root domains are not included in CORS subdomain wildcards
This commit is contained in:
Ken Dale 2020-06-17 09:22:20 -04:00 committed by GitHub
parent f6fee9b4b8
commit 28ed208022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -205,6 +205,20 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure
Assert.True(corsPolicy.IsOriginAllowed("http://test.example.com"));
}
[Fact]
public void SetIsOriginAllowedToAllowWildcardSubdomains_DoesNotAllowRootDomain()
{
// Arrange
var builder = new CorsPolicyBuilder("http://*.example.com");
// Act
builder.SetIsOriginAllowedToAllowWildcardSubdomains();
// Assert
var corsPolicy = builder.Build();
Assert.False(corsPolicy.IsOriginAllowed("http://example.com"));
}
[Fact]
public void WithMethods_AddsMethods()
{