Skip to content

Commit 9a5ef96

Browse files
authored
add SupportsTls11 and SupportsTls12 to PlatformDetection avoid OS versions in tests (#39482)
* add SupportsTls11 and SupportsTls12 to avoid OS versions in tests * feedback from review * fix condition
1 parent f4e9146 commit 9a5ef96

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

+3
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ public static bool IsNonZeroLowerBoundArraySupported
125125

126126
public static bool SupportsClientAlpn => SupportsAlpn || IsOSX || IsiOS || IstvOS;
127127

128+
// TLS 1.1 and 1.2 can work on Windows7 but it is not enabled by default.
129+
public static bool SupportsTls11 => !IsWindows7 && !IsDebian10;
130+
public static bool SupportsTls12 => !IsWindows7;
128131
// OpenSSL 1.1.1 and above.
129132
public static bool SupportsTls13 => GetTls13Support();
130133

src/libraries/System.Net.Security/tests/FunctionalTests/ServerAsyncAuthenticateTest.cs

+14-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public class ServerAsyncAuthenticateTest : IDisposable
2323
private readonly ITestOutputHelper _logVerbose;
2424
private readonly X509Certificate2 _serverCertificate;
2525

26-
public static bool IsNotWindows7 => !PlatformDetection.IsWindows7;
27-
2826
public ServerAsyncAuthenticateTest(ITestOutputHelper output)
2927
{
3028
_log = output;
@@ -99,9 +97,8 @@ public async Task ServerAsyncAuthenticate_SimpleSniOptions_Success()
9997
}
10098
}
10199

102-
[ConditionalTheory(nameof(IsNotWindows7))]
103-
[InlineData(SslProtocols.Tls11)]
104-
[InlineData(SslProtocols.Tls12)]
100+
[Theory]
101+
[MemberData(nameof(SupportedProtocolData))]
105102
public async Task ServerAsyncAuthenticate_SniSetVersion_Success(SslProtocols version)
106103
{
107104
var serverOptions = new SslServerAuthenticationOptions() { ServerCertificate = _serverCertificate, EnabledSslProtocols = version };
@@ -247,6 +244,18 @@ public static IEnumerable<object[]> ProtocolMismatchData()
247244
yield return new object[] { SslProtocols.Tls12, SslProtocols.Tls11, typeof(AuthenticationException) };
248245
}
249246

247+
public static IEnumerable<Object[]> SupportedProtocolData()
248+
{
249+
if (PlatformDetection.SupportsTls11)
250+
{
251+
yield return new object[] { SslProtocols.Tls11 };
252+
}
253+
254+
if (PlatformDetection.SupportsTls12)
255+
{
256+
yield return new object[] { SslProtocols.Tls12 };
257+
}
258+
}
250259
#region Helpers
251260

252261
private async Task ServerAsyncSslHelper(

0 commit comments

Comments
 (0)