diff options
Diffstat (limited to 'service/test/unit/resources/test_auth.py')
-rw-r--r-- | service/test/unit/resources/test_auth.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/service/test/unit/resources/test_auth.py b/service/test/unit/resources/test_auth.py index ac2529dd..adff1083 100644 --- a/service/test/unit/resources/test_auth.py +++ b/service/test/unit/resources/test_auth.py @@ -14,19 +14,20 @@ class TestPixelatedAuthSessionWrapper(unittest.TestCase): def setUp(self): self.portal_mock = mock() + self.user_uuid_mock = mock() self.root_resource_mock = mock() self.anonymous_resource_mock = mock() credential_factories_mock = mock() self.session_wrapper = PixelatedAuthSessionWrapper(self.portal_mock, self.root_resource_mock, self.anonymous_resource_mock, credential_factories_mock) + self.request = DummyRequest([]) + self.request.prepath = [''] + self.request.path = '/' - def test_should_use_login_resource_when_the_user_is_not_logged_in(self): - request = DummyRequest([]) - request.prepath = [''] - request.path = '/' + def test_should_proxy_to_login_resource_when_the_user_is_not_logged_in(self): when(self.portal_mock).login(ANY(), None, IResource).thenReturn(succeed((IResource, ANONYMOUS, lambda: None))) - deferred_resource = self.session_wrapper.getChildWithDefault('/', request) + deferred_resource = self.session_wrapper.getChildWithDefault('/', self.request) d = deferred_resource.d def assert_anonymous_resource(resource): @@ -34,3 +35,15 @@ class TestPixelatedAuthSessionWrapper(unittest.TestCase): d.addCallback(assert_anonymous_resource) return d + + def test_should_proxy_to_root_resource_when_the_user_is_logged_in(self): + when(self.portal_mock).login(ANY(), None, IResource).thenReturn(succeed((IResource, self.user_uuid_mock, lambda: None))) + + deferred_resource = self.session_wrapper.getChildWithDefault('/', self.request) + d = deferred_resource.d + + def assert_root_resource(resource): + self.assertIs(resource, self.root_resource_mock) + + d.addCallback(assert_root_resource) + return d |