summaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'common/src')
-rw-r--r--common/src/leap/soledad/common/__init__.py4
-rw-r--r--common/src/leap/soledad/common/_version.py3
-rw-r--r--common/src/leap/soledad/common/couch/__init__.py16
-rw-r--r--common/src/leap/soledad/common/tests/test_soledad.py36
-rw-r--r--common/src/leap/soledad/common/tests/test_sync_deferred.py4
-rw-r--r--common/src/leap/soledad/common/tests/util.py7
6 files changed, 43 insertions, 27 deletions
diff --git a/common/src/leap/soledad/common/__init__.py b/common/src/leap/soledad/common/__init__.py
index 1ba6ab89..d7f6929c 100644
--- a/common/src/leap/soledad/common/__init__.py
+++ b/common/src/leap/soledad/common/__init__.py
@@ -47,3 +47,7 @@ __all__ = [
"soledad_assert_type",
"__version__",
]
+
+from ._version import get_versions
+__version__ = get_versions()['version']
+del get_versions
diff --git a/common/src/leap/soledad/common/_version.py b/common/src/leap/soledad/common/_version.py
index 889fba38..23749c7c 100644
--- a/common/src/leap/soledad/common/_version.py
+++ b/common/src/leap/soledad/common/_version.py
@@ -1,4 +1,3 @@
-
# This file was generated by the `freeze_debianver` command in setup.py
# Using 'versioneer.py' (0.7+) from
# revision-control system data, or from the parent directory name of an
@@ -10,4 +9,4 @@ version_full = 'aa6a34bc4ac5962dacaa5908778e444fe5aae3d7'
def get_versions(default={}, verbose=False):
- return {'version': version_version, 'full': version_full}
+ return {'version': version_version, 'full': version_full}
diff --git a/common/src/leap/soledad/common/couch/__init__.py b/common/src/leap/soledad/common/couch/__init__.py
index dae460cb..18ed8a19 100644
--- a/common/src/leap/soledad/common/couch/__init__.py
+++ b/common/src/leap/soledad/common/couch/__init__.py
@@ -123,6 +123,8 @@ class CouchDatabase(object):
:type replica_uid: str
:param ensure_ddocs: Ensure that the design docs exist on server.
:type ensure_ddocs: bool
+ :param database_security: security rules as CouchDB security doc
+ :type database_security: dict
:return: the database instance
:rtype: SoledadBackend
@@ -149,6 +151,16 @@ class CouchDatabase(object):
def __init__(self, url, dbname, ensure_ddocs=True,
database_security=None):
+ """
+ :param url: Couch server URL with necessary credentials
+ :type url: string
+ :param dbname: Couch database name
+ :type dbname: string
+ :param ensure_ddocs: Ensure that the design docs exist on server.
+ :type ensure_ddocs: bool
+ :param database_security: security rules as CouchDB security doc
+ :type database_security: dict
+ """
self._session = Session(timeout=COUCH_TIMEOUT)
self._url = url
self._dbname = dbname
@@ -218,8 +230,8 @@ class CouchDatabase(object):
This is achieved by creating a _security design document, see:
http://docs.couchdb.org/en/latest/api/database/security.html
- :param database_security: security configuration parsed from conf file
- :type cache: dict
+ :param security_config: security configuration parsed from conf file
+ :type security_config: dict
"""
security_config = security_config or {}
security = self._database.resource.get_json('_security')[2]
diff --git a/common/src/leap/soledad/common/tests/test_soledad.py b/common/src/leap/soledad/common/tests/test_soledad.py
index 85d6734e..36c4003c 100644
--- a/common/src/leap/soledad/common/tests/test_soledad.py
+++ b/common/src/leap/soledad/common/tests/test_soledad.py
@@ -249,55 +249,51 @@ class SoledadSignalingTestCase(BaseSoledadTest):
# get a fresh instance so it emits all bootstrap signals
sol = self._soledad_instance(
secrets_path='alternative_stage3.json',
- local_db_path='alternative_stage3.u1db')
+ local_db_path='alternative_stage3.u1db',
+ userid=ADDRESS)
# reverse call order so we can verify in the order the signals were
# expected
soledad.client.secrets.events.emit_async.mock_calls.reverse()
soledad.client.secrets.events.emit_async.call_args = \
soledad.client.secrets.events.emit_async.call_args_list[0]
soledad.client.secrets.events.emit_async.call_args_list.reverse()
+
+ user_data = {'userid': ADDRESS, 'uuid': ADDRESS}
+
# downloading keys signals
soledad.client.secrets.events.emit_async.assert_called_with(
- catalog.SOLEDAD_DOWNLOADING_KEYS,
- ADDRESS,
+ catalog.SOLEDAD_DOWNLOADING_KEYS, user_data
)
self._pop_mock_call(soledad.client.secrets.events.emit_async)
soledad.client.secrets.events.emit_async.assert_called_with(
- catalog.SOLEDAD_DONE_DOWNLOADING_KEYS,
- ADDRESS,
+ catalog.SOLEDAD_DONE_DOWNLOADING_KEYS, user_data
)
# creating keys signals
self._pop_mock_call(soledad.client.secrets.events.emit_async)
soledad.client.secrets.events.emit_async.assert_called_with(
- catalog.SOLEDAD_CREATING_KEYS,
- ADDRESS,
+ catalog.SOLEDAD_CREATING_KEYS, user_data
)
self._pop_mock_call(soledad.client.secrets.events.emit_async)
soledad.client.secrets.events.emit_async.assert_called_with(
- catalog.SOLEDAD_DONE_CREATING_KEYS,
- ADDRESS,
+ catalog.SOLEDAD_DONE_CREATING_KEYS, user_data
)
# downloading once more (inside _put_keys_in_shared_db)
self._pop_mock_call(soledad.client.secrets.events.emit_async)
soledad.client.secrets.events.emit_async.assert_called_with(
- catalog.SOLEDAD_DOWNLOADING_KEYS,
- ADDRESS,
+ catalog.SOLEDAD_DOWNLOADING_KEYS, user_data
)
self._pop_mock_call(soledad.client.secrets.events.emit_async)
soledad.client.secrets.events.emit_async.assert_called_with(
- catalog.SOLEDAD_DONE_DOWNLOADING_KEYS,
- ADDRESS,
+ catalog.SOLEDAD_DONE_DOWNLOADING_KEYS, user_data
)
# uploading keys signals
self._pop_mock_call(soledad.client.secrets.events.emit_async)
soledad.client.secrets.events.emit_async.assert_called_with(
- catalog.SOLEDAD_UPLOADING_KEYS,
- ADDRESS,
+ catalog.SOLEDAD_UPLOADING_KEYS, user_data
)
self._pop_mock_call(soledad.client.secrets.events.emit_async)
soledad.client.secrets.events.emit_async.assert_called_with(
- catalog.SOLEDAD_DONE_UPLOADING_KEYS,
- ADDRESS,
+ catalog.SOLEDAD_DONE_UPLOADING_KEYS, user_data
)
# assert db was locked and unlocked
sol.shared_db.lock.assert_called_with()
@@ -332,12 +328,12 @@ class SoledadSignalingTestCase(BaseSoledadTest):
# assert download keys signals
soledad.client.secrets.events.emit_async.assert_called_with(
catalog.SOLEDAD_DOWNLOADING_KEYS,
- ADDRESS,
+ {'userid': ADDRESS, 'uuid': ADDRESS}
)
self._pop_mock_call(soledad.client.secrets.events.emit_async)
soledad.client.secrets.events.emit_async.assert_called_with(
catalog.SOLEDAD_DONE_DOWNLOADING_KEYS,
- ADDRESS,
+ {'userid': ADDRESS, 'uuid': ADDRESS},
)
sol.close()
@@ -371,6 +367,6 @@ class SoledadSignalingTestCase(BaseSoledadTest):
# assert the signal has been emitted
soledad.client.events.emit_async.assert_called_with(
catalog.SOLEDAD_DONE_DATA_SYNC,
- ADDRESS,
+ {'userid': ADDRESS, 'uuid': ADDRESS},
)
sol.close()
diff --git a/common/src/leap/soledad/common/tests/test_sync_deferred.py b/common/src/leap/soledad/common/tests/test_sync_deferred.py
index 90b00670..c62bd156 100644
--- a/common/src/leap/soledad/common/tests/test_sync_deferred.py
+++ b/common/src/leap/soledad/common/tests/test_sync_deferred.py
@@ -148,6 +148,8 @@ class TestSoledadDbSyncDeferredEncDecr(
replica_uid = self._soledad._dbpool.replica_uid
sync_db = self._soledad._sync_db
sync_enc_pool = self._soledad._sync_enc_pool
+ dbsyncer = self._soledad._dbsyncer # Soledad.sync uses the dbsyncer
+
target = soledad_sync_target(
self, self.db2._dbname,
source_replica_uid=replica_uid,
@@ -155,7 +157,7 @@ class TestSoledadDbSyncDeferredEncDecr(
sync_enc_pool=sync_enc_pool)
self.addCleanup(target.close)
return sync.SoledadSynchronizer(
- self.db1,
+ dbsyncer,
target).sync(defer_decryption=True)
def wait_for_sync(self):
diff --git a/common/src/leap/soledad/common/tests/util.py b/common/src/leap/soledad/common/tests/util.py
index f7f9ebd0..d4510686 100644
--- a/common/src/leap/soledad/common/tests/util.py
+++ b/common/src/leap/soledad/common/tests/util.py
@@ -245,6 +245,7 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest):
# each local db.
self.rand_prefix = ''.join(
map(lambda x: random.choice(string.ascii_letters), range(6)))
+
# initialize soledad by hand so we can control keys
# XXX check if this soledad is actually used
self._soledad = self._soledad_instance(
@@ -285,7 +286,8 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest):
server_url='https://127.0.0.1/',
cert_file=None,
shared_db_class=None,
- auth_token='auth-token'):
+ auth_token='auth-token',
+ userid=ADDRESS):
def _put_doc_side_effect(doc):
self._doc_put = doc
@@ -307,7 +309,8 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest):
cert_file=cert_file,
defer_encryption=self.defer_sync_encryption,
shared_db=MockSharedDB(),
- auth_token=auth_token)
+ auth_token=auth_token,
+ userid=userid)
self.addCleanup(soledad.close)
return soledad