Skip to content

Commit

Permalink
Skip tests that require an internet connection when /etc/resolv.conf …
Browse files Browse the repository at this point in the history
…is missing
  • Loading branch information
seanthegeek committed Dec 26, 2024
1 parent 2947d42 commit e43a8ac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""Automated tests"""

import os
import unittest
from collections import OrderedDict

Expand Down Expand Up @@ -99,6 +100,7 @@ def testUppercaseSPFMechanism(self):

self.assertEqual(len(results["warnings"]), 0)

@unittest.skipUnless(os.path.exists("/etc/resolv.conf"), "no network")
def testSplitSPFRecord(self):
"""Split SPF records are parsed properly"""

Expand All @@ -108,6 +110,7 @@ def testSplitSPFRecord(self):

self.assertEqual(parsed_record["parsed"]["all"], "fail")

@unittest.skipUnless(os.path.exists("/etc/resolv.conf"), "no network")
def testJunkAfterAll(self):
"""Ignore any mechanisms after the all mechanism, but warn about it"""
rec = "v=spf1 ip4:213.5.39.110 -all MS=83859DAEBD1978F9A7A67D3"
Expand Down Expand Up @@ -140,6 +143,7 @@ def testIncludeMissingSPF(self):
domain,
)

@unittest.skipUnless(os.path.exists("/etc/resolv.conf"), "no network")
def testTooManySPFDNSLookups(self):
"""SPF records with > 10 SPF mechanisms that cause DNS lookups raise
SPFTooManyDNSLookups"""
Expand All @@ -161,6 +165,7 @@ def testTooManySPFDNSLookups(self):
domain,
)

@unittest.skipUnless(os.path.exists("/etc/resolv.conf"), "no network")
def testTooManySPFVoidDNSLookups(self):
"""SPF records with > 2 void DNS lookups"""

Expand Down Expand Up @@ -274,6 +279,7 @@ def testSPFIncludeLoop(self):
domain,
)

@unittest.skipUnless(os.path.exists("/etc/resolv.conf"), "no network")
def testSPFMissingMXRecord(self):
"""A warning is issued if an SPF record contains a mx mechanism
pointing to a domain that has no MX records"""
Expand All @@ -296,8 +302,9 @@ def testSPFMissingARecord(self):
"cardinalhealth.net does not have any A/AAAA records", results["warnings"]
)

@unittest.skipUnless(os.path.exists("/etc/resolv.conf"), "no network")
def testDMARCPctLessThan100Warning(self):
"""A warning is issued if the DMARC pvt value is less than 100"""
"""A warning is issued if the DMARC pct value is less than 100"""

dmarc_record = (
"v=DMARC1; p=none; sp=none; fo=1; pct=50; adkim=r; "
Expand Down Expand Up @@ -347,6 +354,7 @@ def testInvalidDMARCPolicyValue(self):
domain,
)

@unittest.skipUnless(os.path.exists("/etc/resolv.conf"), "no network")
def testBIMI(self):
"""Test BIMI checks"""
domain = "chase.com"
Expand Down

0 comments on commit e43a8ac

Please sign in to comment.