diff options
author | Ruben Pollan <meskio@sindominio.net> | 2015-09-16 12:26:11 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2015-09-16 12:26:11 +0200 |
commit | 818ea26ec559174302ddf9095f26ed624b5cd507 (patch) | |
tree | 9b44bf85e2cfbd0534b3ba0a0d72c21dce3da786 /src/leap/mail/incoming/tests | |
parent | 64aea2effaa503a31c10f04a6243c6fbc8c7baea (diff) |
[bug] don't fail importing mismatched attached key
We can't import attached keys with different email address than the
sender. Now we don't fail in this case, just log it.
- Resolves: #7454
Diffstat (limited to 'src/leap/mail/incoming/tests')
-rw-r--r-- | src/leap/mail/incoming/tests/test_incoming_mail.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/leap/mail/incoming/tests/test_incoming_mail.py b/src/leap/mail/incoming/tests/test_incoming_mail.py index 033799d..589ddad 100644 --- a/src/leap/mail/incoming/tests/test_incoming_mail.py +++ b/src/leap/mail/incoming/tests/test_incoming_mail.py @@ -30,6 +30,7 @@ from email.parser import Parser 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 @@ -154,9 +155,6 @@ subject: independence of cyberspace return d def testExtractAttachedKey(self): - """ - Test the OpenPGP header key extraction - """ KEY = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n..." message = MIMEMultipart() @@ -176,6 +174,26 @@ subject: independence of cyberspace d.addCallback(put_raw_key_called) return d + def testExtractInvalidAttachedKey(self): + KEY = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n..." + + message = MIMEMultipart() + message.add_header("from", ADDRESS_2) + key = MIMEApplication("", "pgp-keys") + key.set_payload(KEY) + message.attach(key) + self.fetcher._keymanager.put_raw_key = Mock( + return_value=defer.fail(KeyAddressMismatch())) + self.fetcher._keymanager.fetch_key = Mock() + + def put_raw_key_called(_): + self.fetcher._keymanager.put_raw_key.assert_called_once_with( + KEY, OpenPGPKey, address=ADDRESS_2) + + d = self._do_fetch(message.as_string()) + d.addCallback(put_raw_key_called) + return d + def testAddDecryptedHeader(self): class DummyMsg(): def __init__(self): |