summaryrefslogtreecommitdiff
path: root/testing/tests/server/test_session.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/tests/server/test_session.py')
-rw-r--r--testing/tests/server/test_session.py45
1 files changed, 10 insertions, 35 deletions
diff --git a/testing/tests/server/test_session.py b/testing/tests/server/test_session.py
index 7883ef4a..8131ddb3 100644
--- a/testing/tests/server/test_session.py
+++ b/testing/tests/server/test_session.py
@@ -17,24 +17,20 @@
"""
Tests for server session entrypoint.
"""
-from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse
+from twisted.trial import unittest
+
from twisted.cred import portal
+from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse
+from twisted.cred.credentials import IUsernamePassword
+from twisted.web.resource import getChildForRequest
+from twisted.web.static import Data
+from twisted.web.test.requesthelper import DummyRequest
from twisted.web.test.test_httpauth import b64encode
from twisted.web.test.test_httpauth import Realm
-from twisted.web.test.requesthelper import DummyRequest
-from twisted.web.resource import getChildForRequest
-
-from twisted.web.resource import Resource
-
-from twisted.trial import unittest
+from twisted.web._auth.wrapper import UnauthorizedResource
from leap.soledad.server.session import SoledadSession
-from twisted.web.static import Data
-from twisted.web._auth.wrapper import UnauthorizedResource
-from twisted.cred.credentials import IUsernamePassword
-from twisted.cred.checkers import ANONYMOUS, AllowAnonymousAccess
-
class SoledadSessionTestCase(unittest.TestCase):
"""
@@ -168,6 +164,7 @@ class SoledadSessionTestCase(unittest.TestCase):
child = getChildForRequest(self.wrapper, request)
request.render(child)
self.assertEqual(request.responseCode, 500)
+ self.assertEqual(len(self.flushLoggedErrors(UnexpectedException)), 1)
def test_unexpectedLoginError(self):
class UnexpectedException(Exception):
@@ -184,26 +181,4 @@ class SoledadSessionTestCase(unittest.TestCase):
child = self._authorizedTokenLogin(request)
request.render(child)
self.assertEqual(request.responseCode, 500)
-
- def test_anonymousAccess(self):
- """
- Anonymous requests are allowed if a L{Portal} has an anonymous checker
- registered.
- """
- unprotectedContents = b"contents of the unprotected child resource"
-
- self.avatars[ANONYMOUS] = Resource()
- self.avatars[ANONYMOUS].putChild(
- self.childName, Data(unprotectedContents, 'text/plain'))
- self.portal.registerChecker(AllowAnonymousAccess())
-
- request = self.makeRequest([self.childName])
- child = getChildForRequest(self.wrapper, request)
- d = request.notifyFinish()
-
- def cbFinished(ignored):
- self.assertEqual(request.written, [unprotectedContents])
-
- d.addCallback(cbFinished)
- request.render(child)
- return d
+ self.assertEqual(len(self.flushLoggedErrors(UnexpectedException)), 1)