summaryrefslogtreecommitdiff
path: root/src/mailman/rules
diff options
context:
space:
mode:
authorMark Sapiro2016-11-03 18:18:00 -0700
committerMark Sapiro2016-11-03 18:18:00 -0700
commitfdac1fbf0016d53e59d59bee026c27be77bcaccb (patch)
tree0a94fdf8849a7792800afd8386ae86c99871e6b4 /src/mailman/rules
parent8e0795f728c86ac88fba8894a827081c7852451b (diff)
downloadmailman-fdac1fbf0016d53e59d59bee026c27be77bcaccb.tar.gz
mailman-fdac1fbf0016d53e59d59bee026c27be77bcaccb.tar.zst
mailman-fdac1fbf0016d53e59d59bee026c27be77bcaccb.zip
Fixed a minor issue in handlers/dmarc.py revealed in testing.
Added tests. Tweaked some docs.
Diffstat (limited to 'src/mailman/rules')
-rw-r--r--src/mailman/rules/docs/dmarc-moderation.rst25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/mailman/rules/docs/dmarc-moderation.rst b/src/mailman/rules/docs/dmarc-moderation.rst
index 91da762d3..fb9ac3ac5 100644
--- a/src/mailman/rules/docs/dmarc-moderation.rst
+++ b/src/mailman/rules/docs/dmarc-moderation.rst
@@ -78,21 +78,28 @@ Subdomains which don't have a policy will check the organizational domain.
The list's action can also be set to immediately discard or reject the
message.
+ >>> from mailman.interfaces.chain import ChainEvent
+ >>> from mailman.testing.helpers import event_subscribers
+ >>> def handler(event):
+ ... if isinstance(event, ChainEvent):
+ ... print(event.__class__.__name__,
+ ... event.chain.name, event.msg['message-id'])
>>> mlist.dmarc_moderation_action = DMARCModerationAction.discard
>>> msg = message_from_string("""\
... From: aperson@yahoo.com
... To: _xtest@example.com
... Subject: A posted message
+ ... Message-ID: <xxx_message_id@yahoo.com>
...
... """)
>>> msgdata = {}
- >>> rule.check(mlist, msg, msgdata)
+ >>> with event_subscribers(handler):
+ ... rule.check(mlist, msg, msgdata)
+ DiscardEvent discard <xxx_message_id@yahoo.com>
False
>>> msgdata['dmarc']
True
-The above needs to test that the message was discarded.
-
We can reject the message with a default reason.
>>> mlist.dmarc_moderation_action = DMARCModerationAction.reject
@@ -100,10 +107,13 @@ We can reject the message with a default reason.
... From: aperson@yahoo.com
... To: _xtest@example.com
... Subject: A posted message
+ ... Message-ID: <xxx_message_id@yahoo.com>
...
... """)
>>> msgdata = {}
- >>> rule.check(mlist, msg, msgdata)
+ >>> with event_subscribers(handler):
+ ... rule.check(mlist, msg, msgdata)
+ RejectEvent reject <xxx_message_id@yahoo.com>
False
>>> msgdata['dmarc']
True
@@ -148,6 +158,7 @@ There is now a reject message in the virgin queue.
From: aperson@yahoo.com
To: _xtest@example.com
Subject: A posted message
+ Message-ID: <xxx_message_id@yahoo.com>
X-Mailman-Rule-Hits: dmarc-moderation
<BLANKLINE>
<BLANKLINE>
@@ -161,10 +172,13 @@ And, we can reject with a custom message.
... From: aperson@yahoo.com
... To: _xtest@example.com
... Subject: A posted message
+ ... Message-ID: <xxx_message_id@yahoo.com>
...
... """)
>>> msgdata = {}
- >>> rule.check(mlist, msg, msgdata)
+ >>> with event_subscribers(handler):
+ ... rule.check(mlist, msg, msgdata)
+ RejectEvent reject <xxx_message_id@yahoo.com>
False
>>> msgdata['dmarc']
True
@@ -204,6 +218,7 @@ Check the the virgin queue.
From: aperson@yahoo.com
To: _xtest@example.com
Subject: A posted message
+ Message-ID: <xxx_message_id@yahoo.com>
X-Mailman-Rule-Hits: dmarc-moderation
<BLANKLINE>
<BLANKLINE>