summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2022-08-14 10:33:50 -0700
committerBob Halley <halley@dnspython.org>2022-08-14 10:33:50 -0700
commit090102eec9d5ebd4d5faf9b3f957a0f2611a5581 (patch)
tree7c31e14d00d5b280560a039aa079ddad7c688d8e /tests
parentfc02926d24c0c17fc7be9bf27c3c8fdff042fdc2 (diff)
downloaddnspython-090102eec9d5ebd4d5faf9b3f957a0f2611a5581.tar.gz
allow zonefile directives to be specified explicitly
Diffstat (limited to 'tests')
-rw-r--r--tests/test_zone.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/test_zone.py b/tests/test_zone.py
index 2d10274..5dfa6ff 100644
--- a/tests/test_zone.py
+++ b/tests/test_zone.py
@@ -854,12 +854,75 @@ class ZoneTestCase(unittest.TestCase):
z2 = dns.zone.from_file(here("example"), "example.", relativize=True)
self.assertEqual(z1, z2)
+ def testNoInclude(self):
+ def bad():
+ dns.zone.from_text(
+ include_text, "example.", relativize=True, allow_include=False
+ )
+
+ self.assertRaises(dns.exception.SyntaxError, bad)
+
+ def testExplicitInclude(self):
+ z1 = dns.zone.from_text(
+ include_text,
+ "example.",
+ relativize=True,
+ allow_directives={"$INCLUDE", "$ORIGIN", "$TTL"},
+ )
+ z2 = dns.zone.from_file(here("example"), "example.", relativize=True)
+ self.assertEqual(z1, z2)
+
+ def testExplicitLowerCase(self):
+ z1 = dns.zone.from_text(
+ include_text,
+ "example.",
+ relativize=True,
+ allow_directives={"$include", "$origin", "$ttl"},
+ )
+ z2 = dns.zone.from_file(here("example"), "example.", relativize=True)
+ self.assertEqual(z1, z2)
+
+ def testExplicitWithoutInclude1(self):
+ def bad():
+ dns.zone.from_text(
+ include_text,
+ "example.",
+ relativize=True,
+ allow_include=False,
+ allow_directives={"$ORIGIN", "$TTL"},
+ )
+
+ self.assertRaises(dns.exception.SyntaxError, bad)
+
+ def testExplicitWithoutInclude2(self):
+ def bad():
+ dns.zone.from_text(
+ include_text,
+ "example.",
+ relativize=True,
+ allow_include=True,
+ allow_directives={"$ORIGIN", "$TTL"},
+ )
+
+ self.assertRaises(dns.exception.SyntaxError, bad)
+
def testBadDirective(self):
def bad():
dns.zone.from_text(bad_directive_text, "example.", relativize=True)
self.assertRaises(dns.exception.SyntaxError, bad)
+ def testAllowedButNotImplementedDirective(self):
+ def bad():
+ dns.zone.from_text(
+ bad_directive_text,
+ "example.",
+ relativize=True,
+ allow_directives={"$FOO", "$ORIGIN"},
+ )
+
+ self.assertRaises(dns.exception.SyntaxError, bad)
+
def testFirstRRStartsWithWhitespace(self):
# no name is specified, so default to the initial origin
z = dns.zone.from_text(