diff options
Diffstat (limited to 'src/leap/soledad/tests')
-rw-r--r-- | src/leap/soledad/tests/__init__.py | 7 | ||||
-rw-r--r-- | src/leap/soledad/tests/test_couch.py | 1 | ||||
-rw-r--r-- | src/leap/soledad/tests/test_crypto.py | 22 | ||||
-rw-r--r-- | src/leap/soledad/tests/test_leap_backend.py | 6 | ||||
-rw-r--r-- | src/leap/soledad/tests/test_soledad.py | 3 |
5 files changed, 18 insertions, 21 deletions
diff --git a/src/leap/soledad/tests/__init__.py b/src/leap/soledad/tests/__init__.py index 7f1e9f28..396b2775 100644 --- a/src/leap/soledad/tests/__init__.py +++ b/src/leap/soledad/tests/__init__.py @@ -4,7 +4,7 @@ Tests to make sure Soledad provides U1DB functionality and more. import u1db from leap.soledad import Soledad -from leap.soledad.util import GPGWrapper +from leap.soledad.crypto import SoledadCrypto from leap.soledad.backends.leap_backend import LeapDocument from leap.common.testing.basetest import BaseLeapTest @@ -33,8 +33,8 @@ class BaseSoledadTest(BaseLeapTest): # initialize soledad by hand so we can control keys self._soledad = self._soledad_instance(user=self.email) self._soledad._init_dirs() - self._soledad._gpg = GPGWrapper(gnupghome=self.gnupg_home) #self._soledad._gpg.import_keys(PUBLIC_KEY) + self._soledad._crypto = SoledadCrypto(self.gnupg_home) if not self._soledad._has_symkey(): self._soledad._gen_symkey() self._soledad._load_symkey() @@ -57,9 +57,6 @@ class BaseSoledadTest(BaseLeapTest): local_db_path=self.tempdir+prefix+local_db_path, bootstrap=bootstrap) - def _gpgwrapper_instance(self): - return GPGWrapper(gnupghome="%s/gnupg" % self.tempdir) - # Key material for testing KEY_FINGERPRINT = "E36E738D69173C13D709E44F2F455E2824D18DDF" diff --git a/src/leap/soledad/tests/test_couch.py b/src/leap/soledad/tests/test_couch.py index a6171dd8..008c3ca4 100644 --- a/src/leap/soledad/tests/test_couch.py +++ b/src/leap/soledad/tests/test_couch.py @@ -60,7 +60,6 @@ class CouchDBWrapper(object): os.mkdir(os.path.join(self.tempdir, 'lib')) os.mkdir(os.path.join(self.tempdir, 'log')) args = ['couchdb', '-n', '-a', confPath] - print args #null = open('/dev/null', 'w') self.process = subprocess.Popen( args, env=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, diff --git a/src/leap/soledad/tests/test_crypto.py b/src/leap/soledad/tests/test_crypto.py index ee3b6c89..f762437a 100644 --- a/src/leap/soledad/tests/test_crypto.py +++ b/src/leap/soledad/tests/test_crypto.py @@ -32,7 +32,7 @@ from leap.soledad.tests import ( PRIVATE_KEY, ) from leap.soledad import KeyAlreadyExists -from leap.soledad.util import GPGWrapper +from leap.soledad.crypto import SoledadCrypto try: import simplejson as json @@ -49,11 +49,11 @@ class EncryptedSyncTestCase(BaseSoledadTest): """ Test getting and setting encrypted content. """ - doc1 = LeapDocument(soledad=self._soledad) + doc1 = LeapDocument(crypto=self._soledad._crypto) doc1.content = {'key': 'val'} doc2 = LeapDocument(doc_id=doc1.doc_id, encrypted_json=doc1.get_encrypted_json(), - soledad=self._soledad) + crypto=self._soledad._crypto) res1 = doc1.get_json() res2 = doc2.get_json() self.assertEqual(res1, res2, 'incorrect document encryption') @@ -62,12 +62,12 @@ class EncryptedSyncTestCase(BaseSoledadTest): """ Test for successful symmetric encryption. """ - doc1 = LeapDocument(soledad=self._soledad) + doc1 = LeapDocument(crypto=self._soledad._crypto) doc1.content = {'key': 'val'} enc_json = json.loads(doc1.get_encrypted_json())['_encrypted_json'] self.assertEqual( True, - self._soledad._gpg.is_encrypted_sym(enc_json), + self._soledad._crypto.is_encrypted_sym(enc_json), "could not encrypt with passphrase.") @@ -87,12 +87,12 @@ class RecoveryDocumentTestCase(BaseSoledadTest): def test_export_recovery_document_crypt(self): rd = self._soledad.export_recovery_document('123456') self.assertEqual(True, - self._soledad._gpg.is_encrypted_sym(rd)) + self._soledad._crypto.is_encrypted_sym(rd)) data = { 'user': self._soledad._user, 'symkey': self._soledad._symkey, } - raw_data = json.loads(str(self._soledad._gpg.decrypt( + raw_data = json.loads(str(self._soledad._crypto.decrypt( rd, passphrase='123456'))) self.assertEqual( @@ -111,7 +111,7 @@ class RecoveryDocumentTestCase(BaseSoledadTest): gnupg_home = self.gnupg_home = "%s/gnupg2" % self.tempdir s = self._soledad_instance(user='anotheruser@leap.se', prefix='/2') s._init_dirs() - s._gpg = GPGWrapper(gnupghome=gnupg_home) + s._crypto = SoledadCrypto(gnupg_home) s.import_recovery_document(rd, None) self.assertEqual(self._soledad._user, s._user, 'Failed setting user email.') @@ -124,7 +124,7 @@ class RecoveryDocumentTestCase(BaseSoledadTest): gnupg_home = self.gnupg_home = "%s/gnupg2" % self.tempdir s = self._soledad_instance(user='anotheruser@leap.se', prefix='3') s._init_dirs() - s._gpg = GPGWrapper(gnupghome=gnupg_home) + s._crypto = SoledadCrypto(gnupg_home) s.import_recovery_document(rd, '123456') self.assertEqual(self._soledad._user, s._user, 'Failed setting user email.') @@ -138,7 +138,7 @@ class CryptoMethodsTestCase(BaseSoledadTest): def test__gen_symkey(self): sol = self._soledad_instance(user='user@leap.se', prefix='/3') sol._init_dirs() - sol._gpg = GPGWrapper(gnupghome="%s/gnupg3" % self.tempdir) + sol._crypto = SoledadCrypto("%s/3/gnupg" % self.tempdir) self.assertFalse(sol._has_symkey(), "Should not have a symkey at " "this point") sol._gen_symkey() @@ -147,7 +147,7 @@ class CryptoMethodsTestCase(BaseSoledadTest): def test__has_keys(self): sol = self._soledad_instance(user='leap@leap.se', prefix='/5') sol._init_dirs() - sol._gpg = GPGWrapper(gnupghome=self.tempdir+"/5/gnupg") + sol._crypto = SoledadCrypto("%s/5/gnupg" % self.tempdir) self.assertFalse(sol._has_keys()) sol._gen_symkey() self.assertTrue(sol._has_keys()) diff --git a/src/leap/soledad/tests/test_leap_backend.py b/src/leap/soledad/tests/test_leap_backend.py index 9056355f..fd9ef85d 100644 --- a/src/leap/soledad/tests/test_leap_backend.py +++ b/src/leap/soledad/tests/test_leap_backend.py @@ -28,7 +28,7 @@ def make_leap_document_for_test(test, doc_id, rev, content, has_conflicts=False): return leap_backend.LeapDocument( doc_id, rev, content, has_conflicts=has_conflicts, - soledad=test._soledad) + crypto=test._soledad._crypto) def make_leap_encrypted_document_for_test(test, doc_id, rev, encrypted_content, @@ -36,7 +36,7 @@ def make_leap_encrypted_document_for_test(test, doc_id, rev, encrypted_content, return leap_backend.LeapDocument( doc_id, rev, encrypted_json=encrypted_content, has_conflicts=has_conflicts, - soledad=test._soledad) + crypto=test._soledad.crypto) LEAP_SCENARIOS = [ @@ -134,7 +134,7 @@ class TestLeapParsingSyncStream(test_remote_sync_target.TestParsingSyncStream): self.assertRaises(u1db.errors.BrokenSyncStream, tgt._parse_sync_stream, "[\r\n{},\r\n]", None) - self.assertRaises(leap_backend.NoSoledadInstance, + self.assertRaises(leap_backend.NoSoledadCryptoInstance, tgt._parse_sync_stream, '[\r\n{},\r\n{"id": "i", "rev": "r", ' '"content": "{}", "gen": 3, "trans_id": "T-sid"}' diff --git a/src/leap/soledad/tests/test_soledad.py b/src/leap/soledad/tests/test_soledad.py index 61d131f1..b849c310 100644 --- a/src/leap/soledad/tests/test_soledad.py +++ b/src/leap/soledad/tests/test_soledad.py @@ -32,6 +32,7 @@ except ImportError: from leap.soledad.tests import BaseSoledadTest from leap.soledad import Soledad +from leap.soledad.crypto import SoledadCrypto class AuxMethodsTestCase(BaseSoledadTest): @@ -49,7 +50,7 @@ class AuxMethodsTestCase(BaseSoledadTest): def test__init_db(self): sol = self._soledad_instance() sol._init_dirs() - sol._gpg = self._gpgwrapper_instance() + sol._crypto = SoledadCrypto(self.tempdir+'/gnupg') #self._soledad._gpg.import_keys(PUBLIC_KEY) if not sol._has_symkey(): sol._gen_symkey() |