diff options
author | Caio Carrara <ccarrara@thoughtworks.com> | 2016-05-24 15:56:00 -0300 |
---|---|---|
committer | Caio Carrara <ccarrara@thoughtworks.com> | 2016-05-24 15:56:00 -0300 |
commit | ff75ceecbff76bc9142516c198d726422c050797 (patch) | |
tree | 929b1145b9fd4346548f12de73ea714d563418e3 /src/leap/mail/incoming/tests/test_incoming_mail.py | |
parent | 64f1342d0f8ab27a95624b561b52eb8c2003e771 (diff) |
[tests] add test to validate signature from apple mail
This change adds test to validate signature of encrypted email created
by apple mail. It's important to note that apple mail has a specific way
to encrypt signed messages. First it sign the email and then encrypt the
previous signed message. It was also added a message file with the
expected data.
Diffstat (limited to 'src/leap/mail/incoming/tests/test_incoming_mail.py')
-rw-r--r-- | src/leap/mail/incoming/tests/test_incoming_mail.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/leap/mail/incoming/tests/test_incoming_mail.py b/src/leap/mail/incoming/tests/test_incoming_mail.py index 754df9f..91f2556 100644 --- a/src/leap/mail/incoming/tests/test_incoming_mail.py +++ b/src/leap/mail/incoming/tests/test_incoming_mail.py @@ -22,6 +22,7 @@ Test case for leap.mail.incoming.service @license: GPLv3, see included LICENSE file """ +import os import json from email.mime.application import MIMEApplication @@ -295,6 +296,23 @@ subject: independence of cyberspace self._do_fetch(message.as_string())) return d + def testValidateSignatureFromEncryptedEmailFromAppleMail(self): + CURRENT_PATH = os.path.split(os.path.abspath(__file__))[0] + enc_signed_file = os.path.join(CURRENT_PATH, + 'rfc822.multi-encrypt-signed.message') + self.fetcher._add_verified_signature_header = Mock() + + def add_verified_signature_header_called(_): + self.assertTrue(self.fetcher._add_verified_signature_header.called, + "There was some errors verifying signature") + + with open(enc_signed_file) as f: + enc_signed_raw = f.read() + + d = self._do_fetch(enc_signed_raw) + d.addCallback(add_verified_signature_header_called) + return d + def testListener(self): self.called = False |