tests: Split out setUp code into separate function for reuse
[metze/samba/wip.git] / python / samba / tests / password_hash.py
index a3a74aa25df83a0a731fad1e38fa69c6d01102bf..0a295d57c0ddd74aca8e7839fb04ac8d512ac51a 100644 (file)
@@ -29,6 +29,7 @@ from samba.dcerpc import drsblobs
 from samba.dcerpc.samr import DOMAIN_PASSWORD_STORE_CLEARTEXT
 from samba.dsdb import UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED
 from samba.tests import delete_force
+from samba.tests.password_test import PasswordCommon
 import ldb
 import samba
 import binascii
@@ -101,26 +102,11 @@ class PassWordHashTests(TestCase):
         # Gets back the configuration basedn
         configuration_dn = self.ldb.get_config_basedn().get_linearized()
 
-        # Get the old "dSHeuristics" if it was set
-        dsheuristics = self.ldb.get_dsheuristics()
+        # permit password changes during this test
+        PasswordCommon.allow_password_changes(self, self.ldb)
 
-        # Set the "dSHeuristics" to activate the correct "userPassword"
-        # behaviour
-        self.ldb.set_dsheuristics("000000001")
-
-        # Reset the "dSHeuristics" as they were before
-        self.addCleanup(self.ldb.set_dsheuristics, dsheuristics)
-
-        # Get the old "minPwdAge"
-        minPwdAge = self.ldb.get_minPwdAge()
-
-        # Set it temporarily to "0"
-        self.ldb.set_minPwdAge("0")
         self.base_dn = self.ldb.domain_dn()
 
-        # Reset the "minPwdAge" as it was before
-        self.addCleanup(self.ldb.set_minPwdAge, minPwdAge)
-
         account_control = 0
         if clear_text:
             # get the current pwdProperties