summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/leap/soledad/server/auth.py4
-rw-r--r--server/src/leap/soledad/server/entrypoint.py1
-rw-r--r--server/src/leap/soledad/server/session.py8
-rw-r--r--testing/tests/server/test__server_info.py8
-rw-r--r--testing/tests/server/test_session.py5
5 files changed, 17 insertions, 9 deletions
diff --git a/server/src/leap/soledad/server/auth.py b/server/src/leap/soledad/server/auth.py
index aea003ff..c52370cb 100644
--- a/server/src/leap/soledad/server/auth.py
+++ b/server/src/leap/soledad/server/auth.py
@@ -55,7 +55,6 @@ class SoledadRealm(object):
self._sync_pool = sync_pool
def requestAvatar(self, avatarId, mind, *interfaces):
- log.warn('avatarId {0}'.format(avatarId))
enable_blobs = self._conf['blobs']
# Anonymous access
@@ -66,7 +65,8 @@ class SoledadRealm(object):
# Authenticated users
- # XXX review this... we're creating a Resource tree
+ # TODO review this: #8770 ----------------
+ # we're creating a Resource tree
# for each request, for every user.
# What are the perf implications of this??
diff --git a/server/src/leap/soledad/server/entrypoint.py b/server/src/leap/soledad/server/entrypoint.py
index b10bfed6..8078a54a 100644
--- a/server/src/leap/soledad/server/entrypoint.py
+++ b/server/src/leap/soledad/server/entrypoint.py
@@ -35,7 +35,6 @@ conf = get_config()
class SoledadEntrypoint(SoledadSession):
def __init__(self):
- self._credentialFactories = []
SoledadSession.__init__(self)
diff --git a/server/src/leap/soledad/server/session.py b/server/src/leap/soledad/server/session.py
index 70e4a35b..515fd9b3 100644
--- a/server/src/leap/soledad/server/session.py
+++ b/server/src/leap/soledad/server/session.py
@@ -22,6 +22,7 @@ from zope.interface import implementer
from twisted.cred.credentials import Anonymous
from twisted.cred import error
from twisted.logger import Logger
+from twisted.python import log
from twisted.web import util
from twisted.web._auth import wrapper
from twisted.web.guard import HTTPAuthSessionWrapper
@@ -33,9 +34,6 @@ from leap.soledad.server.auth import credentialFactory
from leap.soledad.server.url_mapper import URLMapper
-log = Logger()
-
-
@implementer(IResource)
class UnauthorizedResource(wrapper.UnauthorizedResource):
isLeaf = True
@@ -63,6 +61,8 @@ class SoledadSession(HTTPAuthSessionWrapper):
self._mapper = URLMapper()
self._portal = portal
self._credentialFactory = credentialFactory
+ # expected by the contract of the parent class
+ self._credentialFactories = [credentialFactory]
def _matchPath(self, request):
match = self._mapper.match(request.path, request.method)
@@ -97,6 +97,8 @@ class SoledadSession(HTTPAuthSessionWrapper):
except error.LoginFailed:
return UnauthorizedResource()
except:
+ # If you port this to the newer log facility, be aware that
+ # the tests rely on the error to be logged.
log.err(None, "Unexpected failure from credentials factory")
return ErrorPage(500, None, None)
diff --git a/testing/tests/server/test__server_info.py b/testing/tests/server/test__server_info.py
index 80770721..40567ef1 100644
--- a/testing/tests/server/test__server_info.py
+++ b/testing/tests/server/test__server_info.py
@@ -31,9 +31,13 @@ class ServerInfoTestCase(unittest.TestCase):
def test_blobs_enabled(self):
resource = ServerInfo(True)
response = resource.render(DummyRequest(['']))
- self.assertEquals(json.loads(response), {'blobs': True})
+ _info = json.loads(response)
+ self.assertEquals(_info['blobs'], True)
+ self.assertTrue(isinstance(_info['version'], basestring))
def test_blobs_disabled(self):
resource = ServerInfo(False)
response = resource.render(DummyRequest(['']))
- self.assertEquals(json.loads(response), {'blobs': False})
+ _info = json.loads(response)
+ self.assertEquals(_info['blobs'], False)
+ self.assertTrue(isinstance(_info['version'], basestring))
diff --git a/testing/tests/server/test_session.py b/testing/tests/server/test_session.py
index 8131ddb3..b00ab858 100644
--- a/testing/tests/server/test_session.py
+++ b/testing/tests/server/test_session.py
@@ -156,6 +156,7 @@ class SoledadSessionTestCase(unittest.TestCase):
return {}
def decode(self, response, request):
+ print "decode raised"
raise UnexpectedException()
self.wrapper._credentialFactory = BadFactory()
@@ -164,7 +165,9 @@ class SoledadSessionTestCase(unittest.TestCase):
child = getChildForRequest(self.wrapper, request)
request.render(child)
self.assertEqual(request.responseCode, 500)
- self.assertEqual(len(self.flushLoggedErrors(UnexpectedException)), 1)
+ #self.assertEqual(len(self.flushLoggedErrors(UnexpectedException)), 1)
+ errors = self.flushLoggedErrors(UnexpectedException)
+ self.assertEqual(len(errors), 1)
def test_unexpectedLoginError(self):
class UnexpectedException(Exception):