From: Nadezhda Ivanova Date: Wed, 3 Nov 2010 13:15:02 +0000 (+0200) Subject: s4-tests: Tests for the dSHeuristics attribute value restrictions X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwip.git;a=commitdiff_plain;h=3f4380993e75774c0c5d30171097f701b4227db7 s4-tests: Tests for the dSHeuristics attribute value restrictions Autobuild-User: Nadezhda Ivanova Autobuild-Date: Wed Nov 3 13:58:42 UTC 2010 on sn-devel-104 --- diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py index d69824373fcd..e8bc62580784 100755 --- a/source4/dsdb/tests/python/ldap.py +++ b/source4/dsdb/tests/python/ldap.py @@ -89,6 +89,17 @@ class BasicTests(unittest.TestCase): res = self.ldb.search(base=self.base_dn, expression="(objectClass=*)", scope=SCOPE_BASE) return ndr_unpack( security.dom_sid,res[0]["objectSid"][0]) + def set_dsheuristics(self, dsheuristics): + m = Message() + m.dn = Dn(self.ldb, "CN=Directory Service, CN=Windows NT, CN=Services, " + + self.configuration_dn) + if dsheuristics is not None: + m["dSHeuristics"] = MessageElement(dsheuristics, FLAG_MOD_REPLACE, + "dSHeuristics") + else: + m["dSHeuristics"] = MessageElement([], FLAG_MOD_DELETE, "dsHeuristics") + self.ldb.modify(m) + def setUp(self): super(BasicTests, self).setUp() self.ldb = ldb @@ -2471,6 +2482,36 @@ nTSecurityDescriptor:: """ + desc_base64 finally: self.delete_force(self.ldb, user_dn) + def test_dsheuristics(self): + """Tests the 'dSHeuristics' attribute""" + print "Tests the 'dSHeuristics' attribute""" + + # Get the current value to restore it later + res = self.ldb.search("CN=Directory Service, CN=Windows NT, CN=Services, " + + self.configuration_dn, scope=SCOPE_BASE, attrs=["dSHeuristics"]) + if "dSHeuristics" in res[0]: + dsheuristics = res[0]["dSHeuristics"][0] + else: + dsheuristics = None + # Should not be longer than 18 chars? + try: + self.set_dsheuristics("123ABC-+!1asdfg@#^12") + except LdbError, (num, _): + self.assertEquals(num, ERR_CONSTRAINT_VIOLATION) + # If it is >= 10 chars, tenthChar should be 1 + try: + self.set_dsheuristics("00020000000002") + except LdbError, (num, _): + self.assertEquals(num, ERR_CONSTRAINT_VIOLATION) + # apart from the above, all char values are accepted + self.set_dsheuristics("123ABC-+!1asdfg@#^") + res = self.ldb.search("CN=Directory Service, CN=Windows NT, CN=Services, " + + self.configuration_dn, scope=SCOPE_BASE, attrs=["dSHeuristics"]) + self.assertTrue("dSHeuristics" in res[0]) + self.assertEquals(res[0]["dSHeuristics"][0], "123ABC-+!1asdfg@#^") + # restore old value + self.set_dsheuristics(dsheuristics) + class BaseDnTests(unittest.TestCase):