Skip to content

Commit 88dbfaa

Browse files
Set certificate in some Kestrel tests to avoid global machine state (#21516)
1 parent 32b2894 commit 88dbfaa

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Servers/Kestrel/test/BindTests/AddressRegistrationTests.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@ public async Task RegisterAddresses_IPv6_Success(string addressInput, string[] t
129129
}
130130

131131
[ConditionalTheory]
132-
[MemberData(nameof(AddressRegistrationDataIPv6Port5000Default))]
132+
[MemberData(nameof(AddressRegistrationDataIPv6Port5000And5001Default))]
133133
[IPv6SupportedCondition]
134134
[QuarantinedTest("https://github.com/dotnet/aspnetcore-internal/issues/2711")]
135-
public async Task RegisterAddresses_IPv6Port5000Default_Success(string addressInput, string[] testUrls)
135+
public async Task RegisterAddresses_IPv6Port5000And5001Default_Success(string addressInput, string[] testUrls)
136136
{
137-
if (!CanBindToEndpoint(IPAddress.Loopback, 5000) || !CanBindToEndpoint(IPAddress.IPv6Loopback, 5000))
137+
if ((!CanBindToEndpoint(IPAddress.Loopback, 5000) || !CanBindToEndpoint(IPAddress.IPv6Loopback, 5000)) &&
138+
(!CanBindToEndpoint(IPAddress.Loopback, 5001) || !CanBindToEndpoint(IPAddress.IPv6Loopback, 5001)))
138139
{
139140
return;
140141
}
@@ -183,7 +184,13 @@ public async Task RegisterAddresses_IPv6LocalhostStaticPort_Success()
183184
private async Task RegisterAddresses_Success(string addressInput, string[] testUrls, int testPort = 0)
184185
{
185186
var hostBuilder = TransportSelector.GetWebHostBuilder()
186-
.UseKestrel()
187+
.UseKestrel(serverOptions =>
188+
{
189+
serverOptions.ConfigureHttpsDefaults(httpsOptions =>
190+
{
191+
httpsOptions.ServerCertificate = TestResources.GetTestCertificate();
192+
});
193+
})
187194
.ConfigureServices(AddTestLogging)
188195
.UseUrls(addressInput)
189196
.Configure(ConfigureEchoAddress);
@@ -1038,11 +1045,11 @@ public static TheoryData<string, string[]> AddressRegistrationDataIPv6
10381045
}
10391046
}
10401047

1041-
public static TheoryData<string, string[]> AddressRegistrationDataIPv6Port5000Default =>
1048+
public static TheoryData<string, string[]> AddressRegistrationDataIPv6Port5000And5001Default =>
10421049
new TheoryData<string, string[]>
10431050
{
1044-
{ null, new[] { "http://127.0.0.1:5000/", "http://[::1]:5000/" } },
1045-
{ string.Empty, new[] { "http://127.0.0.1:5000/", "http://[::1]:5000/" } }
1051+
{ null, new[] { "http://127.0.0.1:5000/", "http://[::1]:5000/", "https://127.0.0.1:5001/", "https://[::1]:5001/" } },
1052+
{ string.Empty, new[] { "http://127.0.0.1:5000/", "http://[::1]:5000/", "https://127.0.0.1:5001/", "https://[::1]:5001/" } }
10461053
};
10471054

10481055
public static TheoryData<string, string[]> AddressRegistrationDataIPv6Port80 =>

0 commit comments

Comments
 (0)