summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/changes/refactor_improve_http_target3
-rw-r--r--common/changes/refactor_couch2
-rw-r--r--common/src/leap/soledad/common/tests/test_couch_operations_atomicity.py6
-rw-r--r--common/src/leap/soledad/common/tests/test_server.py18
-rw-r--r--common/src/leap/soledad/common/tests/test_sqlcipher_sync.py4
-rw-r--r--common/src/leap/soledad/common/tests/test_sync.py8
-rw-r--r--common/src/leap/soledad/common/tests/test_sync_deferred.py2
-rw-r--r--common/src/leap/soledad/common/tests/test_sync_mutex.py6
-rw-r--r--common/src/leap/soledad/common/tests/test_sync_target.py6
-rw-r--r--common/src/leap/soledad/common/tests/util.py6
-rw-r--r--server/changes/bug_badrequest1
11 files changed, 34 insertions, 28 deletions
diff --git a/client/changes/refactor_improve_http_target b/client/changes/refactor_improve_http_target
new file mode 100644
index 00000000..a8fe5f60
--- /dev/null
+++ b/client/changes/refactor_improve_http_target
@@ -0,0 +1,3 @@
+ o Split http_target into 4 modules, separating those responsibilities.
+ o Refactor details of making an HTTP request body and headers out of the
+ send/fetch logic. This also makes it easier to enable batching.
diff --git a/common/changes/refactor_couch b/common/changes/refactor_couch
new file mode 100644
index 00000000..2f36b97f
--- /dev/null
+++ b/common/changes/refactor_couch
@@ -0,0 +1,2 @@
+ o Refactor couch.py to separate persistence from logic while saving uploaded
+ documents. Also simplify logic while checking for conflicts.
diff --git a/common/src/leap/soledad/common/tests/test_couch_operations_atomicity.py b/common/src/leap/soledad/common/tests/test_couch_operations_atomicity.py
index c488822e..0a06cc39 100644
--- a/common/src/leap/soledad/common/tests/test_couch_operations_atomicity.py
+++ b/common/src/leap/soledad/common/tests/test_couch_operations_atomicity.py
@@ -83,15 +83,15 @@ class CouchAtomicityTestCase(CouchDBTestCase, TestCaseWithServer):
return soledad
def make_app(self):
- self.request_state = CouchServerState(self._couch_url)
+ self.request_state = CouchServerState(self.couch_url)
return self.make_app_after_state(self.request_state)
def setUp(self):
TestCaseWithServer.setUp(self)
CouchDBTestCase.setUp(self)
- self._couch_url = 'http://localhost:' + str(self.wrapper.port)
+ self.couch_url = 'http://localhost:' + str(self.wrapper.port)
self.db = CouchDatabase.open_database(
- urljoin(self._couch_url, 'user-user-uuid'),
+ urljoin(self.couch_url, 'user-user-uuid'),
create=True,
replica_uid='replica',
ensure_ddocs=True)
diff --git a/common/src/leap/soledad/common/tests/test_server.py b/common/src/leap/soledad/common/tests/test_server.py
index 5ffa2a63..5e8e5f90 100644
--- a/common/src/leap/soledad/common/tests/test_server.py
+++ b/common/src/leap/soledad/common/tests/test_server.py
@@ -50,7 +50,7 @@ from leap.soledad.server.auth import URLToAuthorization
def _couch_ensure_database(self, dbname):
db = CouchDatabase.open_database(
- self._couch_url + '/' + dbname,
+ self.couch_url + '/' + dbname,
create=True,
ensure_ddocs=True)
return db, db._replica_uid
@@ -325,7 +325,7 @@ class EncryptedSyncTestCase(
shared_db=self.get_default_shared_mock(_put_doc_side_effect))
def make_app(self):
- self.request_state = CouchServerState(self._couch_url)
+ self.request_state = CouchServerState(self.couch_url)
return self.make_app_with_state(self.request_state)
def setUp(self):
@@ -333,7 +333,7 @@ class EncryptedSyncTestCase(
# dependencies.
# XXX explain better
CouchDBTestCase.setUp(self)
- self._couch_url = 'http://localhost:' + str(self.wrapper.port)
+ self.couch_url = 'http://localhost:' + str(self.wrapper.port)
self.tempdir = tempfile.mkdtemp(prefix="leap_tests-")
TestCaseWithServer.setUp(self)
@@ -368,7 +368,7 @@ class EncryptedSyncTestCase(
# ensure remote db exists before syncing
db = CouchDatabase.open_database(
- urljoin(self._couch_url, 'user-' + user),
+ urljoin(self.couch_url, 'user-' + user),
create=True,
ensure_ddocs=True)
@@ -494,24 +494,24 @@ class LockResourceTestCase(
# dependencies.
# XXX explain better
CouchDBTestCase.setUp(self)
- self._couch_url = 'http://localhost:' + str(self.wrapper.port)
+ self.couch_url = 'http://localhost:' + str(self.wrapper.port)
self.tempdir = tempfile.mkdtemp(prefix="leap_tests-")
TestCaseWithServer.setUp(self)
# create the databases
CouchDatabase.open_database(
- urljoin(self._couch_url, 'shared'),
+ urljoin(self.couch_url, 'shared'),
create=True,
ensure_ddocs=True)
CouchDatabase.open_database(
- urljoin(self._couch_url, 'tokens'),
+ urljoin(self.couch_url, 'tokens'),
create=True,
ensure_ddocs=True)
- self._state = CouchServerState(self._couch_url)
+ self._state = CouchServerState(self.couch_url)
def tearDown(self):
# delete remote database
db = CouchDatabase.open_database(
- urljoin(self._couch_url, 'shared'),
+ urljoin(self.couch_url, 'shared'),
create=True,
ensure_ddocs=True)
db.delete_database()
diff --git a/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py b/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py
index c57d6f61..af2d0e2a 100644
--- a/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py
+++ b/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py
@@ -733,7 +733,7 @@ def _make_local_db_and_token_http_target(test, path='test'):
test.startTwistedServer()
# ensure remote db exists before syncing
db = couch.CouchDatabase.open_database(
- urljoin(test._couch_url, 'test'),
+ urljoin(test.couch_url, 'test'),
create=True,
replica_uid='test',
ensure_ddocs=True)
@@ -790,7 +790,7 @@ class SQLCipherSyncTargetTests(
(doc.doc_id, doc.rev, doc.get_json(), gen, trans_id))
def make_app(self):
- self.request_state = couch.CouchServerState(self._couch_url)
+ self.request_state = couch.CouchServerState(self.couch_url)
return self.make_app_with_state(self.request_state)
def set_trace_hook(self, callback, shallow=False):
diff --git a/common/src/leap/soledad/common/tests/test_sync.py b/common/src/leap/soledad/common/tests/test_sync.py
index 14152370..61f3879f 100644
--- a/common/src/leap/soledad/common/tests/test_sync.py
+++ b/common/src/leap/soledad/common/tests/test_sync.py
@@ -56,14 +56,14 @@ class InterruptableSyncTestCase(
sync_target = soledad_sync_target
def make_app(self):
- self.request_state = couch.CouchServerState(self._couch_url)
+ self.request_state = couch.CouchServerState(self.couch_url)
return self.make_app_with_state(self.request_state)
def setUp(self):
TestCaseWithServer.setUp(self)
CouchDBTestCase.setUp(self)
self.tempdir = tempfile.mkdtemp(prefix="leap_tests-")
- self._couch_url = 'http://localhost:' + str(self.wrapper.port)
+ self.couch_url = 'http://localhost:' + str(self.wrapper.port)
def tearDown(self):
CouchDBTestCase.tearDown(self)
@@ -103,7 +103,7 @@ class InterruptableSyncTestCase(
# ensure remote db exists before syncing
db = couch.CouchDatabase.open_database(
- urljoin(self._couch_url, 'user-user-uuid'),
+ urljoin(self.couch_url, 'user-user-uuid'),
create=True,
ensure_ddocs=True)
@@ -167,7 +167,7 @@ class TestSoledadDbSync(
token = False
def make_app(self):
- self.request_state = couch.CouchServerState(self._couch_url)
+ self.request_state = couch.CouchServerState(self.couch_url)
return self.make_app_with_state(self.request_state)
def setUp(self):
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 ffb8a4ae..0065413a 100644
--- a/common/src/leap/soledad/common/tests/test_sync_deferred.py
+++ b/common/src/leap/soledad/common/tests/test_sync_deferred.py
@@ -129,7 +129,7 @@ class TestSoledadDbSyncDeferredEncDecr(
token = True
def make_app(self):
- self.request_state = couch.CouchServerState(self._couch_url)
+ self.request_state = couch.CouchServerState(self.couch_url)
return self.make_app_with_state(self.request_state)
def setUp(self):
diff --git a/common/src/leap/soledad/common/tests/test_sync_mutex.py b/common/src/leap/soledad/common/tests/test_sync_mutex.py
index a904a940..aa46d5b7 100644
--- a/common/src/leap/soledad/common/tests/test_sync_mutex.py
+++ b/common/src/leap/soledad/common/tests/test_sync_mutex.py
@@ -84,14 +84,14 @@ class TestSyncMutex(
sync_target = soledad_sync_target
def make_app(self):
- self.request_state = couch.CouchServerState(self._couch_url)
+ self.request_state = couch.CouchServerState(self.couch_url)
return self.make_app_with_state(self.request_state)
def setUp(self):
TestCaseWithServer.setUp(self)
CouchDBTestCase.setUp(self)
self.tempdir = tempfile.mkdtemp(prefix="leap_tests-")
- self._couch_url = 'http://localhost:' + str(self.wrapper.port)
+ self.couch_url = 'http://localhost:' + str(self.wrapper.port)
def tearDown(self):
CouchDBTestCase.tearDown(self)
@@ -103,7 +103,7 @@ class TestSyncMutex(
# ensure remote db exists before syncing
db = couch.CouchDatabase.open_database(
- urljoin(self._couch_url, 'user-user-uuid'),
+ urljoin(self.couch_url, 'user-user-uuid'),
create=True,
ensure_ddocs=True)
diff --git a/common/src/leap/soledad/common/tests/test_sync_target.py b/common/src/leap/soledad/common/tests/test_sync_target.py
index d855fb52..79c350cd 100644
--- a/common/src/leap/soledad/common/tests/test_sync_target.py
+++ b/common/src/leap/soledad/common/tests/test_sync_target.py
@@ -63,13 +63,13 @@ class TestSoledadParseReceivedDocResponse(SoledadWithCouchServerMixin):
def setUp(self):
SoledadWithCouchServerMixin.setUp(self)
- self._couch_url = 'http://localhost:' + str(self.wrapper.port)
+ self.couch_url = 'http://localhost:' + str(self.wrapper.port)
creds = {'token': {
'uuid': 'user-uuid',
'token': 'auth-token',
}}
self.target = target.SoledadHTTPSyncTarget(
- self._couch_url,
+ self.couch_url,
uuid4().hex,
creds,
self._soledad._crypto,
@@ -819,7 +819,7 @@ class TestSoledadDbSync(
token = False
def make_app(self):
- self.request_state = couch.CouchServerState(self._couch_url)
+ self.request_state = couch.CouchServerState(self.couch_url)
return self.make_app_with_state(self.request_state)
def setUp(self):
diff --git a/common/src/leap/soledad/common/tests/util.py b/common/src/leap/soledad/common/tests/util.py
index daa9c558..2190eeaa 100644
--- a/common/src/leap/soledad/common/tests/util.py
+++ b/common/src/leap/soledad/common/tests/util.py
@@ -486,7 +486,7 @@ class CouchServerStateForTests(CouchServerState):
def _create_database(self, dbname):
return CouchDatabase.open_database(
- urljoin(self._couch_url, dbname),
+ urljoin(self.couch_url, dbname),
True,
replica_uid=dbname,
ensure_ddocs=True)
@@ -506,7 +506,7 @@ class SoledadWithCouchServerMixin(
main_test_class = getattr(self, 'main_test_class', None)
if main_test_class is not None:
main_test_class.setUp(self)
- self._couch_url = 'http://localhost:%d' % self.wrapper.port
+ self.couch_url = 'http://localhost:%d' % self.wrapper.port
def tearDown(self):
main_test_class = getattr(self, 'main_test_class', None)
@@ -514,7 +514,7 @@ class SoledadWithCouchServerMixin(
main_test_class.tearDown(self)
# delete the test database
try:
- db = CouchDatabase(self._couch_url, 'test')
+ db = CouchDatabase(self.couch_url, 'test')
db.delete_database()
except DatabaseDoesNotExist:
pass
diff --git a/server/changes/bug_badrequest b/server/changes/bug_badrequest
new file mode 100644
index 00000000..74901476
--- /dev/null
+++ b/server/changes/bug_badrequest
@@ -0,0 +1 @@
+ o Fix a bug where BadRequest could be raised after everything was persisted