summaryrefslogtreecommitdiff
path: root/server/src/leap/soledad
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2017-02-01 19:44:03 -0200
committerKali Kaneko <kali@leap.se>2017-02-09 17:41:43 +0100
commitc9cb1a814b6bfaa40de3c35a590f39d5fb0ce18e (patch)
tree23ea75a31f08df5f0bead3b11d4e68536a32622a /server/src/leap/soledad
parent911695e59ab60d2abaef3013330a6d41283cc733 (diff)
[test] fix session and auth tests
Diffstat (limited to 'server/src/leap/soledad')
-rw-r--r--server/src/leap/soledad/server/auth.py18
-rw-r--r--server/src/leap/soledad/server/session.py3
2 files changed, 7 insertions, 14 deletions
diff --git a/server/src/leap/soledad/server/auth.py b/server/src/leap/soledad/server/auth.py
index bcef2e7c..1f078bff 100644
--- a/server/src/leap/soledad/server/auth.py
+++ b/server/src/leap/soledad/server/auth.py
@@ -67,24 +67,20 @@ class TokenChecker(object):
self._dbs = {}
def _tokens_dbname(self):
- dbname = self.TOKENS_DB_PREFIX + \
- str(int(time.time() / self.TOKENS_DB_EXPIRE))
- return dbname
-
- def _get_db(self, dbname):
- if dbname not in self._dbs:
- self._dbs[dbname] = self._server[dbname]
- return self._dbs[dbname]
-
- def _tokens_db(self):
# the tokens db rotates every 30 days, and the current db name is
# "tokens_NNN", where NNN is the number of seconds since epoch
# divide dby the rotate period in seconds. When rotating, old and
# new tokens db coexist during a certain window of time and valid
# tokens are replicated from the old db to the new one. See:
# https://leap.se/code/issues/6785
+ dbname = self.TOKENS_DB_PREFIX + \
+ str(int(time.time() / self.TOKENS_DB_EXPIRE))
+ return dbname
+
+ def _tokens_db(self):
dbname = self._tokens_dbname()
- db = self._get_db(dbname)
+ with self._server as server:
+ db = server[dbname]
return db
def requestAvatarId(self, credentials):
diff --git a/server/src/leap/soledad/server/session.py b/server/src/leap/soledad/server/session.py
index a56e4e97..a2793bd3 100644
--- a/server/src/leap/soledad/server/session.py
+++ b/server/src/leap/soledad/server/session.py
@@ -104,6 +104,3 @@ class SoledadSession(HTTPAuthSessionWrapper):
# if all checks pass, try to login with credentials
return util.DeferredResource(self._login(credentials))
-
-
-soledadSession = SoledadSession()