From ff75ceecbff76bc9142516c198d726422c050797 Mon Sep 17 00:00:00 2001 From: Caio Carrara Date: Tue, 24 May 2016 15:56:00 -0300 Subject: [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. --- src/leap/mail/incoming/tests/test_incoming_mail.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/leap/mail/incoming/tests/test_incoming_mail.py') 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 -- cgit v1.2.3