1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-21 18:04:06 +03:00

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)
This commit is contained in:
Stefan Metzmacher 2022-03-04 23:35:26 +01:00 committed by Jule Anger
parent 845d367428
commit 275f57f379
2 changed files with 15 additions and 5 deletions

View File

@ -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,

View File

@ -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()