Skip to content

Commit

Permalink
add SupportsTls11 and SupportsTls12 to PlatformDetection avoid OS ver…
Browse files Browse the repository at this point in the history
…sions in tests (dotnet#39482)

* add SupportsTls11 and SupportsTls12 to avoid OS versions in tests

* feedback from review

* fix condition
  • Loading branch information
wfurt authored Jul 20, 2020
1 parent f4e9146 commit 9a5ef96
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public static bool IsNonZeroLowerBoundArraySupported

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public class ServerAsyncAuthenticateTest : IDisposable
private readonly ITestOutputHelper _logVerbose;
private readonly X509Certificate2 _serverCertificate;

public static bool IsNotWindows7 => !PlatformDetection.IsWindows7;

public ServerAsyncAuthenticateTest(ITestOutputHelper output)
{
_log = output;
Expand Down Expand Up @@ -99,9 +97,8 @@ public async Task ServerAsyncAuthenticate_SimpleSniOptions_Success()
}
}

[ConditionalTheory(nameof(IsNotWindows7))]
[InlineData(SslProtocols.Tls11)]
[InlineData(SslProtocols.Tls12)]
[Theory]
[MemberData(nameof(SupportedProtocolData))]
public async Task ServerAsyncAuthenticate_SniSetVersion_Success(SslProtocols version)
{
var serverOptions = new SslServerAuthenticationOptions() { ServerCertificate = _serverCertificate, EnabledSslProtocols = version };
Expand Down Expand Up @@ -247,6 +244,18 @@ public static IEnumerable<object[]> ProtocolMismatchData()
yield return new object[] { SslProtocols.Tls12, SslProtocols.Tls11, typeof(AuthenticationException) };
}

public static IEnumerable<Object[]> SupportedProtocolData()
{
if (PlatformDetection.SupportsTls11)
{
yield return new object[] { SslProtocols.Tls11 };
}

if (PlatformDetection.SupportsTls12)
{
yield return new object[] { SslProtocols.Tls12 };
}
}
#region Helpers

private async Task ServerAsyncSslHelper(
Expand Down

0 comments on commit 9a5ef96

Please sign in to comment.