From ee772866dae9cb2a66006a8e931e5bab6eb5db77 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 16 Apr 2017 12:07:23 +0300 Subject: Add test for wrong password --- distixapi/authn_tests.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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): -- cgit v1.2.1