diff options
author | thaissiqueira <thais.siqueira@thoughtworks.com> | 2017-01-18 11:01:31 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-18 11:01:31 -0200 |
commit | ef163a2598f3bd26c5336e49c78d5b655e4d7e13 (patch) | |
tree | 8f105559d3be3f37c4bce34b36cb9ebdd1d6d3f3 | |
parent | dabbb73ad89ffa04377a12a4b55833a2814dc123 (diff) | |
parent | 6e876d879927c9b5f12eb70987b4070c5e8298eb (diff) |
Merge pull request #911 from pixelated/login-unicode
Encodes user_uuid and passphrase to allow utf-8 characteres
-rw-r--r-- | service/pixelated/config/sessions.py | 4 | ||||
-rw-r--r-- | service/test/unit/config/test_sessions.py | 17 |
2 files changed, 17 insertions, 4 deletions
diff --git a/service/pixelated/config/sessions.py b/service/pixelated/config/sessions.py index 439ca9b3..b301132a 100644 --- a/service/pixelated/config/sessions.py +++ b/service/pixelated/config/sessions.py @@ -75,8 +75,8 @@ class LeapSessionFactory(object): server_url = self._provider.discover_soledad_server(user_uuid) try: soledad = yield threads.deferToThread(Soledad, - user_uuid, - passphrase=unicode(password), + user_uuid.encode('utf-8'), + passphrase=unicode(password, 'utf-8'), secrets_path=secrets, local_db_path=local_db, server_url=server_url, diff --git a/service/test/unit/config/test_sessions.py b/service/test/unit/config/test_sessions.py index ad4dd590..91a0ef90 100644 --- a/service/test/unit/config/test_sessions.py +++ b/service/test/unit/config/test_sessions.py @@ -1,3 +1,4 @@ +# -*- encoding:utf-8 -*- # # Copyright (c) 2014 ThoughtWorks, Inc. # @@ -18,9 +19,8 @@ from mock import patch from mock import MagicMock from mockito import when from twisted.internet import defer -from pixelated.config.sessions import LeapSession, SessionCache +from pixelated.config.sessions import LeapSession, SessionCache, LeapSessionFactory from pixelated.bitmask_libraries.keymanager import UploadKeyError - from test.unit.bitmask_libraries.test_abstract_leap import AbstractLeapTest from leap.common.events.catalog import KEYMANAGER_FINISHED_KEY_GENERATION @@ -166,6 +166,19 @@ class SessionTest(AbstractLeapTest): self.assertFalse(session.fresh_account) + def test_session_setup_soledad_with_utf8_characters(self): + api_cert = MagicMock() + leap_session_factory = LeapSessionFactory(self.provider) + + with patch('pixelated.config.sessions.threads.deferToThread') as deferToThreadMock: + leap_session_factory.setup_soledad('self.token', u'self.uuid', 'Klünter', api_cert) + deferToThreadMock.assert_called_once() + args, kwargs = deferToThreadMock.call_args + uuid_arg = args[1] + pass_arg = kwargs['passphrase'] + self.assertIs(type(uuid_arg), str, "expected uuid argument to be a string") + self.assertIs(type(pass_arg), unicode, "expected passphrase argument to be unicode") + def _create_session(self): return LeapSession(self.provider, self.auth, self.mail_store, self.soledad_session, self.keymanager, self.smtp_mock) |