summaryrefslogtreecommitdiff
path: root/src/leap/soledad/tests/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/soledad/tests/__init__.py')
-rw-r--r--src/leap/soledad/tests/__init__.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/leap/soledad/tests/__init__.py b/src/leap/soledad/tests/__init__.py
index be01dd83..d947f5b3 100644
--- a/src/leap/soledad/tests/__init__.py
+++ b/src/leap/soledad/tests/__init__.py
@@ -7,7 +7,11 @@ import u1db
from leap.soledad import Soledad
from leap.soledad.crypto import SoledadCrypto
-from leap.soledad.backends.leap_backend import LeapDocument
+from leap.soledad.backends.leap_backend import (
+ LeapDocument,
+ decrypt_doc_json,
+ ENC_SCHEME_KEY,
+)
from leap.common.testing.basetest import BaseLeapTest
@@ -58,6 +62,20 @@ class BaseSoledadTest(BaseLeapTest):
cert_file=None,
bootstrap=bootstrap)
+ def assertGetEncryptedDoc(self, db, doc_id, doc_rev, content, has_conflicts):
+ """Assert that the document in the database looks correct."""
+ exp_doc = self.make_document(doc_id, doc_rev, content,
+ has_conflicts=has_conflicts)
+ doc = db.get_doc(doc_id)
+ if ENC_SCHEME_KEY in doc.content:
+ doc.set_json(
+ decrypt_doc_json(
+ self._soledad._crypto, doc.doc_id, doc.get_json()))
+ self.assertEqual(exp_doc.doc_id, doc.doc_id)
+ self.assertEqual(exp_doc.rev, doc.rev)
+ self.assertEqual(exp_doc.has_conflicts, doc.has_conflicts)
+ self.assertEqual(exp_doc.content, doc.content)
+
# Key material for testing
KEY_FINGERPRINT = "E36E738D69173C13D709E44F2F455E2824D18DDF"