From: Andrew Bartlett Date: Sun, 2 Sep 2018 05:34:03 +0000 (+1200) Subject: selftest: Prepare to allow override of lockout duration in password_lockout tests X-Git-Tag: tdb-1.3.17~1901 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=a740a6131c967f9640b19a6964fd5d6f85ce853a selftest: Prepare to allow override of lockout duration in password_lockout tests This will make it easier to avoid flapping tests. Signed-off-by: Andrew Bartlett Reviewed-by: Gary Lockyer --- diff --git a/source4/dsdb/tests/python/password_lockout.py b/source4/dsdb/tests/python/password_lockout.py index 72455acd04f..be3e3fa53e2 100755 --- a/source4/dsdb/tests/python/password_lockout.py +++ b/source4/dsdb/tests/python/password_lockout.py @@ -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) diff --git a/source4/dsdb/tests/python/password_lockout_base.py b/source4/dsdb/tests/python/password_lockout_base.py index 7308f6723bd..c2664e9adba 100644 --- a/source4/dsdb/tests/python/password_lockout_base.py +++ b/source4/dsdb/tests/python/password_lockout_base.py @@ -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)