summaryrefslogtreecommitdiff
path: root/src/mailman/chains/tests/test_headers.py
diff options
context:
space:
mode:
authorMark Sapiro2016-09-29 16:35:13 -0700
committerBarry Warsaw2016-10-22 18:22:15 -0400
commitb4e207583370fa784fa63905897c13bb0b05bc23 (patch)
tree8e64595cdcf90426715af47c5d00fcf8289b9811 /src/mailman/chains/tests/test_headers.py
parent3cf613f56e44bed4bc45f533e6f6263288e66460 (diff)
downloadmailman-b4e207583370fa784fa63905897c13bb0b05bc23.tar.gz
mailman-b4e207583370fa784fa63905897c13bb0b05bc23.tar.zst
mailman-b4e207583370fa784fa63905897c13bb0b05bc23.zip
Diffstat (limited to 'src/mailman/chains/tests/test_headers.py')
-rw-r--r--src/mailman/chains/tests/test_headers.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/mailman/chains/tests/test_headers.py b/src/mailman/chains/tests/test_headers.py
index e21fa452d..6bba6c1b6 100644
--- a/src/mailman/chains/tests/test_headers.py
+++ b/src/mailman/chains/tests/test_headers.py
@@ -169,6 +169,46 @@ class TestHeaderChain(unittest.TestCase):
('baz', 'z+', LinkAction.jump, 'accept'),
]) # noqa: E124
+ def test_header_in_subpart(self):
+ # Test that headers in sub-parts are also matched.
+ msg = mfs("""\
+From: anne@example.com
+To: test@example.com
+Subject: A message
+Message-ID: <ant>
+Foo: foo
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="================12345=="
+
+--================12345==
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+
+A message body.
+
+--================12345==
+Content-Type: application/junk
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+
+This is junk
+
+--================12345==--
+""")
+ msgdata = {}
+ header_matches = IHeaderMatchList(self._mlist)
+ header_matches.append('Content-Type', 'application', 'hold')
+ # This event subscriber records the event that occurs when the message
+ # is processed by the owner chain.
+ events = []
+ with event_subscribers(events.append):
+ process(self._mlist, msg, msgdata, start_chain='header-match')
+ self.assertEqual(len(events), 1)
+ event = events[0]
+ self.assertIsInstance(event, HoldEvent)
+ self.assertEqual(event.chain, config.chains['hold'])
+
@configuration('antispam', header_checks="""
Foo: foo
""", jump_chain='hold')