summaryrefslogtreecommitdiff
path: root/src/mailman/rules/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/rules/tests/test_dmarc.py
parent71d01e786839f70a863ef2711fd2a173c0b5785d (diff)
downloadmailman-f308782d733373246ba3b3bb42d1d6e68695f8f3.tar.gz
mailman-f308782d733373246ba3b3bb42d1d6e68695f8f3.tar.zst
mailman-f308782d733373246ba3b3bb42d1d6e68695f8f3.zip
Diffstat (limited to 'src/mailman/rules/tests/test_dmarc.py')
-rw-r--r--src/mailman/rules/tests/test_dmarc.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mailman/rules/tests/test_dmarc.py b/src/mailman/rules/tests/test_dmarc.py
index 666375699..16cf947cc 100644
--- a/src/mailman/rules/tests/test_dmarc.py
+++ b/src/mailman/rules/tests/test_dmarc.py
@@ -21,9 +21,11 @@ organizational domain tests."""
from dns.rdatatype import TXT
from dns.resolver import NXDOMAIN, NoAnswer
from mailman.rules import dmarc
+from mailman.testing.helpers import LogFileMark
from mailman.testing.layers import ConfigLayer
from public import public
from unittest import TestCase, mock
+from urllib.error import URLError
@public
@@ -108,3 +110,16 @@ class TestDMARCRules(TestCase):
def test_exception_to_wild_card(self):
self.assertEqual(
dmarc._get_org_dom('ssub.sub.city.kobe.jp'), 'city.kobe.jp')
+
+ def test_no_publicsuffix_dot_org(self):
+ mark = LogFileMark('mailman.error')
+ with mock.patch('mailman.rules.dmarc.request.urlopen',
+ side_effect=URLError('no internet')):
+ domain = dmarc._get_org_dom('ssub.sub.city.kobe.jp')
+ self.assertEqual(domain, 'kobe.jp')
+ line = mark.readline()
+ self.assertEqual(
+ line[-95:],
+ 'Unable to retrieve data from '
+ 'https://publicsuffix.org/list/public_suffix_list.dat: '
+ 'no internet\n')