Package ldaptor :: Package test :: Module test_fetchschema
[hide private]
[frames] | no frames]

Source Code for Module ldaptor.test.test_fetchschema

 1  """ 
 2  Test cases for ldaptor.protocols.ldap.fetchschema module. 
 3  """ 
 4   
 5  from twisted.trial import unittest 
 6  from ldaptor.protocols.ldap import fetchschema 
 7  from ldaptor import schema 
 8  from ldaptor.protocols import pureldap 
 9  from ldaptor.testutil import LDAPClientTestDriver 
10   
11 -class OnWire(unittest.TestCase):
12 cn = """( 2.5.4.3 NAME ( 'cn' 'commonName' ) DESC 'RFC2256: common name(s) for which the entity is known by' SUP name )""" 13 dcObject = """( 1.3.6.1.4.1.1466.344 NAME 'dcObject' DESC 'RFC2247: domain component object' SUP top AUXILIARY MUST dc )""" 14
15 - def testSimple(self):
16 client=LDAPClientTestDriver([ 17 pureldap.LDAPSearchResultEntry( 18 objectName='', 19 attributes=(('subschemaSubentry', ['cn=Subschema']), 20 ('bar', ['b', 'c']), 21 ), 22 ), 23 pureldap.LDAPSearchResultDone( 24 resultCode=0, 25 matchedDN='', 26 errorMessage='') 27 ], 28 [ 29 pureldap.LDAPSearchResultEntry( 30 objectName='cn=Subschema', 31 attributes=(('attributeTypes', [ self.cn ]), 32 ('objectClasses', [ self.dcObject ]), 33 ), 34 ), 35 pureldap.LDAPSearchResultDone( 36 resultCode=0, 37 matchedDN='', 38 errorMessage='') 39 ], 40 ) 41 42 d=fetchschema.fetch(client, 'dc=example,dc=com') 43 d.addCallback(self._cb_testSimple, client) 44 return d
45
46 - def _cb_testSimple(self, val, client):
47 client.assertSent(pureldap.LDAPSearchRequest( 48 baseObject='dc=example,dc=com', 49 scope=pureldap.LDAP_SCOPE_baseObject, 50 derefAliases=pureldap.LDAP_DEREF_neverDerefAliases, 51 sizeLimit=1, 52 timeLimit=0, 53 typesOnly=0, 54 filter=pureldap.LDAPFilter_present('objectClass'), 55 attributes=['subschemaSubentry']), 56 pureldap.LDAPSearchRequest( 57 baseObject='cn=Subschema', 58 scope=pureldap.LDAP_SCOPE_baseObject, 59 derefAliases=pureldap.LDAP_DEREF_neverDerefAliases, 60 sizeLimit=1, 61 timeLimit=0, 62 typesOnly=0, 63 filter=pureldap.LDAPFilter_present('objectClass'), 64 attributes=['attributeTypes', 'objectClasses']), 65 ) 66 self.failUnlessEqual(len(val), 2) 67 68 self.failUnlessEqual([str(x) for x in val[0]], 69 [str(schema.AttributeTypeDescription(self.cn))]) 70 self.failUnlessEqual([str(x) for x in val[1]], 71 [str(schema.ObjectClassDescription(self.dcObject))])
72