From 19cda9ca7aa1aca18f61ebf659fc490f8ad4c15a Mon Sep 17 00:00:00 2001 From: Duda Dornelles Date: Wed, 2 Sep 2015 18:07:51 -0300 Subject: [feature] adding security_casing to LeapMail so we can show in the UI the signature and encryption status --- .../test/unit/adapter/mailstore/test_leap_mail.py | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'service/test/unit/adapter/mailstore') diff --git a/service/test/unit/adapter/mailstore/test_leap_mail.py b/service/test/unit/adapter/mailstore/test_leap_mail.py index 9b72d8c3..571e2f60 100644 --- a/service/test/unit/adapter/mailstore/test_leap_mail.py +++ b/service/test/unit/adapter/mailstore/test_leap_mail.py @@ -62,6 +62,10 @@ class TestLeapMail(TestCase): 'status': [], 'body': None, 'textPlainBody': None, + 'security_casing': { + 'imprints': [{'state': 'no_signature_information'}], + 'locks': [] + }, 'replying': {'all': {'cc-field': [], 'to-field': ['receiver@example.test', 'test@example.test', @@ -125,3 +129,22 @@ class TestLeapMail(TestCase): self.assertEquals([], mail.headers['To']) self.assertEquals([], mail.headers['Cc']) self.assertEquals([], mail.headers['Bcc']) + + def test_security_casing(self): + # No Encryption, no Signature + mail = LeapMail('id', 'INBOX', {}) + self.assertEqual({'locks': [], 'imprints': [{'state': 'no_signature_information'}]}, mail.security_casing) + + # Encryption + mail = LeapMail('id', 'INBOX', {'X-Leap-Encryption': 'decrypted'}) + self.assertEqual([{'state': 'valid'}], mail.security_casing['locks']) + + mail = LeapMail('id', 'INBOX', {'X-Leap-Encryption': 'false'}) + self.assertEqual([], mail.security_casing['locks']) + + # Signature + mail = LeapMail('id', 'INBOX', {'X-Leap-Signature': 'valid'}) + self.assertEqual([{'seal': {'validity': 'valid'}, 'state': 'valid'}], mail.security_casing['imprints']) + + mail = LeapMail('id', 'INBOX', {'X-Leap-Signature': 'invalid'}) + self.assertEqual([], mail.security_casing['imprints']) -- cgit v1.2.3