def test_combo(self): u = MyLDAPUrl("ldap://127.0.0.1:1234/dc=example,dc=com" + "?attr1,attr2,attr3" + "?sub" + "?" + quote("(objectClass=*)") + "?bindname=" + quote("cn=d,c=au") + ",X-BINDPW=" + quote("???") + ",trace=8") self.assertEqual(u.urlscheme, "ldap") self.assertEqual(u.hostport, "127.0.0.1:1234") self.assertEqual(u.dn, "dc=example,dc=com") self.assertEqual(u.attrs, ["attr1", "attr2", "attr3"]) self.assertEqual(u.scope, ldap.SCOPE_SUBTREE) self.assertEqual(u.filterstr, "(objectClass=*)") self.assertEqual(len(u.extensions), 3) self.assertEqual(u.who, "cn=d,c=au") self.assertEqual(u.cred, "???") self.assertEqual(u.trace_level, "8")
def unparse(self): if self.exvalue is None: return '%s%s' % ('!'*(self.critical>0),self.extype) else: return '%s%s=%s' % ( '!'*(self.critical>0), self.extype,quote(self.exvalue or '') )
def test_combo(self): u = MyLDAPUrl("ldap://127.0.0.1:1234/dc=example,dc=com" + "?attr1,attr2,attr3" + "?sub" + "?" + quote("(objectClass=*)") + "?bindname=" + quote("cn=d,c=au") + ",X-BINDPW=" + quote("???") + ",trace=8" ) self.assertEqual(u.urlscheme, "ldap") self.assertEqual(u.hostport, "127.0.0.1:1234") self.assertEqual(u.dn, "dc=example,dc=com") self.assertEqual(u.attrs, ["attr1","attr2","attr3"]) self.assertEqual(u.scope, ldap.SCOPE_SUBTREE) self.assertEqual(u.filterstr, "(objectClass=*)") self.assertEqual(len(u.extensions), 3) self.assertEqual(u.who, "cn=d,c=au") self.assertEqual(u.cred, "???") self.assertEqual(u.trace_level, "8")
def ldapUrlEscape(s): """Returns URL encoding of string s""" return quote(s).replace(',','%2C').replace('/','%2F')
def ldapUrlEscape(s): """Returns URL encoding of string s""" return quote(s).replace(",", "%2C").replace("/", "%2F")
def unparse(self): if self.exvalue is None: return "%s%s" % ("!" * (self.critical > 0), self.extype) else: return "%s%s=%s" % ("!" * (self.critical > 0), self.extype, quote(self.exvalue or ""))