summaryrefslogtreecommitdiff
path: root/tests/test_encrypted.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-02-19 13:04:55 -0300
committerdrebs <drebs@leap.se>2013-02-19 13:04:55 -0300
commit8bf2cfc9ec699eceee49c04360434d9c7b0cdf45 (patch)
tree9477a5d50d3ddafabda4561579f51bdd04cba05a /tests/test_encrypted.py
parent77a29a4cda84ee7d7d4859d5ed183810a3e81693 (diff)
Add support for verifying encryption status of data with gpg.
Diffstat (limited to 'tests/test_encrypted.py')
-rw-r--r--tests/test_encrypted.py22
1 files changed, 20 insertions, 2 deletions
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.")