diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-04-16 12:07:23 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-04-16 12:07:23 +0300 |
commit | ee772866dae9cb2a66006a8e931e5bab6eb5db77 (patch) | |
tree | 6dc15db571102bfcc5a5ad71b4496e68e9f1a4a0 | |
parent | 5cbdaeb79ac70954d76d3385296dc5f1404a4d02 (diff) | |
download | distixapi-ee772866dae9cb2a66006a8e931e5bab6eb5db77.tar.gz |
Add test for wrong password
-rw-r--r-- | distixapi/authn_tests.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/distixapi/authn_tests.py b/distixapi/authn_tests.py index f9e2e15..7a150b5 100644 --- a/distixapi/authn_tests.py +++ b/distixapi/authn_tests.py @@ -65,6 +65,28 @@ class PasswordCheckingTests(unittest.TestCase): with self.assertRaises(distixapi.AuthenticationError): distixapi.get_scopes(users, request) + def test_raises_exception_if_password_is_wrong(self): + username = 'fooser' + salt = 'nacl' + password = 'passwooooord' + wrong_password = password + 'foo' + scopes = ['get', 'put'] + + users = { + 'users': { + username: { + 'salt': salt, + 'password': distixapi.encrypt_password(salt, password), + 'name': 'J. Random User', + 'scopes': scopes, + } + }, + } + + request = make_request(username, wrong_password) + with self.assertRaises(distixapi.AuthenticationError): + distixapi.get_scopes(users, request) + class DummyRequest(object): |