summaryrefslogtreecommitdiff
path: root/src/mailman/rules/tests/test_approved.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/rules/tests/test_approved.py')
-rw-r--r--src/mailman/rules/tests/test_approved.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mailman/rules/tests/test_approved.py b/src/mailman/rules/tests/test_approved.py
index e7f122410..e0927bfc9 100644
--- a/src/mailman/rules/tests/test_approved.py
+++ b/src/mailman/rules/tests/test_approved.py
@@ -491,3 +491,34 @@ deprecated = roundup_plaintext
self.assertFalse(result)
self.assertEqual(self._mlist.moderator_password,
b'{plaintext}super secret')
+
+
+class TestApprovedNoPlainText(unittest.TestCase):
+ """Test the approved handler with HTML-only messages."""
+
+ layer = ConfigLayer
+
+ def setUp(self):
+ self._mlist = create_list('test@example.com')
+ self._rule = approved.Approved()
+
+ def test_noplaintext(self):
+ # When the message body only contains HTML, the rule should not throw
+ # AttributeError: 'NoneType' object has no attribute 'get_payload'
+ # LP: #1158721
+ msg = mfs("""\
+From: anne@example.com
+To: test@example.com
+Subject: HTML only email
+Message-ID: <ant>
+MIME-Version: 1.0
+Content-Type: text/html; charset="Windows-1251"
+Content-Transfer-Encoding: 7bit
+
+<HTML>
+<BODY>
+<P>This message contains only HTML, no plain/text part</P>
+</BODY></HTML>
+""")
+ result = self._rule.check(self._mlist, msg, {})
+ self.assertFalse(result)