From caed945c7c85800d7467f52471509afc21a6f071 Mon Sep 17 00:00:00 2001 From: Thais Siqueira Date: Thu, 2 Mar 2017 16:23:17 -0300 Subject: [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 --- tests/unit/bonafide/test_users.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/unit/bonafide/test_users.py (limited to 'tests') 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}) -- cgit v1.2.3