summaryrefslogtreecommitdiff
path: root/testing/tests
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-03-15 20:59:37 -0300
committerdrebs <drebs@leap.se>2017-04-04 18:27:33 +0200
commit613a81facc799fd5f76c6057c168bfb41f7bf790 (patch)
treefc107577479563ef02d4aef43f0863ce908508ff /testing/tests
parent0b9d59f0a61ac05aa1dd751d17f2ef58eea8a2d0 (diff)
[test] BlobManager encrypt test
Diffstat (limited to 'testing/tests')
-rw-r--r--testing/tests/blobs/test_blobs.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/tests/blobs/test_blobs.py b/testing/tests/blobs/test_blobs.py
index 5e763026..b78f6c0f 100644
--- a/testing/tests/blobs/test_blobs.py
+++ b/testing/tests/blobs/test_blobs.py
@@ -19,6 +19,7 @@ Tests for cryptographic related stuff.
"""
from twisted.trial import unittest
from twisted.internet import defer
+from leap.soledad.client import _blobs
from leap.soledad.client._blobs import DecrypterBuffer
from leap.soledad.client import _crypto
from io import BytesIO
@@ -47,3 +48,20 @@ class BlobTestCase(unittest.TestCase):
buf.write(encrypted)
fd, size = buf.close()
assert fd.getvalue() == 'rosa de foc'
+
+ def test_blob_manager_encrypted_upload(self):
+
+ @defer.inlineCallbacks
+ def _check_result(uri, data):
+ decryptor = _crypto.BlobDecryptor(
+ self.doc_info, data,
+ armor=False,
+ secret=self.secret)
+ decrypted = yield decryptor.decrypt()
+ assert decrypted.getvalue() == 'up and up'
+
+ manager = _blobs.BlobManager('', '', self.secret, self.secret, 'user')
+ doc_id, rev = self.doc_info.doc_id, self.doc_info.rev
+ fd = BytesIO('up and up')
+ _blobs.treq.put = _check_result
+ return manager._encrypt_and_upload('blob_id', doc_id, rev, fd)