diff options
author | NavaL <ayoyo@thoughtworks.com> | 2016-10-26 15:55:29 +0200 |
---|---|---|
committer | NavaL <ayoyo@thoughtworks.com> | 2016-10-28 18:02:25 +0200 |
commit | 423ca8f9fb7636b336b24ba28bde5d61538bf5fc (patch) | |
tree | 6d8f95fafe4f08b4ca557d52bc45d310fa8c37af /service/test/support/integration/multi_user_client.py | |
parent | 3df56a4f3c411c3bde51c88e6e0bf34d5e582119 (diff) |
authentication now returns Authentication
leap session creation is only done post-interstitial
and that logic is also extracted into its own class
#795
Diffstat (limited to 'service/test/support/integration/multi_user_client.py')
-rw-r--r-- | service/test/support/integration/multi_user_client.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/service/test/support/integration/multi_user_client.py b/service/test/support/integration/multi_user_client.py index 0257214f..28316d5b 100644 --- a/service/test/support/integration/multi_user_client.py +++ b/service/test/support/integration/multi_user_client.py @@ -13,8 +13,10 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. +from leap.bitmask.bonafide._srp import SRPAuthError from mock import patch from mockito import mock, when, any as ANY +from pixelated.authentication import Authenticator from pixelated.config.leap import Authentication from twisted.internet import defer @@ -49,9 +51,14 @@ class MultiUserClient(AppTestClient): self.credentials_checker = StubSRPChecker(leap_provider) self.resource = set_up_protected_resources(root_resource, leap_provider, self.service_factory, checker=self.credentials_checker) - def login(self, username='username', password='password'): - if(username == 'username' and password == 'password'): + def _mock_bonafide_auth(self, username, password): + if username == 'username' and password == 'password': self.credentials_checker.add_user(username, password) + when(Authenticator)._bonafide_auth(username, password).thenReturn(self.user_auth) + else: + when(Authenticator)._bonafide_auth(username, password).thenRaise(SRPAuthError) + + def login(self, username='username', password='password'): session = Authentication(username, 'some_user_token', 'some_user_uuid', 'session_id', {'is_admin': False}) leap_session = self._test_account.leap_session leap_session.user_auth = session @@ -63,6 +70,8 @@ class MultiUserClient(AppTestClient): self.services = self._test_account.services self.user_auth = session + self._mock_bonafide_auth(username, password) + when(LeapSessionFactory).create(username, password, session).thenReturn(leap_session) with patch('mockito.invocation.AnswerSelector', AnswerSelector): when(leap_session).initial_sync().thenAnswer(lambda: defer.succeed(None)) |