def gettingDNRaises(self, dn, exceptionClass): d = ldiftree.get(self.tree, dn) def eb(fail): fail.trap(exceptionClass) d.addCallbacks(testutil.mustRaise, eb) return d
def testSimpleRead(self): want = BaseLDAPEntry(dn='cn=foo,dc=example,dc=com', attributes={ 'objectClass': ['top'], 'cn': ['foo'], }) d = ldiftree.get(self.tree, want.dn) d.addCallback(self.failUnlessEqual, want) return d
def testTreeBranches(self): want = BaseLDAPEntry(dn='cn=sales-thingie,ou=Sales,dc=example,dc=com', attributes={ 'objectClass': ['top'], 'cn': ['sales-thingie'], }) d = ldiftree.get(self.tree, want.dn) d.addCallback(self.failUnlessEqual, want) return d
def testTreeBranches(self): want = BaseLDAPEntry( dn=b"cn=sales-thingie,ou=Sales,dc=example,dc=com", attributes={ b"objectClass": [b"top"], b"cn": [b"sales-thingie"], }, ) d = ldiftree.get(self.tree, want.dn) d.addCallback(self.failUnlessEqual, want) return d
def testSimpleRead(self): want = BaseLDAPEntry( dn=b"cn=foo,dc=example,dc=com", attributes={ b"objectClass": [b"top"], b"cn": [b"foo"], }, ) d = ldiftree.get(self.tree, want.dn) d.addCallback(self.failUnlessEqual, want) return d
def testNoAccess(self): os.chmod(os.path.join(self.tree, 'dc=com.dir', 'dc=example.dir', 'cn=foo.ldif'), 0) d = ldiftree.get(self.tree, 'cn=foo,dc=example,dc=com') def eb(fail): fail.trap(IOError) self.assertEquals(fail.value.errno, errno.EACCES) d.addCallbacks(testutil.mustRaise, eb) return d
def testNoAccess(self): self.chmod( os.path.join(self.tree, "dc=com.dir", "dc=example.dir", "cn=foo.ldif"), 0 ) d = ldiftree.get(self.tree, "cn=foo,dc=example,dc=com") def eb(fail): fail.trap(IOError) self.assertEqual(fail.value.errno, errno.EACCES) d.addCallbacks(testutil.mustRaise, eb) return d