diff options
author | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-10-24 21:25:52 +0200 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-10-26 18:12:00 +0000 |
commit | a839422fc57762ea3366afbe58b018cf11bfffd7 (patch) | |
tree | ba5ba51af8377ccd432ecfb3fbffd8243ca0ee7a /source4 | |
parent | 4f25eec5a5d9e57f0a63591535fe3f581ce23f45 (diff) | |
download | samba-a839422fc57762ea3366afbe58b018cf11bfffd7.tar.gz samba-a839422fc57762ea3366afbe58b018cf11bfffd7.tar.bz2 samba-a839422fc57762ea3366afbe58b018cf11bfffd7.zip |
s4:ldap.py - enhance and activate the "description" attribute test
It tests only the "description" attribute in particular since it behaves
differently from all others.
Diffstat (limited to 'source4')
-rwxr-xr-x | source4/dsdb/tests/python/ldap.py | 116 |
1 files changed, 89 insertions, 27 deletions
diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py index a7e718e181..3fa6fe5eb3 100755 --- a/source4/dsdb/tests/python/ldap.py +++ b/source4/dsdb/tests/python/ldap.py @@ -591,14 +591,9 @@ class BasicTests(unittest.TestCase): self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) - def test_multi_valued_attributes(self): - """Test multi-valued attributes""" - print "Test multi-valued attributes""" - -# TODO: In this test I added some special tests where I got very unusual -# results back from a real AD. s4 doesn't match them and I've no idea how to -# implement those error cases (maybe there exists a special trigger for -# "description" attributes which handle them) + def test_description_attribute(self): + """Test description attribute""" + print "Test description attribute""" self.ldb.add({ "dn": "cn=ldaptestgroup,cn=users," + self.base_dn, @@ -606,6 +601,13 @@ class BasicTests(unittest.TestCase): "objectclass": "group", "description": "desc1"}) + res = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["description"]) + self.assertTrue(len(res) == 1) + self.assertTrue("description" in res[0]) + self.assertTrue(len(res[0]["description"]) == 1) + self.assertEquals(res[0]["description"][0], "desc1") + self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) self.ldb.add({ @@ -613,6 +615,16 @@ class BasicTests(unittest.TestCase): "objectclass": "group", "description": ["desc1", "desc2"]}) + res = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["description"]) + self.assertTrue(len(res) == 1) + self.assertTrue("description" in res[0]) + self.assertTrue(len(res[0]["description"]) == 2) + self.assertTrue(res[0]["description"][0] == "desc1" or + res[0]["description"][1] == "desc1") + self.assertTrue(res[0]["description"][0] == "desc2" or + res[0]["description"][1] == "desc2") + m = Message() m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) m["description"] = MessageElement(["desc1","desc2"], FLAG_MOD_REPLACE, @@ -625,19 +637,58 @@ class BasicTests(unittest.TestCase): m = Message() m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) + m["description"] = MessageElement(["desc1","desc2"], FLAG_MOD_DELETE, + "description") + ldb.modify(m) + + self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) + + self.ldb.add({ + "dn": "cn=ldaptestgroup,cn=users," + self.base_dn, + "objectclass": "group" }) + + m = Message() + m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) + m["description"] = MessageElement("desc1", FLAG_MOD_REPLACE, + "description") + ldb.modify(m) + + res = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["description"]) + self.assertTrue(len(res) == 1) + self.assertTrue("description" in res[0]) + self.assertTrue(len(res[0]["description"]) == 1) + self.assertEquals(res[0]["description"][0], "desc1") + + self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) + + self.ldb.add({ + "dn": "cn=ldaptestgroup,cn=users," + self.base_dn, + "objectclass": "group", + "description": ["desc1", "desc2"]}) + + m = Message() + m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) m["description"] = MessageElement("desc1", FLAG_MOD_REPLACE, "description") ldb.modify(m) -# m = Message() -# m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) -# m["description"] = MessageElement("desc3", FLAG_MOD_ADD, -# "description") -# try: -# ldb.modify(m) -# self.fail() -# except LdbError, (num, _): -# self.assertEquals(num, ERR_ATTRIBUTE_OR_VALUE_EXISTS) + res = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["description"]) + self.assertTrue(len(res) == 1) + self.assertTrue("description" in res[0]) + self.assertTrue(len(res[0]["description"]) == 1) + self.assertEquals(res[0]["description"][0], "desc1") + + m = Message() + m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) + m["description"] = MessageElement("desc3", FLAG_MOD_ADD, + "description") + try: + ldb.modify(m) + self.fail() + except LdbError, (num, _): + self.assertEquals(num, ERR_ATTRIBUTE_OR_VALUE_EXISTS) m = Message() m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) @@ -654,6 +705,10 @@ class BasicTests(unittest.TestCase): m["description"] = MessageElement("desc1", FLAG_MOD_DELETE, "description") ldb.modify(m) + res = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["description"]) + self.assertTrue(len(res) == 1) + self.assertFalse("description" in res[0]) m = Message() m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) @@ -665,22 +720,29 @@ class BasicTests(unittest.TestCase): except LdbError, (num, _): self.assertEquals(num, ERR_ATTRIBUTE_OR_VALUE_EXISTS) -# m = Message() -# m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) -# m["description"] = MessageElement(["desc3", "desc4"], FLAG_MOD_ADD, -# "description") -# try: -# ldb.modify(m) -# self.fail() -# except LdbError, (num, _): -# self.assertEquals(num, ERR_ATTRIBUTE_OR_VALUE_EXISTS) + m = Message() + m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) + m["description"] = MessageElement(["desc3", "desc4"], FLAG_MOD_ADD, + "description") + try: + ldb.modify(m) + self.fail() + except LdbError, (num, _): + self.assertEquals(num, ERR_ATTRIBUTE_OR_VALUE_EXISTS) m = Message() m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) - m["description"] = MessageElement("desc3", FLAG_MOD_ADD, + m["description"] = MessageElement("desc1", FLAG_MOD_ADD, "description") ldb.modify(m) + res = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["description"]) + self.assertTrue(len(res) == 1) + self.assertTrue("description" in res[0]) + self.assertTrue(len(res[0]["description"]) == 1) + self.assertEquals(res[0]["description"][0], "desc1") + self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + self.base_dn) def test_empty_messages(self): |