summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorSriram Viswanathan <sriramv@thoughtworks.com>2017-03-16 17:06:50 -0300
committerKali Kaneko (leap communications) <kali@leap.se>2017-03-31 18:47:16 +0200
commitb553c65d1d114f2a3a4cb3282b4505838f537421 (patch)
tree2c996504feed652246427e77def9b661f32a78db /tests/integration
parentcaed945c7c85800d7467f52471509afc21a6f071 (diff)
[bug] fix errBack in _decrypt_doc in incoming mail service
with @deniscostadsc
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/mail/incoming/test_incoming_mail.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/integration/mail/incoming/test_incoming_mail.py b/tests/integration/mail/incoming/test_incoming_mail.py
index b8d69f12..daef0578 100644
--- a/tests/integration/mail/incoming/test_incoming_mail.py
+++ b/tests/integration/mail/incoming/test_incoming_mail.py
@@ -29,10 +29,12 @@ import uuid
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.parser import Parser
-from mock import Mock
+from mock import Mock, patch, MagicMock, ANY
from twisted.internet import defer
from twisted.python import log
+from twisted.logger import Logger
+from twisted.python.failure import Failure
from leap.bitmask.keymanager.errors import KeyAddressMismatch
from leap.bitmask.mail.adaptors import soledad_indexes as fields
@@ -324,6 +326,26 @@ subject: independence of cyberspace
d.addCallback(add_decrypted_header_called)
return d
+ def test_log_error_if_decrypt_fails(self):
+
+ def assert_failure(_):
+ mock_logger_error.assert_any_call('_decrypt_doc: '
+ 'Error decrypting document with '
+ 'ID 1')
+
+ with patch.object(Logger, 'error') as mock_logger_error:
+ doc = SoledadDocument()
+ doc.doc_id = '1'
+ doc.content = {'_enc_json': ''}
+
+ self.fetcher._process_decrypted_doc = Mock()
+ self.km.decrypt = Mock(
+ return_value=defer.fail(Exception()))
+
+ d = self.fetcher._decrypt_doc(doc)
+ d.addCallback(assert_failure)
+ return d
+
def testValidateSignatureFromEncryptedEmailFromAppleMail(self):
enc_signed_file = os.path.join(
HERE, 'rfc822.multi-encrypt-signed.message')