selftest: Prepare to allow override of lockout duration in password_lockout tests
authorAndrew Bartlett <abartlet@samba.org>
Sun, 2 Sep 2018 05:34:03 +0000 (17:34 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 3 Sep 2018 01:22:25 +0000 (03:22 +0200)
This will make it easier to avoid flapping tests.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
source4/dsdb/tests/python/password_lockout.py
source4/dsdb/tests/python/password_lockout_base.py

index 72455acd04f15de47b8caf3f0e49396e1f3b6440..be3e3fa53e20b9c685d369d4406a42f7532fe2eb 100755 (executable)
@@ -600,15 +600,14 @@ userPassword: thatsAcomplPASS2XYZ
                                                           initial_lastlogon_relation='greater')
 
     def use_pso_lockout_settings(self, creds):
+
         # create a PSO with the lockout settings the test cases normally expect
+        #
+        # Some test cases sleep() for self.account_lockout_duration
         pso = PasswordSettings("lockout-PSO", self.ldb, lockout_attempts=3,
-                               lockout_duration=3)
+                               lockout_duration=self.account_lockout_duration)
         self.addCleanup(self.ldb.delete, pso.dn)
 
-        # the test cases should sleep() for the PSO's lockoutDuration/obsvWindow
-        self.account_lockout_duration = 3
-        self.lockout_observation_window = 3
-
         userdn = "cn=%s,cn=users,%s" % (creds.get_username(), self.base_dn)
         pso.apply_to(userdn)
 
index 7308f6723bd9aa62f74efd797e750e3b31ebc499..c2664e9adba02ca70c67be52ce51e78c6d6abaac 100644 (file)
@@ -321,8 +321,15 @@ lockoutThreshold: """ + str(lockoutThreshold) + """
 """)
 
         self.base_dn = self.ldb.domain_dn()
-        self.account_lockout_duration = 3
-        self.lockout_observation_window = 3
+
+        #
+        # Some test cases sleep() for self.account_lockout_duration
+        # so allow it to be controlled via the subclass
+        #
+        if not hasattr(self, 'account_lockout_duration'):
+            self.account_lockout_duration = 3
+        if not hasattr(self, 'lockout_observation_window'):
+            self.lockout_observation_window = 3
         self.update_lockout_settings(threshold=3,
                                      duration=self.account_lockout_duration,
                                      observation_window=self.lockout_observation_window)