[tor-commits] [bridgedb/develop] Add unittest for MailMessage.getRecipient() w/ a bad email address.

isis at torproject.org isis at torproject.org
Fri Jun 6 20:40:38 UTC 2014


commit 3fda7f6365fa8445398563391f5ddcda1247f5e7
Author: Isis Lovecruft <isis at torproject.org>
Date:   Wed May 21 15:01:07 2014 +0000

    Add unittest for MailMessage.getRecipient() w/ a bad email address.
    
    This should still return our configured EMAIL_SMTP_FROM_ADDR email
    address.
---
 lib/bridgedb/test/test_email_server.py |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/bridgedb/test/test_email_server.py b/lib/bridgedb/test/test_email_server.py
index f58b36f..d7f2922 100644
--- a/lib/bridgedb/test/test_email_server.py
+++ b/lib/bridgedb/test/test_email_server.py
@@ -323,6 +323,17 @@ class MailMessageTests(unittest.TestCase):
         recipient = self.message.getRecipient(incoming)
         self.assertEqual(recipient, self.context.fromAddr)
 
+    def test_MailMessage_getRecipient_bad_address(self):
+        """MailMessage.getRecipient() for an incoming email sent to a malformed
+        email address should log an smtp.AddressError and then return our
+        configured email address.
+        """
+        self._getIncomingLines()
+        self.message.lines[1] = 'To: ><@><<<>>.foo'
+        incoming = self.message.getIncomingMessage()
+        recipient = self.message.getRecipient(incoming)
+        self.assertEqual(recipient, self.context.fromAddr)
+
     def test_MailMessage_reply_noFrom(self):
         """A received email without a "From:" or "Sender:" header shouldn't
         receive a response.





More information about the tor-commits mailing list