def test_anonymous_no_change(self): self._mlist.anonymous_list = True self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from msgdata = {'dmarc': True} msg = mfs(self._text) dmarc.process(self._mlist, msg, msgdata) self.assertMultiLineEqual(msg.as_string(), self._text)
def test_rfc2047_encoded_from(self): self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from msgdata = {'dmarc': True} msg = mfs(self._text) del msg['from'] msg['From'] = '=?iso-8859-1?Q?A_Pers=F3n?= <*****@*****.**>' dmarc.process(self._mlist, msg, msgdata) self.assertMultiLineEqual( msg.as_string(), """\ To: [email protected] Subject: A subject X-Mailman-Version: X.Y Message-ID: <*****@*****.**> 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: =?utf-8?q?A_Pers=C3=B3n_via_Ant?= <*****@*****.**> Reply-To: =?iso-8859-1?Q?A_Pers=F3n?= <*****@*****.**> --=====abc== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Some things to say. --=====abc== Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: 7bit <html><head></head><body>Some things to say.</body></html> --=====abc==-- """)
def test_from_in_cc(self): self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from self._mlist.reply_goes_to_list = ReplyToMunging.point_to_list msgdata = {'dmarc': True} msg = mfs(self._text) dmarc.process(self._mlist, msg, msgdata) self.assertMultiLineEqual( msg.as_string(), """\ To: [email protected] Subject: A subject X-Mailman-Version: X.Y Message-ID: <*****@*****.**> 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--- via Ant <*****@*****.**> Cc: [email protected] --=====abc== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Some things to say. --=====abc== Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: 7bit <html><head></head><body>Some things to say.</body></html> --=====abc==-- """)
def test_action_munge_from_display_name_in_list(self): self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from add_member(self._mlist, RequestRecord('*****@*****.**', 'Anna Banana')) msgdata = {'dmarc': True} msg = mfs(self._text) dmarc.process(self._mlist, msg, msgdata) self.assertMultiLineEqual( msg.as_string(), """\ To: [email protected] Subject: A subject X-Mailman-Version: X.Y Message-ID: <*****@*****.**> 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 <*****@*****.**> Reply-To: [email protected] --=====abc== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Some things to say. --=====abc== Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: 7bit <html><head></head><body>Some things to say.</body></html> --=====abc==-- """)
def test_action_munge_from_no_from(self): self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from msgdata = dict( dmarc=True, original_sender='*****@*****.**', ) msg = mfs(self._text) del msg['from'] dmarc.process(self._mlist, msg, msgdata) self.assertMultiLineEqual( msg.as_string(), """\ To: [email protected] Subject: A subject X-Mailman-Version: X.Y Message-ID: <*****@*****.**> 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--- via Ant <*****@*****.**> Reply-To: [email protected] --=====abc== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Some things to say. --=====abc== Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: 7bit <html><head></head><body>Some things to say.</body></html> --=====abc==-- """)
def test_wrap_message(self): self._mlist.dmarc_mitigate_action = DMARCMitigateAction.wrap_message msgdata = {'dmarc': True} msg = mfs(self._text) dmarc.process(self._mlist, msg, msgdata) # We can't predict the Message-ID in the wrapper so delete it, but # ensure we have one. self.assertIsNotNone(msg.get('message-id')) del msg['message-id'] self.assertMultiLineEqual( msg.as_string(), """\ To: [email protected] Subject: A subject X-Mailman-Version: X.Y Date: Fri, 1 Jan 2016 00:00:01 +0000 MIME-Version: 1.0 From: anne--- via Ant <*****@*****.**> Reply-To: [email protected] Content-Type: message/rfc822 Content-Disposition: inline """ + self._text)
def test_action_reject_mitigate_unconditionally(self): msg = mfs(self._text) self._mlist.dmarc_mitigate_unconditionally = True self._mlist.dmarc_mitigate_action = DMARCMitigateAction.reject dmarc.process(self._mlist, msg, {}) self.assertMultiLineEqual(msg.as_string(), self._text)
def test_no_mitigation_no_change_2(self): msg = mfs(self._text) msgdata = {'dmarc': True} dmarc.process(self._mlist, msg, msgdata) self.assertMultiLineEqual(msg.as_string(), self._text)
def test_no_mitigation_no_change_1(self): msg = mfs(self._text) self._mlist.dmarc_mitigate_unconditionally = True dmarc.process(self._mlist, msg, {}) self.assertMultiLineEqual(msg.as_string(), self._text)
def test_default_no_change(self): msg = mfs(self._text) dmarc.process(self._mlist, msg, {}) self.assertMultiLineEqual(msg.as_string(), self._text)
def test_no_action_without_msgdata(self): self._mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from msg = mfs(self._text) dmarc.process(self._mlist, msg, {}) self.assertMultiLineEqual(msg.as_string(), self._text)