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

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:19:03 PDT 2014


Revision: 12405
          http://trac.calendarserver.org//changeset/12405
Author:   wsanchez at apple.com
Date:     2014-01-20 14:35:37 -0800 (Mon, 20 Jan 2014)
Log Message:
-----------
Pull in mutable tests.

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

Modified: twext/trunk/twext/who/ldap/_constants.py
===================================================================
--- twext/trunk/twext/who/ldap/_constants.py	2014-01-20 22:21:09 UTC (rev 12404)
+++ twext/trunk/twext/who/ldap/_constants.py	2014-01-20 22:35:37 UTC (rev 12405)
@@ -348,6 +348,7 @@
     """
     Attributes needed internally that have no standard name.
     """
+    dn = ValueConstant(u"__dn__")
     generatedUUID = ValueConstant(u"entryUUID")
     objectClass = ValueConstant(u"objectClass")
 

Modified: twext/trunk/twext/who/ldap/_service.py
===================================================================
--- twext/trunk/twext/who/ldap/_service.py	2014-01-20 22:21:09 UTC (rev 12404)
+++ twext/trunk/twext/who/ldap/_service.py	2014-01-20 22:35:37 UTC (rev 12405)
@@ -25,6 +25,7 @@
 
 import ldap
 
+from twisted.python.constants import Names, NamedConstant
 from twisted.internet.defer import succeed, inlineCallbacks, returnValue
 from twisted.internet.threads import deferToThread
 from twisted.cred.credentials import IUsernamePassword
@@ -89,13 +90,25 @@
     """
 
 
+
 class LDAPQueryError(LDAPError):
     """
     LDAP query error.
     """
 
 
+
 #
+# Data type extentions
+#
+
+class FieldName(Names):
+    dn = NamedConstant()
+    dn.description = u"distinguished name"
+
+
+
+#
 # LDAP schema descriptions
 #
 
@@ -126,6 +139,7 @@
 
 # Maps field name -> LDAP attribute names
 DEFAULT_FIELDNAME_ATTRIBUTE_MAP = MappingProxyType({
+    FieldName.dn: (LDAPAttribute.dn.value,),
     BaseFieldName.guid: (LDAPAttribute.generatedUUID.value,),
     BaseFieldName.shortNames: (LDAPAttribute.uid.value,),
     BaseFieldName.fullNames: (LDAPAttribute.cn.value,),
@@ -177,6 +191,8 @@
 
     log = Logger()
 
+    fieldName = ConstantsContainer((BaseFieldName, FieldName))
+
     recordType = ConstantsContainer((
         BaseRecordType.user, BaseRecordType.group,
     ))
@@ -418,6 +434,7 @@
 
             fields[self.fieldName.recordType] = recordType
             fields[self.fieldName.uid] = uid
+            fields[self.fieldName.dn] = dn
 
             # Make a record object from fields.
 
@@ -453,7 +470,19 @@
         return self._recordsFromQueryString(queryString)
 
 
+    # def updateRecords(self, records, create=False):
+    #     for record in records:
+    #         return fail(NotAllowedError("Record updates not allowed."))
+    #     return succeed(None)
 
+
+    # def removeRecords(self, uids):
+    #     for uid in uids:
+    #         return fail(NotAllowedError("Record removal not allowed."))
+    #     return succeed(None)
+
+
+
 class DirectoryRecord(BaseDirectoryRecord):
     """
     LDAP directory record.

Modified: twext/trunk/twext/who/ldap/test/test_service.py
===================================================================
--- twext/trunk/twext/who/ldap/test/test_service.py	2014-01-20 22:21:09 UTC (rev 12404)
+++ twext/trunk/twext/who/ldap/test/test_service.py	2014-01-20 22:35:37 UTC (rev 12405)
@@ -51,6 +51,7 @@
     as BaseDirectoryServiceConvenienceTestMixIn,
     DirectoryServiceRealmTestMixIn,
     DirectoryServiceQueryTestMixIn as BaseDirectoryServiceQueryTestMixIn,
+    DirectoryServiceMutableTestMixIn as BaseDirectoryServiceMutableTestMixIn,
 )
 
 
@@ -129,19 +130,16 @@
 class DirectoryServiceQueryTestMixIn(BaseDirectoryServiceQueryTestMixIn):
     def test_queryNot(self):
         return BaseDirectoryServiceQueryTestMixIn.test_queryNot(self)
-
     test_queryNot.todo = "?"
 
 
     def test_queryNotNoIndex(self):
         return BaseDirectoryServiceQueryTestMixIn.test_queryNotNoIndex(self)
-
     test_queryNotNoIndex.todo = "?"
 
 
     def test_queryStartsWithNot(self):
         return BaseDirectoryServiceQueryTestMixIn.test_queryStartsWithNot(self)
-
     test_queryStartsWithNot.todo = "?"
 
 
@@ -150,7 +148,6 @@
             BaseDirectoryServiceQueryTestMixIn
             .test_queryStartsWithNotAny(self)
         )
-
     test_queryStartsWithNotAny.todo = "?"
 
 
@@ -159,13 +156,11 @@
             BaseDirectoryServiceQueryTestMixIn
             .test_queryStartsWithNotNoIndex(self)
         )
-
     test_queryStartsWithNotNoIndex.todo = "?"
 
 
     def test_queryContainsNot(self):
         return BaseDirectoryServiceQueryTestMixIn.test_queryContainsNot(self)
-
     test_queryContainsNot.todo = "?"
 
 
@@ -174,11 +169,42 @@
             BaseDirectoryServiceQueryTestMixIn
             .test_queryContainsNotNoIndex(self)
         )
-
     test_queryContainsNotNoIndex.todo = "?"
 
 
 
+class DirectoryServiceMutableTestMixIn(BaseDirectoryServiceMutableTestMixIn):
+    def test_removeRecord(self):
+        return BaseDirectoryServiceMutableTestMixIn.test_removeRecord(self)
+    test_removeRecord.todo = "?"
+
+
+    def test_removeRecordNoExist(self):
+        return (
+            BaseDirectoryServiceMutableTestMixIn.test_removeRecordNoExist(self)
+        )
+    test_removeRecordNoExist.todo = "?"
+
+
+    def test_addRecord(self):
+        return BaseDirectoryServiceMutableTestMixIn.test_addRecord(self)
+    test_addRecord.todo = "?"
+
+
+    def test_updateRecord(self):
+        return BaseDirectoryServiceMutableTestMixIn.test_updateRecord(self)
+    test_updateRecord.todo = "?"
+
+
+    def test_addRecordNoCreate(self):
+        raise NotImplementedError()
+        return (
+            BaseDirectoryServiceMutableTestMixIn.test_addRecordNoCreate(self)
+        )
+    test_addRecordNoCreate.todo = "?"
+
+
+
 class DirectoryServiceConnectionTestMixIn(object):
     @inlineCallbacks
     def test_connect_defaults(self):
@@ -287,6 +313,7 @@
     DirectoryServiceConvenienceTestMixIn,
     DirectoryServiceRealmTestMixIn,
     DirectoryServiceQueryTestMixIn,
+    DirectoryServiceMutableTestMixIn,
     DirectoryServiceConnectionTestMixIn,
     test_directory.BaseDirectoryServiceTest,
     unittest.TestCase,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/3839bbce/attachment.html>


More information about the calendarserver-changes mailing list