From 6efb7ff98191c5f62f66be33591f674b682986ac Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Dec 2008 07:34:27 +0100 Subject: Fix various Python-related bugs. --- source4/lib/ldb/pyldb.c | 21 +++++-- source4/lib/ldb/pyldb.h | 4 +- source4/lib/ldb/tests/python/ldap.py | 114 +++++++++++++++++------------------ 3 files changed, 75 insertions(+), 64 deletions(-) (limited to 'source4/lib/ldb') diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index c30953859a..dfabed54e3 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -1275,9 +1275,9 @@ static PyObject *py_ldb_msg_element_iter(PyLdbMessageElementObject *self) return PyObject_GetIter(ldb_msg_element_to_set(NULL, PyLdbMessageElement_AsMessageElement(self))); } -PyObject *PyLdbMessageElement_FromMessageElement(struct ldb_message_element *el) +PyObject *PyLdbMessageElement_FromMessageElement(struct ldb_message_element *el, TALLOC_CTX *mem_ctx) { - return py_talloc_import(&PyLdbMessageElement, el); + return py_talloc_import_ex(&PyLdbMessageElement, mem_ctx, el); } static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) @@ -1338,11 +1338,22 @@ static PyObject *py_ldb_msg_element_repr(PyLdbMessageElementObject *self) return ret; } +static PyObject *py_ldb_msg_element_str(PyLdbMessageElementObject *self) +{ + struct ldb_message_element *el = PyLdbMessageElement_AsMessageElement(self); + + if (el->num_values == 1) + return PyString_FromStringAndSize((char *)el->values[0].data, el->values[0].length); + else + return Py_None; +} + PyTypeObject PyLdbMessageElement = { .tp_name = "MessageElement", .tp_basicsize = sizeof(PyLdbMessageElementObject), .tp_dealloc = py_talloc_dealloc, .tp_repr = (reprfunc)py_ldb_msg_element_repr, + .tp_str = (reprfunc)py_ldb_msg_element_str, .tp_methods = py_ldb_msg_element_methods, .tp_compare = (cmpfunc)py_ldb_msg_element_cmp, .tp_iter = (getiterfunc)py_ldb_msg_element_iter, @@ -1388,7 +1399,7 @@ static PyObject *py_ldb_msg_getitem_helper(PyLdbMessageObject *self, PyObject *p if (el == NULL) { return NULL; } - return (PyObject *)PyLdbMessageElement_FromMessageElement(el); + return (PyObject *)PyLdbMessageElement_FromMessageElement(el, self->talloc_ctx); } static PyObject *py_ldb_msg_getitem(PyLdbMessageObject *self, PyObject *py_name) @@ -1424,7 +1435,7 @@ static PyObject *py_ldb_msg_items(PyLdbMessageObject *self) j++; } for (i = 0; i < msg->num_elements; i++, j++) { - PyList_SetItem(l, j, Py_BuildValue("(sO)", msg->elements[i].name, PyLdbMessageElement_FromMessageElement(&msg->elements[i]))); + PyList_SetItem(l, j, Py_BuildValue("(sO)", msg->elements[i].name, PyLdbMessageElement_FromMessageElement(&msg->elements[i], self->talloc_ctx))); } return l; } @@ -1956,7 +1967,7 @@ void initldb(void) PyModule_AddObject(m, "ERR_OBJECT_CLASS_VIOLATION", PyInt_FromLong(LDB_ERR_OBJECT_CLASS_VIOLATION)); PyModule_AddObject(m, "ERR_NOT_ALLOWED_ON_NON_LEAF", PyInt_FromLong(LDB_ERR_NOT_ALLOWED_ON_NON_LEAF)); PyModule_AddObject(m, "ERR_NOT_ALLOWED_ON_RDN", PyInt_FromLong(LDB_ERR_NOT_ALLOWED_ON_RDN)); - PyModule_AddObject(m, "ERR_ENTYR_ALREADY_EXISTS", PyInt_FromLong(LDB_ERR_ENTRY_ALREADY_EXISTS)); + PyModule_AddObject(m, "ERR_ENTRY_ALREADY_EXISTS", PyInt_FromLong(LDB_ERR_ENTRY_ALREADY_EXISTS)); PyModule_AddObject(m, "ERR_OBJECT_CLASS_MODS_PROHIBITED", PyInt_FromLong(LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED)); PyModule_AddObject(m, "ERR_AFFECTS_MULTIPLE_DSAS", PyInt_FromLong(LDB_ERR_AFFECTS_MULTIPLE_DSAS)); diff --git a/source4/lib/ldb/pyldb.h b/source4/lib/ldb/pyldb.h index 4ffc21325a..b55bb68401 100644 --- a/source4/lib/ldb/pyldb.h +++ b/source4/lib/ldb/pyldb.h @@ -61,8 +61,8 @@ PyObject *PyLdbModule_FromModule(struct ldb_module *mod); typedef py_talloc_Object PyLdbMessageElementObject; PyAPI_DATA(PyTypeObject) PyLdbMessageElement; struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx, PyObject *obj, int flags, const char *name); -PyObject *PyLdbMessageElement_FromMessageElement(struct ldb_message_element *); -#define PyLdbMessageElement_AsMessageElement(pyobj) py_talloc_get_type(pyobj, struct ldb_message_element) +PyObject *PyLdbMessageElement_FromMessageElement(struct ldb_message_element *, TALLOC_CTX *mem_ctx); +#define PyLdbMessageElement_AsMessageElement(pyobj) ((struct ldb_message_element *)py_talloc_get_ptr(pyobj)) #define PyLdbMessageElement_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessageElement) typedef py_talloc_Object PyLdbTreeObject; diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py index 821bd04b5c..f9006dbd63 100755 --- a/source4/lib/ldb/tests/python/ldap.py +++ b/source4/lib/ldb/tests/python/ldap.py @@ -14,9 +14,9 @@ import samba.getopt as options from samba.auth import system_session from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError -from ldb import LDB_ERR_NO_SUCH_OBJECT, LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS -from ldb import LDB_ERR_ENTRY_ALREADY_EXISTS, LDB_ERR_UNWILLING_TO_PERFORM -from ldb import LDB_ERR_NOT_ALLOWED_ON_NON_LEAF, LDB_ERR_OTHER, LDB_ERR_INVALID_DN_SYNTAX +from ldb import ERR_NO_SUCH_OBJECT, ERR_ATTRIBUTE_OR_VALUE_EXISTS +from ldb import ERR_ENTRY_ALREADY_EXISTS, ERR_UNWILLING_TO_PERFORM +from ldb import ERR_NOT_ALLOWED_ON_NON_LEAF, ERR_OTHER, ERR_INVALID_DN_SYNTAX from samba import Ldb from subunit import SubunitTestRunner from samba import param @@ -45,7 +45,7 @@ class BasicTests(unittest.TestCase): try: ldb.delete(dn) except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT) + self.assertEquals(num, ERR_NO_SUCH_OBJECT) def find_basedn(self, ldb): res = ldb.search(base="", expression="", scope=SCOPE_BASE, @@ -88,7 +88,7 @@ class BasicTests(unittest.TestCase): "member": "cn=ldaptestuser,cn=useRs," + self.base_dn}) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT) + self.assertEquals(num, ERR_NO_SUCH_OBJECT) def test_all(self): """Basic tests""" @@ -129,7 +129,7 @@ class BasicTests(unittest.TestCase): }) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_INVALID_DN_SYNTAX) + self.assertEquals(num, ERR_INVALID_DN_SYNTAX) self.delete_force(self.ldb, "cn=ldaptestcomputer3,cn=computers," + self.base_dn) try: @@ -140,7 +140,7 @@ class BasicTests(unittest.TestCase): }) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_UNWILLING_TO_PERFORM) + self.assertEquals(num, ERR_UNWILLING_TO_PERFORM) self.delete_force(self.ldb, "cn=ldaptestcomputer3,cn=computers," + self.base_dn) try: @@ -151,7 +151,7 @@ class BasicTests(unittest.TestCase): }) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_UNWILLING_TO_PERFORM) + self.assertEquals(num, ERR_UNWILLING_TO_PERFORM) self.delete_force(self.ldb, "cn=ldaptestuser7,cn=users," + self.base_dn) try: @@ -162,7 +162,7 @@ class BasicTests(unittest.TestCase): }) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_UNWILLING_TO_PERFORM) + self.assertEquals(num, ERR_UNWILLING_TO_PERFORM) self.delete_force(self.ldb, "cn=ldaptestuser7,cn=users," + self.base_dn) @@ -213,7 +213,7 @@ servicePrincipalName: cifs/ldaptest2computer """) self.fail() except LdbError, (num, msg): - self.assertEquals(num, LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS) + self.assertEquals(num, ERR_ATTRIBUTE_OR_VALUE_EXISTS) ldb.modify_ldif(""" dn: cn=ldaptest2computer,cn=computers,""" + self.base_dn + """ @@ -231,7 +231,7 @@ servicePrincipalName: host/ldaptest2computer """) self.fail() except LdbError, (num, msg): - self.assertEquals(num, LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS) + self.assertEquals(num, ERR_ATTRIBUTE_OR_VALUE_EXISTS) print "Testing ranged results" ldb.modify_ldif(""" @@ -352,7 +352,7 @@ servicePrincipalName: host/ldaptest2computer29 self.assertEquals(str(res[0].dn), ("CN=ldaptestuser,CN=Users," + self.base_dn)) self.assertEquals(res[0]["cn"][0], "ldaptestuser") - self.assertEquals(res[0]["name"], "ldaptestuser") + self.assertEquals(str(res[0]["name"]), "ldaptestuser") # Testing ldb.search for (&(anr=testy)(objectClass=user)) res = ldb.search(expression="(&(anr=testy)(objectClass=user))") @@ -384,24 +384,24 @@ servicePrincipalName: host/ldaptest2computer29 self.assertEquals(len(res), 1, "Could not find (&(anr=testy ldap user)(objectClass=user))") self.assertEquals(str(res[0].dn), ("CN=ldaptestuser2,CN=Users," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestuser2") - self.assertEquals(res[0]["name"], "ldaptestuser2") + self.assertEquals(str(res[0]["cn"]), "ldaptestuser2") + self.assertEquals(str(res[0]["name"]), "ldaptestuser2") # Testing ldb.search for (&(anr==testy ldap user2)(objectClass=user)) # res = ldb.search(expression="(&(anr==testy ldap user2)(objectClass=user))") # self.assertEquals(len(res), 1, "Could not find (&(anr==testy ldap user2)(objectClass=user))") self.assertEquals(str(res[0].dn), ("CN=ldaptestuser2,CN=Users," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestuser2") - self.assertEquals(res[0]["name"], "ldaptestuser2") + self.assertEquals(str(res[0]["cn"]), "ldaptestuser2") + self.assertEquals(str(res[0]["name"]), "ldaptestuser2") # Testing ldb.search for (&(anr==ldap user2)(objectClass=user)) # res = ldb.search(expression="(&(anr==ldap user2)(objectClass=user))") # self.assertEquals(len(res), 1, "Could not find (&(anr==ldap user2)(objectClass=user))") self.assertEquals(str(res[0].dn), ("CN=ldaptestuser2,CN=Users," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestuser2") - self.assertEquals(res[0]["name"], "ldaptestuser2") + self.assertEquals(str(res[0]["cn"]), "ldaptestuser2") + self.assertEquals(str(res[0]["name"]), "ldaptestuser2") # Testing ldb.search for (&(anr==not ldap user2)(objectClass=user)) # res = ldb.search(expression="(&(anr==not ldap user2)(objectClass=user))") @@ -436,7 +436,7 @@ member: cn=ldaptestuser3,cn=users,""" + self.base_dn + """ """) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT) + self.assertEquals(num, ERR_NO_SUCH_OBJECT) print "Testing Renames" @@ -457,24 +457,24 @@ member: cn=ldaptestuser3,cn=users,""" + self.base_dn + """ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestuser3)(objectClass=user))") self.assertEquals(str(res[0].dn), ("CN=ldaptestUSER3,CN=Users," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestUSER3") - self.assertEquals(res[0]["name"], "ldaptestUSER3") + self.assertEquals(str(res[0]["cn"]), "ldaptestUSER3") + self.assertEquals(str(res[0]["name"]), "ldaptestUSER3") #"Testing ldb.search for (&(&(cn=ldaptestuser3)(userAccountControl=*))(objectClass=user))" res = ldb.search(expression="(&(&(cn=ldaptestuser3)(userAccountControl=*))(objectClass=user))") self.assertEquals(len(res), 1, "(&(&(cn=ldaptestuser3)(userAccountControl=*))(objectClass=user))") self.assertEquals(str(res[0].dn), ("CN=ldaptestUSER3,CN=Users," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestUSER3") - self.assertEquals(res[0]["name"], "ldaptestUSER3") + self.assertEquals(str(res[0]["cn"]), "ldaptestUSER3") + self.assertEquals(str(res[0]["name"]), "ldaptestUSER3") #"Testing ldb.search for (&(&(cn=ldaptestuser3)(userAccountControl=546))(objectClass=user))" res = ldb.search(expression="(&(&(cn=ldaptestuser3)(userAccountControl=546))(objectClass=user))") self.assertEquals(len(res), 1, "(&(&(cn=ldaptestuser3)(userAccountControl=546))(objectClass=user))") self.assertEquals(str(res[0].dn), ("CN=ldaptestUSER3,CN=Users," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestUSER3") - self.assertEquals(res[0]["name"], "ldaptestUSER3") + self.assertEquals(str(res[0]["cn"]), "ldaptestUSER3") + self.assertEquals(str(res[0]["name"]), "ldaptestUSER3") #"Testing ldb.search for (&(&(cn=ldaptestuser3)(userAccountControl=547))(objectClass=user))" res = ldb.search(expression="(&(&(cn=ldaptestuser3)(userAccountControl=547))(objectClass=user))") @@ -495,8 +495,8 @@ member: cn=ldaptestuser3,cn=users,""" + self.base_dn + """ res = ldb.search(expression="(distinguishedName=CN=ldaptestUSER3,CN=Users," + self.base_dn + ")") self.assertEquals(len(res), 1, "Could not find (dn=CN=ldaptestUSER3,CN=Users," + self.base_dn + ")") self.assertEquals(str(res[0].dn), ("CN=ldaptestUSER3,CN=Users," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestUSER3") - self.assertEquals(res[0]["name"], "ldaptestUSER3") + self.assertEquals(str(res[0]["cn"]), "ldaptestUSER3") + self.assertEquals(str(res[0]["name"]), "ldaptestUSER3") # ensure we cannot add it again try: @@ -505,7 +505,7 @@ member: cn=ldaptestuser3,cn=users,""" + self.base_dn + """ "cn": "LDAPtestUSER3"}) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_ENTRY_ALREADY_EXISTS) + self.assertEquals(num, ERR_ENTRY_ALREADY_EXISTS) # rename back ldb.rename("cn=ldaptestuser3,cn=users," + self.base_dn, "cn=ldaptestuser2,cn=users," + self.base_dn) @@ -516,7 +516,7 @@ member: cn=ldaptestuser3,cn=users,""" + self.base_dn + """ "cn=ldaptestuser2,cn=users," + self.base_dn) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT) + self.assertEquals(num, ERR_NO_SUCH_OBJECT) # ensure can now use that name ldb.add({"dn": "cn=ldaptestuser3,cn=users," + self.base_dn, @@ -528,7 +528,7 @@ member: cn=ldaptestuser3,cn=users,""" + self.base_dn + """ ldb.rename("cn=ldaptestuser2,cn=users," + self.base_dn, "cn=ldaptestuser3,cn=users," + self.base_dn) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_ENTRY_ALREADY_EXISTS) + self.assertEquals(num, ERR_ENTRY_ALREADY_EXISTS) try: ldb.rename("cn=ldaptestuser3,cn=users," + self.base_dn, "cn=ldaptestuser3,cn=configuration," + self.base_dn) self.fail() @@ -569,12 +569,12 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ print "Testing subtree ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in (just renamed from) cn=ldaptestcontainer," + self.base_dn try: - ldb.search("cn=ldaptestcontainer," + self.base_dn, + res = ldb.search("cn=ldaptestcontainer," + self.base_dn, expression="(&(cn=ldaptestuser4)(objectClass=user))", scope=SCOPE_SUBTREE) - self.fail() + self.fail(res) except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT) + self.assertEquals(num, ERR_NO_SUCH_OBJECT) print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in (just renamed from) cn=ldaptestcontainer," + self.base_dn try: @@ -582,7 +582,7 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ expression="(&(cn=ldaptestuser4)(objectClass=user))", scope=SCOPE_ONELEVEL) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT) + self.assertEquals(num, ERR_NO_SUCH_OBJECT) print "Testing ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in renamed container" res = ldb.search("cn=ldaptestcontainer2," + self.base_dn, expression="(&(cn=ldaptestuser4)(objectClass=user))", scope=SCOPE_SUBTREE) @@ -602,21 +602,21 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ ldb.rename("cn=ldaptestcontainer2," + self.base_dn, "cn=ldaptestcontainer,cn=ldaptestcontainer2," + self.base_dn) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_UNWILLING_TO_PERFORM) + self.assertEquals(num, ERR_UNWILLING_TO_PERFORM) print "Testing ldb.rename (into non-existent container) of cn=ldaptestcontainer2," + self.base_dn + " to cn=ldaptestcontainer,cn=ldaptestcontainer3," + self.base_dn try: ldb.rename("cn=ldaptestcontainer2," + self.base_dn, "cn=ldaptestcontainer,cn=ldaptestcontainer3," + self.base_dn) self.fail() except LdbError, (num, _): - self.assertTrue(num in (LDB_ERR_UNWILLING_TO_PERFORM, LDB_ERR_OTHER)) + self.assertTrue(num in (ERR_UNWILLING_TO_PERFORM, ERR_OTHER)) print "Testing delete (should fail, not a leaf node) of renamed cn=ldaptestcontainer2," + self.base_dn try: ldb.delete("cn=ldaptestcontainer2," + self.base_dn) self.fail() except LdbError, (num, _): - self.assertEquals(num, LDB_ERR_NOT_ALLOWED_ON_NON_LEAF) + self.assertEquals(num, NOT_ALLOWED_ON_NON_LEAF) print "Testing base ldb.search for CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn res = ldb.search(expression="(objectclass=*)", base=("CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn), scope=SCOPE_BASE) @@ -648,12 +648,12 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestuser)(objectClass=user))") self.assertEquals(str(res[0].dn), ("CN=ldaptestuser,CN=Users," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestuser") - self.assertEquals(res[0]["name"], "ldaptestuser") - self.assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user"]) + self.assertEquals(str(res[0]["cn"]), "ldaptestuser") + self.assertEquals(str(res[0]["name"]), "ldaptestuser") + self.assertEquals(str(res[0]["objectClass"]), ["top", "person", "organizationalPerson", "user"]) self.assertTrue("objectGUID" in res[0]) self.assertTrue("whenCreated" in res[0]) - self.assertEquals(res[0]["objectCategory"], ("CN=Person,CN=Schema,CN=Configuration," + self.base_dn)) + self.assertEquals(str(res[0]["objectCategory"]), ("CN=Person,CN=Schema,CN=Configuration," + self.base_dn)) self.assertEquals(int(res[0]["sAMAccountType"][0]), 805306368) self.assertEquals(int(res[0]["userAccountControl"][0]), 546) self.assertEquals(res[0]["memberOf"][0].upper(), ("CN=ldaptestgroup2,CN=Users," + self.base_dn).upper()) @@ -692,9 +692,9 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestuser)(objectClass=user))") self.assertEquals(str(res[0].dn), ("CN=ldaptestcomputer,CN=Computers," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestcomputer") - self.assertEquals(res[0]["name"], "ldaptestcomputer") - self.assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user", "computer"]) + self.assertEquals(str(res[0]["cn"]), "ldaptestcomputer") + self.assertEquals(str(res[0]["name"]), "ldaptestcomputer") + self.assertEquals(str(res[0]["objectClass"]), ["top", "person", "organizationalPerson", "user", "computer"]) self.assertTrue("objectGUID" in res[0]) self.assertTrue("whenCreated" in res[0]) self.assertEquals(res[0]["objectCategory"], ("CN=Computer,CN=Schema,CN=Configuration," + self.base_dn)) @@ -755,9 +755,9 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptest2computer)(objectClass=user))") self.assertEquals(res[0].dn, ("CN=ldaptest2computer,CN=Computers," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptest2computer") - self.assertEquals(res[0]["name"], "ldaptest2computer") - self.assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user", "computer"]) + self.assertEquals(str(res[0]["cn"]), "ldaptest2computer") + self.assertEquals(str(res[0]["name"]), "ldaptest2computer") + self.assertEquals(list(res[0]["objectClass"]), ["top", "person", "organizationalPerson", "user", "computer"]) self.assertTrue("objectGUID" in res[0]) self.assertTrue("whenCreated" in res[0]) self.assertEquals(res[0]["objectCategory"][0], "CN=Computer,CN=Schema,CN=Configuration," + self.base_dn) @@ -772,9 +772,9 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ self.assertEquals(len(res_user), 1, "Could not find (&(cn=ldaptestUSer2)(objectClass=user))") self.assertEquals(res_user[0].dn, ("CN=ldaptestuser2,CN=Users," + self.base_dn)) - self.assertEquals(res_user[0]["cn"], "ldaptestuser2") - self.assertEquals(res_user[0]["name"], "ldaptestuser2") - self.assertEquals(res_user[0]["objectClass"], ["top", "person", "organizationalPerson", "user"]) + self.assertEquals(str(res_user[0]["cn"]), "ldaptestuser2") + self.assertEquals(str(res_user[0]["name"]), "ldaptestuser2") + self.assertEquals(list(res_user[0]["objectClass"]), ["top", "person", "organizationalPerson", "user"]) self.assertTrue("objectSid" in res_user[0]) self.assertTrue("objectGUID" in res_user[0]) self.assertTrue("whenCreated" in res_user[0]) @@ -792,9 +792,9 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group))") self.assertEquals(res[0].dn, ("CN=ldaptestgroup2,CN=Users," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestgroup2") - self.assertEquals(res[0]["name"], "ldaptestgroup2") - self.assertEquals(res[0]["objectClass"], ["top", "group"]) + self.assertEquals(str(res[0]["cn"]), "ldaptestgroup2") + self.assertEquals(str(res[0]["name"]), "ldaptestgroup2") + self.assertEquals(list(res[0]["objectClass"]), ["top", "group"]) self.assertTrue("objectGUID" in res[0]) self.assertTrue("objectSid" in res[0]) self.assertTrue("whenCreated" in res[0]) @@ -892,9 +892,9 @@ member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + self.base_dn + """ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))") self.assertEquals(res[0].dn, ("CN=ldaptestutf8user èùéìòà,CN=Users," + self.base_dn)) - self.assertEquals(res[0]["cn"], "ldaptestutf8user èùéìòà") - self.assertEquals(res[0]["name"], "ldaptestutf8user èùéìòà") - self.assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user"]) + self.assertEquals(str(res[0]["cn"]), "ldaptestutf8user èùéìòà") + self.assertEquals(str(res[0]["name"]), "ldaptestutf8user èùéìòà") + self.assertEquals(list(res[0]["objectClass"]), ["top", "person", "organizationalPerson", "user"]) self.assertTrue("objectGUID" in res[0]) self.assertTrue("whenCreated" in res[0]) @@ -957,7 +957,7 @@ member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + self.base_dn + """ scope=SCOPE_BASE, attrs=["objectClass"]) self.assertEquals(len(res), 1) - self.assertEquals(res[0]["objectClass"], ["top", "domain", "domainDNS"]) + self.assertEquals(list(res[0]["objectClass"]), ["top", "domain", "domainDNS"]) # check enumeration -- cgit