diff options
author | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-11-09 15:04:47 +0100 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-11-11 10:03:40 +0100 |
commit | 4f86f297a22655067006f88eed5f6cb980742b81 (patch) | |
tree | 64a699e6fd5c71e206a02d4bb3ad9a6b46803880 /source4/dsdb | |
parent | 7f171a9e0f9b5945bd16a1330ba0908090659030 (diff) | |
download | samba-4f86f297a22655067006f88eed5f6cb980742b81.tar.gz samba-4f86f297a22655067006f88eed5f6cb980742b81.tar.bz2 samba-4f86f297a22655067006f88eed5f6cb980742b81.zip |
s4:passwords.py - add a test for the normal "userPassword" behaviour
Just to make sure that this works now too
Diffstat (limited to 'source4/dsdb')
-rwxr-xr-x | source4/dsdb/tests/python/passwords.py | 98 |
1 files changed, 97 insertions, 1 deletions
diff --git a/source4/dsdb/tests/python/passwords.py b/source4/dsdb/tests/python/passwords.py index 869c4a0524..8cb7136ebb 100755 --- a/source4/dsdb/tests/python/passwords.py +++ b/source4/dsdb/tests/python/passwords.py @@ -11,6 +11,7 @@ import optparse import sys import base64 +import time import os sys.path.append("bin/python") @@ -821,6 +822,101 @@ userPassword: thatsAcomplPASS4 self.assertTrue(num == ERR_CONSTRAINT_VIOLATION or num == ERR_NO_SUCH_ATTRIBUTE) # for Windows + def test_plain_userPassword(self): + print "Performs testing about the standard 'userPassword' behaviour" + + # Delete the "dSHeuristics" + m = Message() + m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, " + + configuration_dn) + m["dSHeuristics"] = MessageElement([], FLAG_MOD_DELETE, "dsHeuristics") + ldb.modify(m) + + time.sleep(1) # This switching time is strictly needed! + + m = Message() + m.dn = Dn(ldb, "cn=testuser,cn=users," + self.base_dn) + m["userPassword"] = MessageElement("myPassword", FLAG_MOD_ADD, + "userPassword") + ldb.modify(m) + + res = ldb.search("cn=testuser,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["userPassword"]) + self.assertTrue(len(res) == 1) + self.assertTrue("userPassword" in res[0]) + self.assertEquals(res[0]["userPassword"][0], "myPassword") + + m = Message() + m.dn = Dn(ldb, "cn=testuser,cn=users," + self.base_dn) + m["userPassword"] = MessageElement("myPassword2", FLAG_MOD_REPLACE, + "userPassword") + ldb.modify(m) + + res = ldb.search("cn=testuser,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["userPassword"]) + self.assertTrue(len(res) == 1) + self.assertTrue("userPassword" in res[0]) + self.assertEquals(res[0]["userPassword"][0], "myPassword2") + + m = Message() + m.dn = Dn(ldb, "cn=testuser,cn=users," + self.base_dn) + m["userPassword"] = MessageElement([], FLAG_MOD_DELETE, + "userPassword") + ldb.modify(m) + + res = ldb.search("cn=testuser,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["userPassword"]) + self.assertTrue(len(res) == 1) + self.assertFalse("userPassword" in res[0]) + + # Set the test "dSHeuristics" to deactivate "userPassword" pwd changes + m = Message() + m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, " + + configuration_dn) + m["dSHeuristics"] = MessageElement("000000000", FLAG_MOD_REPLACE, + "dSHeuristics") + ldb.modify(m) + + m = Message() + m.dn = Dn(ldb, "cn=testuser,cn=users," + self.base_dn) + m["userPassword"] = MessageElement("myPassword3", FLAG_MOD_REPLACE, + "userPassword") + ldb.modify(m) + + res = ldb.search("cn=testuser,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["userPassword"]) + self.assertTrue(len(res) == 1) + self.assertTrue("userPassword" in res[0]) + self.assertEquals(res[0]["userPassword"][0], "myPassword3") + + # Set the test "dSHeuristics" to deactivate "userPassword" pwd changes + m = Message() + m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, " + + configuration_dn) + m["dSHeuristics"] = MessageElement("000000002", FLAG_MOD_REPLACE, + "dSHeuristics") + ldb.modify(m) + + m = Message() + m.dn = Dn(ldb, "cn=testuser,cn=users," + self.base_dn) + m["userPassword"] = MessageElement("myPassword4", FLAG_MOD_REPLACE, + "userPassword") + ldb.modify(m) + + res = ldb.search("cn=testuser,cn=users," + self.base_dn, + scope=SCOPE_BASE, attrs=["userPassword"]) + self.assertTrue(len(res) == 1) + self.assertTrue("userPassword" in res[0]) + self.assertEquals(res[0]["userPassword"][0], "myPassword4") + + # Reset the test "dSHeuristics" (reactivate "userPassword" pwd changes) + m = Message() + m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, " + + configuration_dn) + m["dSHeuristics"] = MessageElement("000000001", FLAG_MOD_REPLACE, + "dSHeuristics") + ldb.modify(m) + def tearDown(self): super(PasswordTests, self).tearDown() self.delete_force(self.ldb, "cn=testuser,cn=users," + self.base_dn) @@ -854,7 +950,7 @@ if "dSHeuristics" in res[0]: else: dsheuristics = None -# Set the "dSHeuristics" to have the tests run against Windows Server +# Set the "dSHeuristics" to activate the correct "userPassword" behaviour m = Message() m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, " + configuration_dn) |