diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bounces/qmail_08.txt | 24 | ||||
-rw-r--r-- | tests/bounces/simple_39.txt | 32 | ||||
-rw-r--r-- | tests/bounces/simple_40.txt | 29 | ||||
-rw-r--r-- | tests/bounces/yahoo_11.txt | 16 | ||||
-rwxr-xr-x | tests/onebounce.py | 6 | ||||
-rwxr-xr-x | tests/test_bounces.py | 9 | ||||
-rw-r--r-- | tests/test_handlers.py | 188 |
7 files changed, 278 insertions, 26 deletions
diff --git a/tests/bounces/qmail_08.txt b/tests/bounces/qmail_08.txt new file mode 100644 index 00000000..583d94aa --- /dev/null +++ b/tests/bounces/qmail_08.txt @@ -0,0 +1,24 @@ +From contact@example.com Mon Mar 18 11:39:41 2013 +Return-Path: <contact@example.com> +X-Original-To: noreply@example.org +Delivered-To: noreply@example.org +Received: from example.com (example.com [1.2.3.4]) + by worker1.example.org (Postfix) with ESMTP id 58C7E14C1208 + for <noreply@example.org>; Mon, 18 Mar 2013 11:39:40 +0000 (GMT) +Received: from contact by example.com with local (Exim 4.80) + (envelope-from <contact@example.com>) + id 1UHYPj-0001DB-Ij + for noreply@example.org; Mon, 18 Mar 2013 06:39:39 -0500 +To: "Example Sender" <noreply@example.org> +MIME-Version: 1.0 +Precedence: auto_reply +X-Precedence: auto_reply +From: "Example user" <contact@example.com> +Content-type: text/plain; charset=ansi_x3.110-1983 +Subject: Auto reply +Message-Id: <E1UHYPj-0001DB-Ij@example.com> +Date: Mon, 18 Mar 2013 06:39:39 -0500 +X-Comment: qmail detector would throw UnicodeDecodeError on this message +X-Comment: when running under Python 2.x. Bug LP: 1074592. + +Gracias por contactar con nosotros!! en este instante estamos procesando la respuesta a tu consulta, a la mayor brevedad posible tendr疽 noticias nuestras... diff --git a/tests/bounces/simple_39.txt b/tests/bounces/simple_39.txt new file mode 100644 index 00000000..1b46ff92 --- /dev/null +++ b/tests/bounces/simple_39.txt @@ -0,0 +1,32 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Auto-Submitted: auto-replied +Date: Wed, 07 Nov 2012 10:47:34 +0400 +From: Mail Delivery System <Mailer-Daemon@mx183.mail.ru> +Message-Id: <E1TVzQE-0003uW-ED@mx183.mail.ru> +Subject: =?utf-8?b?0JLQsNGI0LUg0YHQvtC+0LHRidC10L3QuNC1INC90LUg0LTQvtGB0YLQsNCy0LvQ?= + =?utf-8?b?tdC90L4uIE1haWwgZmFpbHVyZS4=?= +To: noreply@example.com +Content-Transfer-Encoding: 8bit + +ミュムひセ ミソミクムム糊シミセ ムミセミキミエミーミスミセ ミーミイムひセミシミームひクムミオムミコミク ムミオムミイミオムミセミシ Mail.Ru, ミセムひイミオムミームび ミスミー ミスミオミウミセ ミスミオ ミスムσカミスミセ. + +ミ ムミセミカミーミサミオミスミクム, ミ漬ーム威オ ミソミクムム糊シミセ ミスミオ ミシミセミカミオム ミアム錦び ミエミセムムひーミイミサミオミスミセ ミセミエミスミセミシム ミクミサミク ミスミオムミコミセミサム糊コミクミシ ミソミセミサムτミームひオミサム紹シ, ミソミセムひセミシム ムムひセ: + + Message was not accepted -- invalid mailbox. + Local mailbox foo@mail.ru is unavailable: user not found + +********************** + +A message that you sent was rejected by the local scanning code that +checks incoming messages on this system. The following error was given: + + Message was not accepted -- invalid mailbox. + Local mailbox foo@mail.ru is unavailable: user not found + +------ This is a copy of your message, including all the headers. +------ No more than 1K characters of the body are included. + +Received: from mail by mx183.mail.ru with local (envelope-from <noreply@example.com>) + id 1TVzQE-0003tT-Co + for foo@mail.ru; Wed, 07 Nov 2012 10:47:34 +0400 diff --git a/tests/bounces/simple_40.txt b/tests/bounces/simple_40.txt new file mode 100644 index 00000000..89375151 --- /dev/null +++ b/tests/bounces/simple_40.txt @@ -0,0 +1,29 @@ +Return-Path: <> +Received: from mout by moeu2.kundenserver.de id 0LkyaB-1VJZRH2iiz-00ahag; + Fri, 13 Dec 2013 01:07:54 +0100 +Date: Fri, 13 Dec 2013 01:07:54 +0100 +From: Mail Delivery System <mailer-daemon@kundenserver.de> +To: mailman-users-bounces+user=example.com@python.org +Subject: Warning: message delayed 2 days +Message-Id: <0LkyaB-1VJZRH2iiz-00ahag@moeu2.kundenserver.de> +X-Original-Id: 0LykMh-1VSY0J0JZn-015ri8 + +This message was created automatically by mail delivery software. + +A message that you sent has not yet been delivered to one or more of +its recipients after 2 days. + +The message has not yet been delivered to the following addresses: + + <user@example.com> + +host lsvk.de[213.165.78.137]: +connection to mail exchanger failed + +No action is required on your part. Delivery attempts will continue for +some time, and this warning may be repeated at intervals if the message +remains undelivered. Eventually the mail delivery software will give up, +and when that happens, the message will be returned to you. + +--- The header of the original message is following. --- + diff --git a/tests/bounces/yahoo_11.txt b/tests/bounces/yahoo_11.txt new file mode 100644 index 00000000..6e9692a6 --- /dev/null +++ b/tests/bounces/yahoo_11.txt @@ -0,0 +1,16 @@ +From: MAILER-DAEMON@yahoo.com +To: user@bellsouth.net +Date: Wed, 20 Feb 2013 15:50:26 -0000 +Subject: Failure Notice + +Sorry, we were unable to deliver your message to the following address. + +<bad_user@aol.com>: +Remote host said: 550 5.1.1 <bad_user@aol.com>: Recipient address rejected: aol.com [RCPT_TO] + +--- Below this line is a copy of the message. + +The following should not be found as we should have stopped looking. + +<bogus@dont.find.me.invalid>: + diff --git a/tests/onebounce.py b/tests/onebounce.py index 2b05807c..846c4fa6 100755 --- a/tests/onebounce.py +++ b/tests/onebounce.py @@ -1,6 +1,6 @@ #! /usr/bin/env python -# Copyright (C) 2002 by the Free Software Foundation, Inc. +# Copyright (C) 2002-2013 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -14,7 +14,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Test the bounce detection for files containing bounces. @@ -80,6 +81,7 @@ def main(): print module, 'got a Stop' if not all: break + continue if not addrs: if verbose: print module, 'found no matches' diff --git a/tests/test_bounces.py b/tests/test_bounces.py index 6bf51570..8c33ccfd 100755 --- a/tests/test_bounces.py +++ b/tests/test_bounces.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2011 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2013 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -41,7 +41,8 @@ class BounceTest(unittest.TestCase): # Exim bounces ('Exim', 'exim_01.txt', ['delangen@its.tudelft.nl']), # SimpleMatch bounces - ('SimpleMatch', 'sendmail_01.txt', ['zzzzz@nfg.nl']), + ('SimpleMatch', 'sendmail_01.txt', ['zzzzz@shaft.coal.nl', + 'zzzzz@nfg.nl']), ('SimpleMatch', 'simple_01.txt', ['bbbsss@turbosport.com']), ('SimpleMatch', 'simple_02.txt', ['chris.ggggmmmm@usa.net']), ('SimpleMatch', 'simple_04.txt', ['claird@starbase.neosoft.com']), @@ -79,6 +80,7 @@ class BounceTest(unittest.TestCase): ('SimpleMatch', 'simple_36.txt', ['garyt@xxx.com']), ('SimpleMatch', 'simple_37.txt', ['user@uci.edu']), ('SimpleMatch', 'simple_38.txt', ['prueba@domain.com']), + ('SimpleMatch', 'simple_39.txt', [b'foo@mail.ru']), ('SimpleMatch', 'bounce_02.txt', ['acinsp1@midsouth.rr.com']), ('SimpleMatch', 'bounce_03.txt', ['james@jeborall.demon.co.uk']), # SimpleWarning @@ -87,6 +89,7 @@ class BounceTest(unittest.TestCase): ('SimpleWarning', 'simple_22.txt', Stop), ('SimpleWarning', 'simple_28.txt', Stop), ('SimpleWarning', 'simple_35.txt', Stop), + ('SimpleWarning', 'simple_40.txt', Stop), # GroupWise ('GroupWise', 'groupwise_01.txt', ['thoff@MAINEX1.ASU.EDU']), # This one really sucks 'cause it's text/html. Just make sure it @@ -136,6 +139,7 @@ class BounceTest(unittest.TestCase): ('Qmail', 'qmail_05.txt', ['ivokggrrdvc@caixaforte.freeservers.com']), ('Qmail', 'qmail_06.txt', ['ntl@xxx.com']), ('Qmail', 'qmail_07.txt', ['user@example.net']), + ('Qmail', 'qmail_08.txt', []), # LLNL's custom Sendmail ('LLNL', 'llnl_01.txt', ['trotts1@llnl.gov']), # Netscape's server... @@ -168,6 +172,7 @@ class BounceTest(unittest.TestCase): ('Yahoo', 'yahoo_10.txt', ['jajcchoo@yahoo.com', 'lyons94706@yahoo.com', 'turtle4jne@yahoo.com']), + ('Yahoo', 'yahoo_11.txt', ['bad_user@aol.com']), # sina.com appears to use their own weird SINAEMAIL MTA ('Sina', 'sina_01.txt', ['boboman76@sina.com', 'alan_t18@sina.com']), ('AOL', 'aol_01.txt', ['screenname@aol.com']), diff --git a/tests/test_handlers.py b/tests/test_handlers.py index aa73b3c1..8f6219e8 100644 --- a/tests/test_handlers.py +++ b/tests/test_handlers.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2011 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2015 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -76,6 +76,7 @@ class TestAcknowledge(TestBase): # Add a member self._mlist.addNewMember('aperson@dom.ain') self._mlist.personalize = False + self._mlist.dmarc_moderation_action = 0 def tearDown(self): for f in os.listdir(mm_cfg.VIRGINQUEUE_DIR): @@ -591,82 +592,220 @@ Subject: Re: [XTEST] About Mailman... eq = self.assertEqual mlist = self._mlist mlist.reply_goes_to_list = 1 + mlist.from_is_list = 0 msg = email.message_from_string("""\ From: aperson@dom.ain """, Message.Message) - CookHeaders.process(mlist, msg, {}) - eq(msg['reply-to'], '_xtest@dom.ain') - eq(msg.get_all('reply-to'), ['_xtest@dom.ain']) + msgdata = {} + CookHeaders.process(mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], '_xtest@dom.ain') + eq(msg.get_all('reply-to'), None) + + def test_reply_to_list_fil(self): + eq = self.assertEqual + mlist = self._mlist + mlist.reply_goes_to_list = 1 + mlist.from_is_list = 1 + msg = email.message_from_string("""\ +From: aperson@dom.ain + +""", Message.Message) + msgdata = {} + CookHeaders.process(mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], + '_xtest@dom.ain') + eq(msgdata['add_header']['Cc'], + 'aperson@dom.ain') + eq(msg.get_all('reply-to'), None) + eq(msg.get_all('cc'), None) def test_reply_to_list_with_strip(self): eq = self.assertEqual mlist = self._mlist mlist.reply_goes_to_list = 1 mlist.first_strip_reply_to = 1 + mlist.from_is_list = 0 msg = email.message_from_string("""\ From: aperson@dom.ain Reply-To: bperson@dom.ain """, Message.Message) - CookHeaders.process(mlist, msg, {}) - eq(msg['reply-to'], '_xtest@dom.ain') - eq(msg.get_all('reply-to'), ['_xtest@dom.ain']) + msgdata = {} + CookHeaders.process(mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], '_xtest@dom.ain') + eq(msg.get_all('reply-to'), ['bperson@dom.ain']) + + def test_reply_to_list_with_strip_fil(self): + eq = self.assertEqual + mlist = self._mlist + mlist.reply_goes_to_list = 1 + mlist.first_strip_reply_to = 1 + mlist.from_is_list = 1 + msg = email.message_from_string("""\ +From: aperson@dom.ain +Reply-To: bperson@dom.ain + +""", Message.Message) + msgdata = {} + CookHeaders.process(mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], + '_xtest@dom.ain') + eq(msgdata['add_header']['Cc'], + 'aperson@dom.ain') + eq(msg.get_all('reply-to'), ['bperson@dom.ain']) + eq(msg.get_all('cc'), None) + def test_reply_to_explicit(self): eq = self.assertEqual mlist = self._mlist mlist.reply_goes_to_list = 2 + mlist.from_is_list = 0 mlist.reply_to_address = 'mlist@dom.ain' msg = email.message_from_string("""\ From: aperson@dom.ain """, Message.Message) - CookHeaders.process(mlist, msg, {}) - eq(msg['reply-to'], 'mlist@dom.ain') - eq(msg.get_all('reply-to'), ['mlist@dom.ain']) + msgdata = {} + CookHeaders.process(mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], 'mlist@dom.ain') + eq(msg.get_all('reply-to'), None) + + def test_reply_to_explicit_fil(self): + eq = self.assertEqual + mlist = self._mlist + mlist.reply_goes_to_list = 2 + mlist.from_is_list = 1 + mlist.reply_to_address = 'mlist@dom.ain' + msg = email.message_from_string("""\ +From: aperson@dom.ain + +""", Message.Message) + msgdata = {} + CookHeaders.process(mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], + 'mlist@dom.ain') + eq(msgdata['add_header']['Cc'], + 'aperson@dom.ain') + eq(msg.get_all('reply-to'), None) + eq(msg.get_all('cc'), None) def test_reply_to_explicit_with_strip(self): eq = self.assertEqual mlist = self._mlist mlist.reply_goes_to_list = 2 mlist.first_strip_reply_to = 1 + mlist.from_is_list = 0 mlist.reply_to_address = 'mlist@dom.ain' msg = email.message_from_string("""\ From: aperson@dom.ain Reply-To: bperson@dom.ain """, Message.Message) - CookHeaders.process(self._mlist, msg, {}) - eq(msg['reply-to'], 'mlist@dom.ain') - eq(msg.get_all('reply-to'), ['mlist@dom.ain']) + msgdata = {} + + CookHeaders.process(self._mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], 'mlist@dom.ain') + eq(msg.get_all('reply-to'), ['bperson@dom.ain']) + + def test_reply_to_explicit_with_strip_fil(self): + eq = self.assertEqual + mlist = self._mlist + mlist.reply_goes_to_list = 2 + mlist.first_strip_reply_to = 1 + mlist.from_is_list = 1 + mlist.reply_to_address = 'mlist@dom.ain' + msg = email.message_from_string("""\ +From: aperson@dom.ain +Reply-To: bperson@dom.ain + +""", Message.Message) + msgdata = {} + + CookHeaders.process(self._mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], + 'mlist@dom.ain') + eq(msgdata['add_header']['Cc'], + 'aperson@dom.ain') + eq(msg.get_all('reply-to'), ['bperson@dom.ain']) + eq(msg.get_all('cc'), None) def test_reply_to_extends_to_list(self): eq = self.assertEqual mlist = self._mlist mlist.reply_goes_to_list = 1 mlist.first_strip_reply_to = 0 + mlist.from_is_list = 0 msg = email.message_from_string("""\ From: aperson@dom.ain Reply-To: bperson@dom.ain """, Message.Message) - CookHeaders.process(mlist, msg, {}) - eq(msg['reply-to'], 'bperson@dom.ain, _xtest@dom.ain') + msgdata = {} + + CookHeaders.process(mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], + 'bperson@dom.ain, _xtest@dom.ain') + + def test_reply_to_extends_to_list_fil(self): + eq = self.assertEqual + mlist = self._mlist + mlist.reply_goes_to_list = 1 + mlist.first_strip_reply_to = 0 + mlist.from_is_list = 1 + msg = email.message_from_string("""\ +From: aperson@dom.ain +Reply-To: bperson@dom.ain + +""", Message.Message) + msgdata = {} + + CookHeaders.process(mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], + 'bperson@dom.ain, _xtest@dom.ain') + eq(msgdata['add_header']['Cc'], + 'aperson@dom.ain') + eq(msg.get_all('reply-to'), ['bperson@dom.ain']) + eq(msg.get_all('cc'), None) def test_reply_to_extends_to_explicit(self): eq = self.assertEqual mlist = self._mlist mlist.reply_goes_to_list = 2 mlist.first_strip_reply_to = 0 + mlist.from_is_list = 0 + mlist.reply_to_address = 'mlist@dom.ain' + msg = email.message_from_string("""\ +From: aperson@dom.ain +Reply-To: bperson@dom.ain + +""", Message.Message) + msgdata = {} + CookHeaders.process(mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], + 'mlist@dom.ain, bperson@dom.ain') + + def test_reply_to_extends_to_explicit_fil(self): + eq = self.assertEqual + mlist = self._mlist + mlist.reply_goes_to_list = 2 + mlist.first_strip_reply_to = 0 + mlist.from_is_list = 1 mlist.reply_to_address = 'mlist@dom.ain' msg = email.message_from_string("""\ From: aperson@dom.ain Reply-To: bperson@dom.ain """, Message.Message) - CookHeaders.process(mlist, msg, {}) - eq(msg['reply-to'], 'mlist@dom.ain, bperson@dom.ain') + msgdata = {} + CookHeaders.process(mlist, msg, msgdata) + eq(msgdata['add_header']['Reply-To'], + 'mlist@dom.ain, bperson@dom.ain') + eq(msgdata['add_header']['Cc'], + 'aperson@dom.ain') + eq(msg.get_all('reply-to'), ['bperson@dom.ain']) + eq(msg.get_all('cc'), None) def test_list_headers_nolist(self): eq = self.assertEqual @@ -704,7 +843,7 @@ From: aperson@dom.ain '<http://www.dom.ain/mailman/listinfo/_xtest>,' '\n\t<mailto:_xtest-request@dom.ain?subject=subscribe>') eq(msg['list-post'], '<mailto:_xtest@dom.ain>') - eq(msg['list-archive'], '<http://www.dom.ain/pipermail/_xtest>') + eq(msg['list-archive'], '<http://www.dom.ain/pipermail/_xtest/>') def test_list_headers_with_description(self): eq = self.assertEqual @@ -862,7 +1001,8 @@ Content-Transfer-Encoding: 7bit Content-Disposition: inline footer ---BOUNDARY--""") +--BOUNDARY-- +""") def test_image(self): eq = self.assertEqual @@ -1221,7 +1361,8 @@ MIME-Version: 1.0 """) MimeDel.process(self._mlist, msg, {}) eq(msg.get_content_type(), 'text/plain') - eq(msg.get_payload(), '\n\n\n') + #eq(msg.get_payload(), '\n\n\n') + eq(msg.get_payload().strip(), '') def test_deep_structure(self): eq = self.assertEqual @@ -1630,7 +1771,8 @@ class TestReplybot(TestBase): class TestSpamDetect(TestBase): def test_short_circuit(self): msgdata = {'approved': 1} - rtn = SpamDetect.process(self._mlist, None, msgdata) + msg = email.message_from_string('') + rtn = SpamDetect.process(self._mlist, msg, msgdata) # Not really a great test, but there's little else to assert self.assertEqual(rtn, None) @@ -1878,7 +2020,9 @@ Here is message %(i)d mlist = self._mlist msg = self._makemsg(99) size = os.path.getsize(self._path) + len(str(msg)) - mlist.digest_size_threshhold = 0 + # Set digest_size_threshhold to a very small value to force a digest. + # Setting to zero no longer works. + mlist.digest_size_threshhold = 0.001 ToDigest.process(mlist, msg, {}) files = self._sb.files() # There should be two files in the queue, one for the MIME digest and |