summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py2
-rw-r--r--tests/test_encrypted.py22
-rw-r--r--tests/test_leap_backend.py1
3 files changed, 21 insertions, 4 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index 1a9962a7..4bdf814c 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -30,7 +30,7 @@ class BaseSoledadTest(BaseLeapTest):
self._db2 = u1db.open(self.db2_file, create=True,
document_factory=LeapDocument)
# open a soledad instance
- self._soledad = Soledad(self.email, gpghome=self.gnupg_home,
+ self._soledad = Soledad(self.email, gnupghome=self.gnupg_home,
initialize=False)
self._soledad._gpg.import_keys(PUBLIC_KEY)
self._soledad._gpg.import_keys(PRIVATE_KEY)
diff --git a/tests/test_encrypted.py b/tests/test_encrypted.py
index 18894331..4a48266e 100644
--- a/tests/test_encrypted.py
+++ b/tests/test_encrypted.py
@@ -1,5 +1,11 @@
from leap.soledad.backends.leap_backend import LeapDocument
from leap.soledad.tests import BaseSoledadTest
+from leap.soledad.tests import KEY_FINGERPRINT
+
+try:
+ import simplejson as json
+except ImportError:
+ import json # noqa
class EncryptedSyncTestCase(BaseSoledadTest):
@@ -7,9 +13,9 @@ class EncryptedSyncTestCase(BaseSoledadTest):
Tests that guarantee that data will always be encrypted when syncing.
"""
- def test_get_set_encrypted(self):
+ def test_get_set_encrypted_json(self):
"""
- Test if document encryption is working.
+ Test getting and setting encrypted content.
"""
doc1 = LeapDocument(soledad=self._soledad)
doc1.content = {'key': 'val'}
@@ -19,3 +25,15 @@ class EncryptedSyncTestCase(BaseSoledadTest):
res1 = doc1.get_json()
res2 = doc2.get_json()
self.assertEqual(res1, res2, 'incorrect document encryption')
+
+ def test_successful_symmetric_encryption(self):
+ """
+ Test for successful symmetric encryption.
+ """
+ doc1 = LeapDocument(soledad=self._soledad)
+ 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),
+ "could not encrypt with passphrase.")
diff --git a/tests/test_leap_backend.py b/tests/test_leap_backend.py
index a061533c..9056355f 100644
--- a/tests/test_leap_backend.py
+++ b/tests/test_leap_backend.py
@@ -134,7 +134,6 @@ 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,
tgt._parse_sync_stream,
'[\r\n{},\r\n{"id": "i", "rev": "r", '