summaryrefslogtreecommitdiff
path: root/soledad/src
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-07-23 23:12:27 -0300
committerdrebs <drebs@leap.se>2013-07-24 18:22:11 -0300
commit7feefdc283d896fdccee8067d867c14f674a912c (patch)
treed290f58447cfbcd9ccd8956cfea00ecf096d502a /soledad/src
parentb5f9e0ce679c87075d04db0645f18281feeeb01d (diff)
Refactor authentication to make it adaptable.
Diffstat (limited to 'soledad/src')
-rw-r--r--soledad/src/leap/soledad/tests/test_server.py11
-rw-r--r--soledad/src/leap/soledad/tests/test_target.py20
2 files changed, 15 insertions, 16 deletions
diff --git a/soledad/src/leap/soledad/tests/test_server.py b/soledad/src/leap/soledad/tests/test_server.py
index ba01a391..24cd68dc 100644
--- a/soledad/src/leap/soledad/tests/test_server.py
+++ b/soledad/src/leap/soledad/tests/test_server.py
@@ -27,9 +27,8 @@ import mock
from leap.soledad import Soledad
-from leap.soledad_server import (
- URLToAuth,
-)
+from leap.soledad_server import SoledadApp
+from leap.soledad_server.auth import URLToAuthorization
from leap.soledad_server.couch import (
CouchServerState,
CouchDatabase,
@@ -87,7 +86,8 @@ class ServerAuthorizationTestCase(BaseLeapTest):
/user-db/sync-from/{source} | GET, PUT, POST
"""
uuid = 'myuuid'
- authmap = URLToAuth(uuid)
+ authmap = URLToAuthorization(
+ uuid, SoledadApp.SHARED_DB_NAME, SoledadApp.USER_DB_PREFIX)
dbname = authmap._uuid_dbname(uuid)
# test global auth
self.assertTrue(
@@ -202,7 +202,8 @@ class ServerAuthorizationTestCase(BaseLeapTest):
Test if authorization fails for a wrong dbname.
"""
uuid = 'myuuid'
- authmap = URLToAuth(uuid)
+ authmap = URLToAuthorization(
+ uuid, SoledadApp.SHARED_DB_NAME, SoledadApp.USER_DB_PREFIX)
dbname = 'somedb'
# test wrong-db database resource auth
self.assertFalse(
diff --git a/soledad/src/leap/soledad/tests/test_target.py b/soledad/src/leap/soledad/tests/test_target.py
index 73c9fe68..ca2878a5 100644
--- a/soledad/src/leap/soledad/tests/test_target.py
+++ b/soledad/src/leap/soledad/tests/test_target.py
@@ -40,10 +40,8 @@ from leap.soledad import (
auth,
)
from leap.soledad.document import SoledadDocument
-from leap.soledad_server import (
- SoledadApp,
- SoledadAuthMiddleware,
-)
+from leap.soledad_server import SoledadApp
+from leap.soledad_server.auth import SoledadTokenAuthMiddleware
from leap.soledad.tests import u1db_tests as tests
@@ -74,18 +72,18 @@ def make_soledad_app(state):
def make_token_soledad_app(state):
app = SoledadApp(state)
- def verify_token(environ, uuid, token):
- if uuid == 'user-uuid' and token == 'auth-token':
+ def _verify_authentication_data(uuid, auth_data):
+ if uuid == 'user-uuid' and auth_data == 'auth-token':
return True
return False
# we test for action authorization in leap.soledad.tests.test_server
- def verify_action(environ, uuid):
+ def _verify_authorization(uuid, environ):
return True
- application = SoledadAuthMiddleware(app)
- application.verify_token = verify_token
- application.verify_action = verify_action
+ application = SoledadTokenAuthMiddleware(app)
+ application._verify_authentication_data = _verify_authentication_data
+ application._verify_authorization = _verify_authorization
return application
@@ -190,7 +188,7 @@ class TestSoledadClientBase(test_http_client.TestHTTPClientBase):
return res
# mime solead application here.
if '/token' in environ['PATH_INFO']:
- auth = environ.get(SoledadAuthMiddleware.HTTP_AUTH_KEY)
+ auth = environ.get(SoledadTokenAuthMiddleware.HTTP_AUTH_KEY)
if not auth:
start_response("401 Unauthorized",
[('Content-Type', 'application/json')])