Skip to content
Permalink
Browse files

Pull in mutable tests.

  • Loading branch information
wsanchez committed Jan 20, 2014
1 parent 4842504 commit c8454d348bacf0e377a7ecf0165f9e1b3d46267d
Showing with 64 additions and 7 deletions.
  1. +1 −0 twext/who/ldap/_constants.py
  2. +29 −0 twext/who/ldap/_service.py
  3. +34 −7 twext/who/ldap/test/test_service.py
@@ -348,6 +348,7 @@ class WhoAttribute(Values):
"""
Attributes needed internally that have no standard name.
"""
dn = ValueConstant(u"__dn__")
generatedUUID = ValueConstant(u"entryUUID")
objectClass = ValueConstant(u"objectClass")

@@ -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,12 +90,24 @@ class LDAPBindAuthError(LDAPConnectionError):
"""



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 @@ def __init__(self, relativeDN, attributes):

# 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 @@ class DirectoryService(BaseDirectoryService):

log = Logger()

fieldName = ConstantsContainer((BaseFieldName, FieldName))

recordType = ConstantsContainer((
BaseRecordType.user, BaseRecordType.group,
))
@@ -418,6 +434,7 @@ def _recordsFromQueryString(self, queryString):

fields[self.fieldName.recordType] = recordType
fields[self.fieldName.uid] = uid
fields[self.fieldName.dn] = dn

# Make a record object from fields.

@@ -453,6 +470,18 @@ def recordsFromCompoundExpression(self, expression, records=None):
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):
"""
@@ -51,6 +51,7 @@
as BaseDirectoryServiceConvenienceTestMixIn,
DirectoryServiceRealmTestMixIn,
DirectoryServiceQueryTestMixIn as BaseDirectoryServiceQueryTestMixIn,
DirectoryServiceMutableTestMixIn as BaseDirectoryServiceMutableTestMixIn,
)


@@ -129,19 +130,16 @@ def test_recordsWithRecordType_unknown(self):
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 @@ def test_queryStartsWithNotAny(self):
BaseDirectoryServiceQueryTestMixIn
.test_queryStartsWithNotAny(self)
)

test_queryStartsWithNotAny.todo = "?"


@@ -159,13 +156,11 @@ def test_queryStartsWithNotNoIndex(self):
BaseDirectoryServiceQueryTestMixIn
.test_queryStartsWithNotNoIndex(self)
)

test_queryStartsWithNotNoIndex.todo = "?"


def test_queryContainsNot(self):
return BaseDirectoryServiceQueryTestMixIn.test_queryContainsNot(self)

test_queryContainsNot.todo = "?"


@@ -174,11 +169,42 @@ def test_queryContainsNotNoIndex(self):
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 @@ class DirectoryServiceTest(
DirectoryServiceConvenienceTestMixIn,
DirectoryServiceRealmTestMixIn,
DirectoryServiceQueryTestMixIn,
DirectoryServiceMutableTestMixIn,
DirectoryServiceConnectionTestMixIn,
test_directory.BaseDirectoryServiceTest,
unittest.TestCase,

0 comments on commit c8454d3

Please sign in to comment.
You can’t perform that action at this time.