diff options
author | Thais Siqueira <thais.siqueira@gmail.com> | 2017-03-02 16:23:17 -0300 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2017-03-30 17:00:06 +0200 |
commit | caed945c7c85800d7467f52471509afc21a6f071 (patch) | |
tree | 4b1c3167e49044f14c0192e842bfd30fc92e8912 /tests/unit | |
parent | bd853141a23055cf2d1e0a4ae1712577024f9b84 (diff) |
[feature] Creates methods for update recovery code.
Related with: https://github.com/pixelated/pixelated-user-agent/issues/924
with @aarni
Signed-off-by: Ruben Pollan <meskio@sindominio.net>
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/bonafide/test_users.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/unit/bonafide/test_users.py b/tests/unit/bonafide/test_users.py new file mode 100644 index 00000000..952e73d4 --- /dev/null +++ b/tests/unit/bonafide/test_users.py @@ -0,0 +1,34 @@ +from mock import patch, ANY + +from twisted.internet import defer +from twisted.trial import unittest +from twisted.cred.credentials import UsernamePassword + +from leap.bitmask.bonafide.provider import Api +from leap.bitmask.bonafide.session import Session + + +class UsersTest(unittest.TestCase): + + @patch('leap.bitmask.bonafide.session.Session.is_authenticated') + @patch('leap.bitmask.bonafide.session.cookieAgentFactory') + @patch('leap.bitmask.bonafide.session.httpRequest') + @defer.inlineCallbacks + def test_recovery_code_creation(self, + mock_http_request, + mock_cookie_agent, + mock_is_authenticated): + api = Api('https://api.test:4430') + credentials = UsernamePassword('username', 'password') + + mock_is_authenticated.return_value = True + session = Session(credentials, api, 'fake path') + session._uuid = '123' + + response = yield session.update_recovery_code('RECOVERY_CODE') + mock_http_request.assert_called_with( + ANY, 'https://api.test:4430/1/users/123', + method='PUT', + token=None, + values={'user[recovery_code_salt]': ANY, + 'user[recovery_code_verifier]': ANY}) |