From bb7da041fc63696c272ef296acb10a8cedb297a5 Mon Sep 17 00:00:00 2001 From: Mark Sapiro Date: Fri, 30 Dec 2016 23:17:47 -0800 Subject: Added test data for organizational domains and a mock to use it. Made a few test coverage tweaks. --- src/mailman/rules/docs/dmarc-mitigation.rst | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/mailman/rules/docs') diff --git a/src/mailman/rules/docs/dmarc-mitigation.rst b/src/mailman/rules/docs/dmarc-mitigation.rst index 7118a5be4..9a6fa5b9b 100644 --- a/src/mailman/rules/docs/dmarc-mitigation.rst +++ b/src/mailman/rules/docs/dmarc-mitigation.rst @@ -20,6 +20,12 @@ This returns p=reject for the example.biz domain and not for any others. >>> from mailman.rules.tests.test_dmarc import get_dns_resolver >>> patcher = get_dns_resolver() +And we do a similar thing to mock the organizational domain data. + + >>> from mailman.rules.tests.test_dmarc import get_org_data + >>> patcher2 = get_org_data() + + A message From: a domain without a DMARC policy does not set any flags. >>> from mailman.interfaces.mailinglist import DMARCMitigateAction @@ -31,7 +37,7 @@ A message From: a domain without a DMARC policy does not set any flags. ... ... """) >>> msgdata = {} - >>> with patcher as Resolver: + >>> with patcher as Resolver, patcher2 as urlopen: ... rule.check(mlist, msg, msgdata) False >>> msgdata == {} @@ -48,7 +54,7 @@ action is no_mitigation. ... ... """) >>> msgdata = {} - >>> with patcher as Resolver: + >>> with patcher as Resolver, patcher2 as urlopen: ... rule.check(mlist, msg, msgdata) False >>> msgdata == {} @@ -64,7 +70,7 @@ But with a different list setting, the message is flagged. ... ... """) >>> msgdata = {} - >>> with patcher as Resolver: + >>> with patcher as Resolver, patcher2 as urlopen: ... rule.check(mlist, msg, msgdata) False >>> msgdata['dmarc'] @@ -79,7 +85,7 @@ Subdomains which don't have a policy will check the organizational domain. ... ... """) >>> msgdata = {} - >>> with patcher as Resolver: + >>> with patcher as Resolver, patcher2 as urlopen: ... rule.check(mlist, msg, msgdata) False >>> msgdata['dmarc'] @@ -97,7 +103,7 @@ message. ... ... """) >>> msgdata = {} - >>> with patcher as Resolver: + >>> with patcher as Resolver, patcher2 as urlopen: ... rule.check(mlist, msg, msgdata) True >>> msgdata['dmarc'] @@ -116,7 +122,7 @@ We can reject the message with a default reason. ... ... """) >>> msgdata = {} - >>> with patcher as Resolver: + >>> with patcher as Resolver, patcher2 as urlopen: ... rule.check(mlist, msg, msgdata) True >>> msgdata['dmarc'] @@ -137,7 +143,7 @@ And, we can reject with a custom message. ... ... """) >>> msgdata = {} - >>> with patcher as Resolver: + >>> with patcher as Resolver, patcher2 as urlopen: ... rule.check(mlist, msg, msgdata) True >>> msgdata['dmarc'] -- cgit v1.2.3-70-g09d2