diff options
author | Stefan Metzmacher <metze@samba.org> | 2022-03-04 23:35:26 +0100 |
---|---|---|
committer | Jule Anger <janger@samba.org> | 2022-03-16 14:27:11 +0000 |
commit | 275f57f3796d7e74a2a9b69de51be53b89814f06 (patch) | |
tree | 21b060166f7f03c2cf9f460056e566726edecb64 | |
parent | 845d3674286b410070d215a73f75af4e758935af (diff) | |
download | samba-275f57f3796d7e74a2a9b69de51be53b89814f06.tar.gz |
dsdb/tests: introduce assertLoginSuccess
This makes it possible to catch failures with knownfail entries.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13879
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 751ce671a4af32bc1c56433a5a1c8161377856c5)
-rwxr-xr-x | source4/dsdb/tests/python/login_basics.py | 7 | ||||
-rw-r--r-- | source4/dsdb/tests/python/password_lockout_base.py | 13 |
2 files changed, 15 insertions, 5 deletions
diff --git a/source4/dsdb/tests/python/login_basics.py b/source4/dsdb/tests/python/login_basics.py index 6b1d04ad8ce..e43673456f5 100755 --- a/source4/dsdb/tests/python/login_basics.py +++ b/source4/dsdb/tests/python/login_basics.py @@ -102,7 +102,7 @@ class BasicUserAuthTests(BasePasswordTestCase): # check logging in with the correct password succeeds test_creds.set_password(userpass) - user_ldb = SamDB(url=self.host_url, credentials=test_creds, lp=self.lp) + user_ldb = self.assertLoginSuccess(self.host_url, test_creds, self.lp) res = self._check_account(userdn, badPwdCount=0, badPasswordTime=badPasswordTime, @@ -148,8 +148,7 @@ userPassword: %s badPasswordTime = int(res[0]["badPasswordTime"][0]) else: # for NTLM, logging in with the old password succeeds - user_ldb = SamDB(url=self.host_url, credentials=test_creds, - lp=self.lp) + user_ldb = self.assertLoginSuccess(self.host_url, test_creds, self.lp) info_msg = 'Test NTLM login with old password succeeds' res = self._check_account(userdn, badPwdCount=0, @@ -163,7 +162,7 @@ userPassword: %s # check logging in with the new password succeeds test_creds.set_password(new_password) - user_ldb = SamDB(url=self.host_url, credentials=test_creds, lp=self.lp) + user_ldb = self.assertLoginSuccess(self.host_url, test_creds, self.lp) res = self._check_account(userdn, badPwdCount=0, badPasswordTime=badPasswordTime, diff --git a/source4/dsdb/tests/python/password_lockout_base.py b/source4/dsdb/tests/python/password_lockout_base.py index 913e8304a8a..0951ed8594f 100644 --- a/source4/dsdb/tests/python/password_lockout_base.py +++ b/source4/dsdb/tests/python/password_lockout_base.py @@ -251,7 +251,7 @@ userPassword: """ + userpass + """ self.assertLoginFailure(self.host_url, fail_creds, self.lp) # Succeed to reset everything to 0 - ldb = SamDB(url=self.host_url, credentials=creds, lp=self.lp) + ldb = self.assertLoginSuccess(self.host_url, creds, self.lp) return ldb @@ -266,6 +266,17 @@ userPassword: """ + userpass + """ "(got err %d, expected %d)" % (num, errno))) + def assertLoginSuccess(self, url, creds, lp): + try: + ldb = SamDB(url=url, credentials=creds, lp=lp) + return ldb + except LdbError as e1: + (num, msg) = e1.args + self.assertEqual(num, LDB_SUCCESS, + ("Login failed - %d - %s" % ( + num, msg))) + + def setUp(self): super(BasePasswordTestCase, self).setUp() |