[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit 3fda7f6365fa8445398563391f5ddcda1247f5e7
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
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.



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits