diff options
Diffstat (limited to 'src/leap/mail/incoming')
-rw-r--r-- | src/leap/mail/incoming/service.py | 20 | ||||
-rw-r--r-- | src/leap/mail/incoming/tests/test_incoming_mail.py | 21 |
2 files changed, 16 insertions, 25 deletions
diff --git a/src/leap/mail/incoming/service.py b/src/leap/mail/incoming/service.py index 58a19c8..fea3ecb 100644 --- a/src/leap/mail/incoming/service.py +++ b/src/leap/mail/incoming/service.py @@ -40,7 +40,6 @@ from leap.common.events import emit_async, catalog from leap.common.check import leap_assert, leap_assert_type from leap.common.mail import get_email_charset from leap.keymanager import errors as keymanager_errors -from leap.keymanager.openpgp import OpenPGPKey from leap.mail.adaptors import soledad_indexes as fields from leap.mail.generator import Generator from leap.mail.utils import json_loads, empty @@ -340,9 +339,7 @@ class IncomingMail(Service): "1" if success else "0") return self._process_decrypted_doc(doc, decrdata) - d = self._keymanager.decrypt( - doc.content[ENC_JSON_KEY], - self._userid, OpenPGPKey) + d = self._keymanager.decrypt(doc.content[ENC_JSON_KEY], self._userid) d.addErrback(self._errback) d.addCallback(process_decrypted) d.addCallback(lambda data: (doc, data)) @@ -536,8 +533,7 @@ class IncomingMail(Service): return res d = self._keymanager.decrypt( - encdata, self._userid, OpenPGPKey, - verify=senderAddress) + encdata, self._userid, verify=senderAddress) d.addCallbacks(build_msg, self._decryption_error, errbackArgs=(msg,)) d.addCallbacks(verify_signature_after_decrypt_an_email) return d @@ -581,8 +577,7 @@ class IncomingMail(Service): end = data.find(PGP_END) pgp_message = data[begin:end + len(PGP_END)] d = self._keymanager.decrypt( - pgp_message, self._userid, OpenPGPKey, - verify=senderAddress) + pgp_message, self._userid, verify=senderAddress) d.addCallbacks(decrypted_data, self._decryption_error, errbackArgs=(data,)) else: @@ -607,8 +602,7 @@ class IncomingMail(Service): msg = copy.deepcopy(origmsg) data = self._serialize_msg(msg.get_payload(0)) detached_sig = self._extract_signature(msg) - d = self._keymanager.verify(data, sender_address, OpenPGPKey, - detached_sig) + d = self._keymanager.verify(data, sender_address, detached_sig) d.addCallback(lambda sign_key: (msg, sign_key)) d.addErrback(lambda _: (msg, keymanager_errors.InvalidSignature())) @@ -720,7 +714,7 @@ class IncomingMail(Service): else: return failure - d = self._keymanager.fetch_key(address, url, OpenPGPKey) + d = self._keymanager.fetch_key(address, url) d.addCallback( lambda _: logger.info("Imported key from header %s" % (url,))) @@ -761,9 +755,7 @@ class IncomingMail(Service): for attachment in attachments: if MIME_KEY == attachment.get_content_type(): d = self._keymanager.put_raw_key( - attachment.get_payload(decode=True), - OpenPGPKey, - address=address) + attachment.get_payload(decode=True), address=address) d.addCallbacks(log_key_added, failed_put_key) deferreds.append(d) d = defer.gatherResults(deferreds) diff --git a/src/leap/mail/incoming/tests/test_incoming_mail.py b/src/leap/mail/incoming/tests/test_incoming_mail.py index 91f2556..0f19a6f 100644 --- a/src/leap/mail/incoming/tests/test_incoming_mail.py +++ b/src/leap/mail/incoming/tests/test_incoming_mail.py @@ -32,7 +32,6 @@ from mock import Mock from twisted.internet import defer from leap.keymanager.errors import KeyAddressMismatch -from leap.keymanager.openpgp import OpenPGPKey from leap.mail.adaptors import soledad_indexes as fields from leap.mail.constants import INBOX_NAME from leap.mail.imap.account import IMAPAccount @@ -123,7 +122,7 @@ subject: independence of cyberspace def fetch_key_called(ret): self.fetcher._keymanager.fetch_key.assert_called_once_with( - ADDRESS_2, KEYURL, OpenPGPKey) + ADDRESS_2, KEYURL) d = self._create_incoming_email(message.as_string()) d.addCallback( @@ -168,7 +167,7 @@ subject: independence of cyberspace def put_raw_key_called(_): self.fetcher._keymanager.put_raw_key.assert_called_once_with( - KEY, OpenPGPKey, address=ADDRESS_2) + KEY, address=ADDRESS_2) d = self._do_fetch(message.as_string()) d.addCallback(put_raw_key_called) @@ -187,7 +186,7 @@ subject: independence of cyberspace def put_raw_key_called(_): self.fetcher._keymanager.put_raw_key.assert_called_once_with( - KEY, OpenPGPKey, address=ADDRESS_2) + KEY, address=ADDRESS_2) d = self._do_fetch(message.as_string()) d.addCallback(put_raw_key_called) @@ -211,7 +210,7 @@ subject: independence of cyberspace def put_raw_key_called(_): self.fetcher._keymanager.put_raw_key.assert_called_once_with( - KEY, OpenPGPKey, address=ADDRESS_2) + KEY, address=ADDRESS_2) self.assertFalse(self.fetcher._keymanager.fetch_key.called) d = self._do_fetch(message.as_string()) @@ -236,9 +235,9 @@ subject: independence of cyberspace def put_raw_key_called(_): self.fetcher._keymanager.put_raw_key.assert_called_once_with( - KEY, OpenPGPKey, address=ADDRESS_2) + KEY, address=ADDRESS_2) self.fetcher._keymanager.fetch_key.assert_called_once_with( - ADDRESS_2, KEYURL, OpenPGPKey) + ADDRESS_2, KEYURL) d = self._do_fetch(message.as_string()) d.addCallback(put_raw_key_called) @@ -287,13 +286,13 @@ subject: independence of cyberspace self.assertTrue(self.fetcher._add_decrypted_header.called, "There was some errors with decryption") - d = self._km.encrypt( - self.EMAIL, - ADDRESS, OpenPGPKey, sign=ADDRESS_2) + d = self._km.encrypt(self.EMAIL, ADDRESS, sign=ADDRESS_2) d.addCallback(create_encrypted_message) d.addCallback( lambda message: self._do_fetch(message.as_string())) + d.addCallback(decryption_error_not_called) + d.addCallback(add_decrypted_header_called) return d def testValidateSignatureFromEncryptedEmailFromAppleMail(self): @@ -349,7 +348,7 @@ subject: independence of cyberspace ENC_JSON_KEY: encr_data } return email - d = self._km.encrypt(data, ADDRESS, OpenPGPKey, fetch_remote=False) + d = self._km.encrypt(data, ADDRESS, fetch_remote=False) d.addCallback(set_email_content) return d |