From 75208477a2f1634664b80b8501818e5a905aa0f3 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 22 Sep 2016 01:42:26 -0400 Subject: [tests] adapt tests --- testing/test_soledad/util.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'testing/test_soledad/util.py') diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py index d53f6cda..bde0b1b7 100644 --- a/testing/test_soledad/util.py +++ b/testing/test_soledad/util.py @@ -15,12 +15,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - """ Utilities used by multiple test suites. """ - import os import random import string @@ -45,14 +43,13 @@ from leap.soledad.common.document import SoledadDocument from leap.soledad.common.couch import CouchDatabase from leap.soledad.common.couch.state import CouchServerState -from leap.soledad.common.crypto import ENC_SCHEME_KEY from leap.soledad.client import Soledad from leap.soledad.client import http_target from leap.soledad.client import auth -from leap.soledad.client.crypto import decrypt_doc_dict from leap.soledad.client.sqlcipher import SQLCipherDatabase from leap.soledad.client.sqlcipher import SQLCipherOptions +from leap.soledad.client._crypto import is_symmetrically_encrypted from leap.soledad.server import SoledadApp from leap.soledad.server.auth import SoledadTokenAuthMiddleware @@ -212,6 +209,7 @@ def soledad_sync_target( # redefine the base leap test class so it inherits from twisted trial's # TestCase. This is needed so trial knows that it has to manage a reactor and # wait for deferreds returned by tests to be fired. + BaseLeapTest = type( 'BaseLeapTest', (unittest.TestCase,), dict(BaseLeapTest.__dict__)) @@ -311,6 +309,7 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): self.addCleanup(soledad.close) return soledad + @pytest.inlineCallbacks def assertGetEncryptedDoc( self, db, doc_id, doc_rev, content, has_conflicts): """ @@ -320,13 +319,9 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): has_conflicts=has_conflicts) doc = db.get_doc(doc_id) - if ENC_SCHEME_KEY in doc.content: - # XXX check for SYM_KEY too - key = self._soledad._crypto.doc_passphrase(doc.doc_id) - secret = self._soledad._crypto.secret - decrypted = decrypt_doc_dict( - doc.content, doc.doc_id, doc.rev, - key, secret) + if is_symmetrically_encrypted(doc.content['raw']): + crypt = self._soledad._crypto + decrypted = yield crypt.decrypt_doc(doc) doc.set_json(decrypted) self.assertEqual(exp_doc.doc_id, doc.doc_id) self.assertEqual(exp_doc.rev, doc.rev) -- cgit v1.2.3 From 69958161af00958b1d92ab6153a591aa89199e35 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 22 Sep 2016 03:08:20 -0400 Subject: [refactor] remove lingering refs to syncdb --- testing/test_soledad/util.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'testing/test_soledad/util.py') diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py index bde0b1b7..b1965aa6 100644 --- a/testing/test_soledad/util.py +++ b/testing/test_soledad/util.py @@ -190,8 +190,7 @@ class MockedSharedDBTest(object): def soledad_sync_target( - test, path, source_replica_uid=uuid4().hex, - sync_db=None, sync_enc_pool=None): + test, path, source_replica_uid=uuid4().hex): creds = {'token': { 'uuid': 'user-uuid', 'token': 'auth-token', @@ -201,9 +200,7 @@ def soledad_sync_target( source_replica_uid, creds, test._soledad._crypto, - None, # cert_file - sync_db=sync_db, - sync_enc_pool=sync_enc_pool) + None) # cert_file # redefine the base leap test class so it inherits from twisted trial's -- cgit v1.2.3 From 781984f3485b1fd479d09278a665f599c1bd10dc Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 22 Sep 2016 20:37:23 -0300 Subject: [test] fix test and remove leftovers defer_encryption --- testing/test_soledad/util.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'testing/test_soledad/util.py') diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py index b1965aa6..f44ce166 100644 --- a/testing/test_soledad/util.py +++ b/testing/test_soledad/util.py @@ -216,7 +216,6 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): """ Instantiates Soledad for usage in tests. """ - defer_sync_encryption = False @pytest.mark.usefixtures("method_tmpdir") def setUp(self): @@ -300,7 +299,6 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): self.tempdir, prefix, local_db_path), server_url=server_url, # Soledad will fail if not given an url cert_file=cert_file, - defer_encryption=self.defer_sync_encryption, shared_db=MockSharedDB(), auth_token=auth_token) self.addCleanup(soledad.close) -- cgit v1.2.3 From 3e74de6208c22643b1c063b70d22d352c0409703 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 17 Nov 2016 22:11:54 -0200 Subject: [test] remove unneeded setting of environment variables --- testing/test_soledad/util.py | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'testing/test_soledad/util.py') diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py index f44ce166..4a705396 100644 --- a/testing/test_soledad/util.py +++ b/testing/test_soledad/util.py @@ -223,14 +223,7 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): # repeat it here because twisted.trial does not work with # setUpClass/tearDownClass. - self.old_path = os.environ['PATH'] - self.old_home = os.environ['HOME'] self.home = self.tempdir - bin_tdir = os.path.join( - self.tempdir, - 'bin') - os.environ["PATH"] = bin_tdir - os.environ["HOME"] = self.tempdir # config info self.db1_file = os.path.join(self.tempdir, "db1.u1db") @@ -257,10 +250,6 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): self._db2.close() self._soledad.close() - # restore paths - os.environ["PATH"] = self.old_path - os.environ["HOME"] = self.old_home - def _delete_temporary_dirs(): # XXX should not access "private" attrs for f in [self._soledad.local_db_path, -- cgit v1.2.3 From 1804b5f74a4efa6b25c06fe353ac960fd42e4fb6 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Sat, 19 Nov 2016 04:13:52 -0300 Subject: [tests] migrate pytest to trial test_deprecated_crypto was using pytest, which unfortunately doesnt work when mixed with trial. Migrated back. Also added norecursedirs option back, as it is necessary for parallel testing mode. --- testing/test_soledad/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testing/test_soledad/util.py') diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py index 4a705396..57f8199b 100644 --- a/testing/test_soledad/util.py +++ b/testing/test_soledad/util.py @@ -56,7 +56,7 @@ from leap.soledad.server.auth import SoledadTokenAuthMiddleware PASSWORD = '123456' -ADDRESS = 'leap@leap.se' +ADDRESS = 'user-1234' def make_local_db_and_target(test): -- cgit v1.2.3