[CalendarServer-changes] [12311] twext/trunk/twext/who/ldap

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:24:04 PDT 2014


Revision: 12311
          http://trac.calendarserver.org//changeset/12311
Author:   wsanchez at apple.com
Date:     2014-01-11 13:56:19 -0800 (Sat, 11 Jan 2014)
Log Message:
-----------
Test called list

Modified Paths:
--------------
    twext/trunk/twext/who/ldap/_service.py
    twext/trunk/twext/who/ldap/test/test_service.py

Modified: twext/trunk/twext/who/ldap/_service.py
===================================================================
--- twext/trunk/twext/who/ldap/_service.py	2014-01-11 21:31:13 UTC (rev 12310)
+++ twext/trunk/twext/who/ldap/_service.py	2014-01-11 21:56:19 UTC (rev 12311)
@@ -136,7 +136,7 @@
         else:
             self._tlsCACertificateDirectory = tlsCACertificateDirectory.path
 
-        self._useTLS = useTLS,
+        self._useTLS = useTLS
 
         if debug:
             self._debug = 255
@@ -176,6 +176,7 @@
                     connection.set_option(option, value)
 
             if self._useTLS:
+                self.log.info("Starting TLS for {source.url}")
                 yield deferToThread(connection.start_tls_s)
 
             if self.credentials is not None:
@@ -191,7 +192,7 @@
                             credentials=self.credentials
                         )
                     except ldap.INVALID_CREDENTIALS as e:
-                        self.log.info(
+                        self.log.error(
                             "Unable to bind to LDAP as {credentials.username}",
                             credentials=self.credentials
                         )

Modified: twext/trunk/twext/who/ldap/test/test_service.py
===================================================================
--- twext/trunk/twext/who/ldap/test/test_service.py	2014-01-11 21:31:13 UTC (rev 12310)
+++ twext/trunk/twext/who/ldap/test/test_service.py	2014-01-11 21:56:19 UTC (rev 12311)
@@ -91,16 +91,15 @@
         service = self.service()
         connection = yield service._connect()
 
+        self.assertEquals(connection.methods_called(), ["initialize"])
+
         for option in (
             ldap.OPT_TIMEOUT,
             ldap.OPT_X_TLS_CACERTFILE,
             ldap.OPT_X_TLS_CACERTDIR,
             ldap.OPT_DEBUG_LEVEL,
         ):
-            self.assertRaises(
-                KeyError,
-                connection.get_option, option
-            )
+            self.assertRaises(KeyError, connection.get_option, option)
 
         self.assertFalse(connection.tls_enabled)
 
@@ -119,6 +118,17 @@
         )
         connection = yield service._connect()
 
+        self.assertEquals(
+            connection.methods_called(),
+            sum(
+                (
+                    ["initialize"],
+                    ["set_option"] * 4,
+                    ["start_tls_s"],
+                ), []
+            )
+        )
+
         opt = lambda k: connection.get_option(k)
 
         self.assertEquals(opt(ldap.OPT_TIMEOUT), 18)
@@ -129,6 +139,5 @@
         self.assertTrue(connection.tls_enabled)
 
 
-
 mockDirectoryData = dict(
 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/935f3041/attachment.html>


More information about the calendarserver-changes mailing list