summaryrefslogtreecommitdiff
path: root/service/test/unit/resources
diff options
context:
space:
mode:
authorNavaL <mnandri@thoughtworks.com>2016-02-03 13:44:13 +0100
committerNavaL <mnandri@thoughtworks.com>2016-02-03 13:49:54 +0100
commit4873b25259b7ec1c060e32993857a183314eaa66 (patch)
tree90c1d0c0e3ccf72074b75a21c307a581fcc381f7 /service/test/unit/resources
parenta57953de3be89533be11c5d346fb98ab210954bc (diff)
checks to load leap sessions and services or not
Issue #590
Diffstat (limited to 'service/test/unit/resources')
-rw-r--r--service/test/unit/resources/test_login_resource.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/service/test/unit/resources/test_login_resource.py b/service/test/unit/resources/test_login_resource.py
index 50b96f15..8f65a030 100644
--- a/service/test/unit/resources/test_login_resource.py
+++ b/service/test/unit/resources/test_login_resource.py
@@ -1,8 +1,6 @@
-import os
-
from leap.exceptions import SRPAuthenticationError
from mock import patch
-from mockito import mock, when, any as ANY, verify, verifyZeroInteractions
+from mockito import mock, when, any as ANY, verify, verifyZeroInteractions, verifyNoMoreInteractions
from twisted.trial import unittest
from twisted.web.resource import IResource
from twisted.web.test.requesthelper import DummyRequest
@@ -113,6 +111,24 @@ class TestLoginPOST(unittest.TestCase):
d.addCallback(assert_login_setup_service_for_user)
return d
+ def test_login_does_not_reload_leap_sessions_and_services_if_already_loaded(self):
+ irrelevant = None
+ when(self.portal).login(ANY(), None, IResource).thenReturn((irrelevant, self.user_auth, irrelevant))
+ when(self.services_factory).is_logged_in('some_user_uuid').thenReturn(True)
+
+ d = self.web.get(self.request)
+
+ def assert_login_setup_service_for_user(_):
+ verify(self.portal).login(ANY(), None, IResource)
+ verify(self.services_factory).is_logged_in('some_user_uuid')
+ verifyNoMoreInteractions(self.services_factory)
+ interstitial_js_in_template = '<script src="startup-assets/Interstitial.js"></script>'
+ self.assertIn(interstitial_js_in_template, self.request.written[0])
+ self.assertTrue(self.resource.is_logged_in(self.request))
+
+ d.addCallback(assert_login_setup_service_for_user)
+ return d
+
def test_should_return_form_back_with_error_message_when_login_fails(self):
when(self.portal).login(ANY(), None, IResource).thenRaise(Exception())
d = self.web.get(self.request)