From 520221d2bea114ff0191d8e47ce6c085040dfca2 Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 30 Apr 2013 18:29:15 -0300 Subject: Remove unauth requests. --- src/leap/soledad/__init__.py | 2 +- src/leap/soledad/shared_db.py | 25 ++----------------------- src/leap/soledad/tests/test_soledad.py | 17 +++++++++++++---- 3 files changed, 16 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/leap/soledad/__init__.py b/src/leap/soledad/__init__.py index 9e920d68..7ffb6837 100644 --- a/src/leap/soledad/__init__.py +++ b/src/leap/soledad/__init__.py @@ -422,7 +422,7 @@ class Soledad(object): """ events.signal( events.events_pb2.SOLEDAD_DOWNLOADING_KEYS, self._uuid) - doc = self._shared_db().get_doc_unauth(self._uuid_hash()) + doc = self._shared_db().get_doc(self._uuid_hash()) events.signal( events.events_pb2.SOLEDAD_DONE_DOWNLOADING_KEYS, self._uuid) return doc diff --git a/src/leap/soledad/shared_db.py b/src/leap/soledad/shared_db.py index dbb78d97..02ff8667 100644 --- a/src/leap/soledad/shared_db.py +++ b/src/leap/soledad/shared_db.py @@ -54,12 +54,8 @@ class Unauthorized(Exception): class SoledadSharedDatabase(http_database.HTTPDatabase): """ - This is a shared remote database that holds users' encrypted keys. - - An authorization token is attached to every request other than - get_doc_unauth, which has the purpose of retrieving encrypted content from - the shared database without the need to associate user information with - the request. + This is a shared recovery database that enables users to store their + encryption secrets in the server and retrieve them afterwards. """ # TODO: prevent client from messing with the shared DB. # TODO: define and document API. @@ -124,20 +120,3 @@ class SoledadSharedDatabase(http_database.HTTPDatabase): """ http_database.HTTPDatabase.__init__(self, url, document_factory, creds) - - def get_doc_unauth(self, doc_id): - """ - Modified method to allow for unauth request. - - This is the only (public) way to make an unauthenticaded request on - the shared database. - - @param doc_id: The document id. - @type doc_id: str - - @return: The requested document. - @rtype: Document - """ - db = http_database.HTTPDatabase(self._url.geturl(), - document_factory=self._factory) - return db.get_doc(doc_id) diff --git a/src/leap/soledad/tests/test_soledad.py b/src/leap/soledad/tests/test_soledad.py index d096989e..7c941066 100644 --- a/src/leap/soledad/tests/test_soledad.py +++ b/src/leap/soledad/tests/test_soledad.py @@ -105,11 +105,20 @@ class SoledadSharedDBTestCase(BaseSoledadTest): """ Ensure the shared db is queried with the correct doc_id. """ - self._soledad._shared_db = Mock() + + class MockSharedDB(object): + + get_doc = Mock(return_value=None) + + def __call__(self): + return self + + self._soledad._shared_db = MockSharedDB() doc_id = self._soledad._uuid_hash() self._soledad._fetch_keys_from_shared_db() self.assertTrue( - self._soledad._shared_db.get_doc_unauth.assert_called_once(doc_id), + self._soledad._shared_db().get_doc.assert_called_once_with( + doc_id) is None, 'Wrong doc_id when fetching recovery document.') def test__assert_keys_in_shared_db(self): @@ -122,7 +131,7 @@ class SoledadSharedDBTestCase(BaseSoledadTest): class MockSharedDB(object): - get_doc_unauth = Mock(return_value=None) + get_doc = Mock(return_value=None) put_doc = Mock(side_effect=_put_doc_side_effect) def __call__(self): @@ -132,7 +141,7 @@ class SoledadSharedDBTestCase(BaseSoledadTest): doc_id = self._soledad._uuid_hash() self._soledad._assert_keys_in_shared_db() self.assertTrue( - self._soledad._shared_db().get_doc_unauth.assert_called_once_with( + self._soledad._shared_db().get_doc.assert_called_once_with( doc_id) is None, 'Wrong doc_id when fetching recovery document.') self.assertTrue( -- cgit v1.2.3