diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2015-10-22 16:54:19 +1300 |
---|---|---|
committer | Garming Sam <garming@samba.org> | 2015-12-15 00:08:57 +0100 |
commit | 909ebe0191a409c107904df658dc9111dd5de669 (patch) | |
tree | 80c8cc23c27bf0859db76fcfaba10fd7f28680c0 /source4/dsdb | |
parent | d097e813fff3aaed261a18d8066e6bd11f12abad (diff) | |
download | samba-909ebe0191a409c107904df658dc9111dd5de669.tar.gz |
password_lockout tests: add assertLoginFailure()
In a few places where a login should fail in a particular way, an
actual login success would not have triggered a test failure -- only
the wrong kind of login failure was caught.
This makes a helper function to deal with them all.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source4/dsdb')
-rwxr-xr-x | source4/dsdb/tests/python/password_lockout.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/source4/dsdb/tests/python/password_lockout.py b/source4/dsdb/tests/python/password_lockout.py index 133b40b9369..fddbb8f24c8 100755 --- a/source4/dsdb/tests/python/password_lockout.py +++ b/source4/dsdb/tests/python/password_lockout.py @@ -233,6 +233,16 @@ userAccountControl: %d time.sleep(0.01) return res + def assertLoginFailure(self, url, creds, lp, errno=ERR_INVALID_CREDENTIALS): + try: + ldb = SamDB(url=url, credentials=creds, lp=lp) + self.fail("Login unexpectedly succeeded") + except LdbError, (num, msg): + if errno is not None: + self.assertEquals(num, errno, ("Login failed in the wrong way" + "(got err %d, expected %d)" % + (num, errno))) + def setUp(self): super(PasswordTests, self).setUp() @@ -1230,11 +1240,7 @@ unicodePwd:: """ + base64.b64encode("\"thatsAcomplPASS2\"".encode('utf-16-le')) # The wrong password creds_lockout.set_password("thatsAcomplPASS1x") - try: - ldb_lockout = SamDB(url=host_url, credentials=creds_lockout, lp=lp) - - except LdbError, (num, msg): - self.assertEquals(num, ERR_INVALID_CREDENTIALS) + self.assertLoginFailure(host_url, creds_lockout, lp) res = self._check_account("cn=testuser,cn=users," + self.base_dn, badPwdCount=1, @@ -1259,11 +1265,7 @@ unicodePwd:: """ + base64.b64encode("\"thatsAcomplPASS2\"".encode('utf-16-le')) # The wrong password creds_lockout.set_password("thatsAcomplPASS1x") - try: - ldb_lockout = SamDB(url=host_url, credentials=creds_lockout, lp=lp) - - except LdbError, (num, msg): - self.assertEquals(num, ERR_INVALID_CREDENTIALS) + self.assertLoginFailure(host_url, creds_lockout, lp) res = self._check_account("cn=testuser,cn=users," + self.base_dn, badPwdCount=1, |