summaryrefslogtreecommitdiff
path: root/service/test/unit/adapter
diff options
context:
space:
mode:
authorNavaL <ayoyo@thoughtworks.com>2016-12-02 16:44:36 +0100
committerNavaL <ayoyo@thoughtworks.com>2016-12-02 16:44:36 +0100
commit0dd71ff7c3a895e774205231c23720ee7313ad39 (patch)
treeb9cb35726e97007478332b1f68b53378274218dd /service/test/unit/adapter
parent31ac4ebd4f734fc4e438af504a318b4eb7ce627c (diff)
[#625, #851] fixing log typo and adding test making sure encryption error does propagate to mails resources
Diffstat (limited to 'service/test/unit/adapter')
-rw-r--r--service/test/unit/adapter/services/test_mail_sender.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/service/test/unit/adapter/services/test_mail_sender.py b/service/test/unit/adapter/services/test_mail_sender.py
index 4daa7f24..23951214 100644
--- a/service/test/unit/adapter/services/test_mail_sender.py
+++ b/service/test/unit/adapter/services/test_mail_sender.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from leap.bitmask.mail.outgoing.service import OutgoingMail
+from mock import patch
from twisted.mail.smtp import User
from twisted.trial import unittest
@@ -104,6 +105,25 @@ class MailSenderTest(unittest.TestCase):
self.assertTrue(recipient in e.email_error_map)
@defer.inlineCallbacks
+ def test_keymanager_encrypt_problem_raises_exception(self):
+ input_mail = InputMail.from_dict(mail_dict(), from_address='pixelated@org')
+
+ when(OutgoingMail)._maybe_attach_key(any(), any(), any()).thenReturn(
+ defer.succeed(None))
+ when(OutgoingMail)._fix_headers(any(), any(), any()).thenReturn(
+ defer.succeed((None, mock())))
+ when(self._keymanager_mock).encrypt(any(), any(), sign=any(),
+ fetch_remote=any()).thenReturn(defer.fail(Exception('pretend key expired')))
+
+ with patch('leap.bitmask.mail.outgoing.service.emit_async'):
+ try:
+ yield self.sender.sendmail(input_mail)
+ self.fail('Exception expected!')
+ except MailSenderException, e:
+ for recipient in flatten([input_mail.to, input_mail.cc, input_mail.bcc]):
+ self.assertTrue(recipient in e.email_error_map)
+
+ @defer.inlineCallbacks
def test_iterates_over_recipients_and_send_whitout_bcc_field(self):
input_mail = InputMail.from_dict(mail_dict(), from_address='pixelated@org')
bccs = input_mail.bcc