Enable more LDAP TLS tests on linux (#54377)
authoriinuwa <isaiah.inuwa@moody.edu>
Thu, 1 Jul 2021 09:59:59 +0000 (04:59 -0500)
committerGitHub <noreply@github.com>
Thu, 1 Jul 2021 09:59:59 +0000 (11:59 +0200)
* Remove SupportedOsPlatform attribute for LDAP TLS

* Throw ObjectDisposedException when setting LDAP TLS settings on Linux.

src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Linux.cs
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Windows.cs
src/libraries/System.DirectoryServices.Protocols/tests/LdapSessionOptionsTests.cs

index b7bcca2..dbedfdb 100644 (file)
@@ -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
         {
index c587f42..14b8878 100644 (file)
@@ -9,7 +9,6 @@ namespace System.DirectoryServices.Protocols
     {
         private static void PALCertFreeCRLContext(IntPtr certPtr) => Interop.Ldap.CertFreeCRLContext(certPtr);
 
-        [SupportedOSPlatform("windows")]
         public bool SecureSocketLayer
         {
             get
index ef1436b..77cdf83 100644 (file)
@@ -64,7 +64,6 @@ namespace System.DirectoryServices.Protocols.Tests
         }
 
         [Fact]
-        [PlatformSpecific(TestPlatforms.Windows)]
         public void SecureSocketLayer_GetSetWhenDisposed_ThrowsObjectDisposedException()
         {
             var connection = new LdapConnection("server");