Fix Server_RegisterUnavailablePrefix_ThrowsActionableHttpSysException #26156 (#26203) (#29368)

This commit is contained in:
Chris Ross 2021-02-09 18:42:22 -08:00 committed by GitHub
parent 6860a706ef
commit 9ab6dbd593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -126,17 +126,18 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
}
[ConditionalFact]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/pull/20718#issuecomment-618758634")]
public void Server_RegisterUnavailablePrefix_ThrowsActionableHttpSysException()
{
using var server1 = Utilities.CreateHttpServer(out var address1);
var options = new HttpSysOptions();
options.UrlPrefixes.Add(UrlPrefix.Create("http", "example.org", "8080", ""));
var listener = new HttpSysListener(options, new LoggerFactory());
options.UrlPrefixes.Add(address1);
using var listener = new HttpSysListener(options, new LoggerFactory());
var exception = Assert.Throws<HttpSysException>(() => listener.Start());
Assert.Equal((int)UnsafeNclNativeMethods.ErrorCodes.ERROR_ACCESS_DENIED, exception.ErrorCode);
Assert.Contains($@"netsh http add urlacl url=http://example.org:8080/ user={Environment.UserDomainName}\{Environment.UserName}", exception.Message);
Assert.Equal((int)UnsafeNclNativeMethods.ErrorCodes.ERROR_ALREADY_EXISTS, exception.ErrorCode);
Assert.Contains($"The prefix '{address1}' is already registered.", exception.Message);
}
[ConditionalFact]