summaryrefslogtreecommitdiff
path: root/src/mailman/handlers/tests/test_dmarc.py
diff options
context:
space:
mode:
authorBarry Warsaw2016-12-30 16:43:52 -0500
committerBarry Warsaw2016-12-30 16:43:52 -0500
commitf308782d733373246ba3b3bb42d1d6e68695f8f3 (patch)
treea7752d358fb0f9d40a848a8f9e9e07ef09201330 /src/mailman/handlers/tests/test_dmarc.py
parent71d01e786839f70a863ef2711fd2a173c0b5785d (diff)
downloadmailman-f308782d733373246ba3b3bb42d1d6e68695f8f3.tar.gz
mailman-f308782d733373246ba3b3bb42d1d6e68695f8f3.tar.zst
mailman-f308782d733373246ba3b3bb42d1d6e68695f8f3.zip
Diffstat (limited to 'src/mailman/handlers/tests/test_dmarc.py')
-rw-r--r--src/mailman/handlers/tests/test_dmarc.py54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/mailman/handlers/tests/test_dmarc.py b/src/mailman/handlers/tests/test_dmarc.py
index 4a9375b7f..6fe15bd18 100644
--- a/src/mailman/handlers/tests/test_dmarc.py
+++ b/src/mailman/handlers/tests/test_dmarc.py
@@ -170,12 +170,18 @@ Content-Transfer-Encoding: 7bit
--=====abc==--
""")
- def test_action_munge_from_display_name_in_from(self):
+ def test_action_munge_multiple_froms(self):
self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from
- msgdata = {'dmarc': True}
+ msgdata = dict(
+ dmarc=True,
+ original_sender='cate@example.com',
+ )
msg = mfs(self._text)
+ # Put multiple addresses in the From: header. The msgdata must
+ # contain a key naming the "original sender" as determined by the
+ # Message.sender attribute.
del msg['from']
- msg['From'] = 'Anne Person <anne@example.com>'
+ msg['From'] = 'anne@example.com, bart@example.com'
dmarc.process(self._mlist, msg, msgdata)
self.assertMultiLineEqual(msg.as_string(), """\
To: ant@example.com
@@ -186,8 +192,8 @@ Date: Fri, 1 Jan 2016 00:00:01 +0000
Another-Header: To test removal in wrapper
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="=====abc=="
-From: Anne Person via Ant <ant@example.com>
-Reply-To: Anne Person <anne@example.com>
+From: cate--- via Ant <ant@example.com>
+Reply-To: cate@example.com
--=====abc==
Content-Type: text/plain; charset="us-ascii"
@@ -202,26 +208,24 @@ Content-Transfer-Encoding: 7bit
--=====abc==--
""")
- def test_action_munge_from_display_name_in_list(self):
+ def test_action_munge_from_display_name_in_from(self):
self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from
- add_member(
- self._mlist,
- RequestRecord('anne@example.com', 'Anna Banana')
- )
msgdata = {'dmarc': True}
msg = mfs(self._text)
+ del msg['from']
+ msg['From'] = 'Anne Person <anne@example.com>'
dmarc.process(self._mlist, msg, msgdata)
self.assertMultiLineEqual(msg.as_string(), """\
To: ant@example.com
Subject: A subject
X-Mailman-Version: X.Y
-Message-ID: <some-id@example.com>
+Message-ID: <alpha@example.com>
Date: Fri, 1 Jan 2016 00:00:01 +0000
Another-Header: To test removal in wrapper
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="=====abc=="
-From: Anna Banana via Ant <ant@example.com>
-Reply-To: anne@example.com
+From: Anne Person via Ant <ant@example.com>
+Reply-To: Anne Person <anne@example.com>
--=====abc==
Content-Type: text/plain; charset="us-ascii"
@@ -236,18 +240,14 @@ Content-Transfer-Encoding: 7bit
--=====abc==--
""")
- def test_action_munge_multiple_froms(self):
+ def test_action_munge_from_display_name_in_list(self):
self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from
- msg = mfs(self._text)
- # Put multiple addresses in the From: header. The msgdata must
- # contain a key naming the "original sender" as determined by the
- # Message.sender attribute.
- del msg['from']
- msg['From'] = 'anne@example.com, bart@example.com'
- msgdata = dict(
- dmarc=True,
- original_sender='cate@example.com',
+ add_member(
+ self._mlist,
+ RequestRecord('anne@example.com', 'Anna Banana')
)
+ msgdata = {'dmarc': True}
+ msg = mfs(self._text)
dmarc.process(self._mlist, msg, msgdata)
self.assertMultiLineEqual(msg.as_string(), """\
To: ant@example.com
@@ -258,8 +258,8 @@ Date: Fri, 1 Jan 2016 00:00:01 +0000
Another-Header: To test removal in wrapper
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="=====abc=="
-From: cate --- via Ant <ant@example.com>
-Reply-To: cate@example.com
+From: Anna Banana via Ant <ant@example.com>
+Reply-To: anne@example.com
--=====abc==
Content-Type: text/plain; charset="us-ascii"
@@ -320,7 +320,7 @@ Content-Transfer-Encoding: 7bit
To: ant@example.com
Subject: A subject
X-Mailman-Version: X.Y
-Message-ID: <some-id@example.com>
+Message-ID: <alpha@example.com>
Date: Fri, 1 Jan 2016 00:00:01 +0000
Another-Header: To test removal in wrapper
MIME-Version: 1.0
@@ -419,7 +419,7 @@ Content-Disposition: inline
To: ant@example.com
Subject: A subject
X-Mailman-Version: X.Y
-Message-ID: <some-id@example.com>
+Message-ID: <alpha@example.com>
Date: Fri, 1 Jan 2016 00:00:01 +0000
Another-Header: To test removal in wrapper
MIME-Version: 1.0