From c1289d25f25814e1b34bb1ccf3e55b809d0c5f96 Mon Sep 17 00:00:00 2001 From: drebs Date: Wed, 6 Feb 2013 19:14:50 -0200 Subject: Add test scenario for SQLCipher backend using LeapSyncTarget. --- src/leap/soledad/backends/couch.py | 1 + src/leap/soledad/backends/leap_backend.py | 1 - src/leap/soledad/tests/test_sqlcipher.py | 22 ++++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/leap') diff --git a/src/leap/soledad/backends/couch.py b/src/leap/soledad/backends/couch.py index 11122aa8..8757f5af 100644 --- a/src/leap/soledad/backends/couch.py +++ b/src/leap/soledad/backends/couch.py @@ -243,6 +243,7 @@ class CouchSyncTarget(LocalSyncTarget): source_replica_uid, source_replica_generation, source_replica_transaction_id) + class CouchServerState(ServerState): """ Inteface of the WSGI server with the CouchDB backend. diff --git a/src/leap/soledad/backends/leap_backend.py b/src/leap/soledad/backends/leap_backend.py index f9d37e19..41027e50 100644 --- a/src/leap/soledad/backends/leap_backend.py +++ b/src/leap/soledad/backends/leap_backend.py @@ -200,4 +200,3 @@ class LeapSyncTarget(HTTPSyncTarget): res = self._parse_sync_stream(data, return_doc_cb, ensure_callback) data = None return res['new_generation'], res['new_transaction_id'] - diff --git a/src/leap/soledad/tests/test_sqlcipher.py b/src/leap/soledad/tests/test_sqlcipher.py index b964f51e..85b9e486 100644 --- a/src/leap/soledad/tests/test_sqlcipher.py +++ b/src/leap/soledad/tests/test_sqlcipher.py @@ -11,6 +11,7 @@ import threading from u1db import ( errors, query_parser, + sync, ) from u1db.backends.sqlite_backend import SQLitePartialExpandDatabase @@ -28,6 +29,7 @@ from leap.soledad.tests.u1db_tests import test_sqlite_backend from leap.soledad.tests.u1db_tests import test_backends from leap.soledad.tests.u1db_tests import test_open from leap.soledad.tests.u1db_tests import test_sync +from leap.soledad.backends.leap_backend import LeapSyncTarget PASSWORD = '123456' @@ -334,6 +336,26 @@ for name, scenario in SQLCIPHER_SCENARIOS: scenario = dict(scenario) +def sync_via_synchronizer_and_leap(test, db_source, db_target, + trace_hook=None, trace_hook_shallow=None): + if trace_hook: + test.skipTest("full trace hook unsupported over http") + path = test._http_at[db_target] + target = LeapSyncTarget.connect(test.getURL(path)) + if trace_hook_shallow: + target._set_trace_hook_shallow(trace_hook_shallow) + return sync.Synchronizer(db_source, target).sync() + + +sync_scenarios.append(('pyleap', { + 'make_database_for_test': test_sync.make_database_for_http_test, + 'copy_database_for_test': test_sync.copy_database_for_http_test, + 'make_document_for_test': tests.make_document_for_test, + 'make_app_with_state': tests.test_remote_sync_target.make_http_app, + 'do_sync': sync_via_synchronizer_and_leap, +})) + + class SQLCipherDatabaseSyncTests(test_sync.DatabaseSyncTests): scenarios = sync_scenarios -- cgit v1.2.3