From 784ddffced6984719f7b76e3f2750990b1087eaa Mon Sep 17 00:00:00 2001 From: iinuwa Date: Thu, 1 Jul 2021 04:59:59 -0500 Subject: [PATCH] Enable more LDAP TLS tests on linux (#54377) * Remove SupportedOsPlatform attribute for LDAP TLS * Throw ObjectDisposedException when setting LDAP TLS settings on Linux. --- .../Protocols/ldap/LdapSessionOptions.Linux.cs | 16 +++++++++++++++- .../Protocols/ldap/LdapSessionOptions.Windows.cs | 1 - .../tests/LdapSessionOptionsTests.cs | 1 - 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Linux.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Linux.cs index b7bcca2..dbedfdb 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Linux.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Linux.cs @@ -9,7 +9,21 @@ namespace System.DirectoryServices.Protocols { private static void PALCertFreeCRLContext(IntPtr certPtr) { /* No op */ } - public bool SecureSocketLayer { get; set; } + private bool _secureSocketLayer; + + public bool SecureSocketLayer + { + get + { + if (_connection._disposed) throw new ObjectDisposedException(GetType().Name); + return _secureSocketLayer; + } + set + { + if (_connection._disposed) throw new ObjectDisposedException(GetType().Name); + _secureSocketLayer = value; + } + } public int ProtocolVersion { diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Windows.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Windows.cs index c587f42..14b8878 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Windows.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Windows.cs @@ -9,7 +9,6 @@ namespace System.DirectoryServices.Protocols { private static void PALCertFreeCRLContext(IntPtr certPtr) => Interop.Ldap.CertFreeCRLContext(certPtr); - [SupportedOSPlatform("windows")] public bool SecureSocketLayer { get diff --git a/src/libraries/System.DirectoryServices.Protocols/tests/LdapSessionOptionsTests.cs b/src/libraries/System.DirectoryServices.Protocols/tests/LdapSessionOptionsTests.cs index ef1436b..77cdf83 100644 --- a/src/libraries/System.DirectoryServices.Protocols/tests/LdapSessionOptionsTests.cs +++ b/src/libraries/System.DirectoryServices.Protocols/tests/LdapSessionOptionsTests.cs @@ -64,7 +64,6 @@ namespace System.DirectoryServices.Protocols.Tests } [Fact] - [PlatformSpecific(TestPlatforms.Windows)] public void SecureSocketLayer_GetSetWhenDisposed_ThrowsObjectDisposedException() { var connection = new LdapConnection("server"); -- 2.7.4