Skip to content

Commit ab62e1c

Browse files
authored
Fix Server_RegisterUnavailablePrefix_ThrowsActionableHttpSysException #26156 (#26203)
1 parent ad34133 commit ab62e1c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Servers/HttpSys/test/FunctionalTests/Listener/ServerTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,18 @@ public async Task Server_SetRejectionVerbosityLevel_Success()
126126
}
127127

128128
[ConditionalFact]
129-
[QuarantinedTest("https://github.com/dotnet/aspnetcore/pull/20718#issuecomment-618758634")]
130129
public void Server_RegisterUnavailablePrefix_ThrowsActionableHttpSysException()
131130
{
131+
using var server1 = Utilities.CreateHttpServer(out var address1);
132+
132133
var options = new HttpSysOptions();
133-
options.UrlPrefixes.Add(UrlPrefix.Create("http", "example.org", "8080", ""));
134-
var listener = new HttpSysListener(options, new LoggerFactory());
134+
options.UrlPrefixes.Add(address1);
135+
using var listener = new HttpSysListener(options, new LoggerFactory());
135136

136137
var exception = Assert.Throws<HttpSysException>(() => listener.Start());
137138

138-
Assert.Equal((int)UnsafeNclNativeMethods.ErrorCodes.ERROR_ACCESS_DENIED, exception.ErrorCode);
139-
Assert.Contains($@"netsh http add urlacl url=http://example.org:8080/ user={Environment.UserDomainName}\{Environment.UserName}", exception.Message);
139+
Assert.Equal((int)UnsafeNclNativeMethods.ErrorCodes.ERROR_ALREADY_EXISTS, exception.ErrorCode);
140+
Assert.Contains($"The prefix '{address1}' is already registered.", exception.Message);
140141
}
141142

142143
[ConditionalFact]

0 commit comments

Comments
 (0)