1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Validations to ensure Record.name and Zone.name have no whitespace

This commit is contained in:
Ross McFarland
2023-05-19 09:57:56 -07:00
parent eca3e108e3
commit cfa7abaee5
6 changed files with 39 additions and 1 deletions

View File

@@ -398,6 +398,28 @@ class TestRecordValidation(TestCase):
zone = Zone('unit.tests.', [])
def test_base(self):
# no spaces
for name in (
' ',
' leading',
'trailing ',
'in the middle',
'\t',
'\tleading',
'trailing\t',
'in\tthe\tmiddle',
):
with self.assertRaises(ValidationError) as ctx:
Record.new(
self.zone,
name,
{'ttl': 300, 'type': 'A', 'value': '1.2.3.4'},
)
reason = ctx.exception.reasons[0]
self.assertEqual(
'invalid record, whitespace is not allowed', reason
)
# name = '@'
with self.assertRaises(ValidationError) as ctx:
name = '@'

View File

@@ -186,6 +186,11 @@ class TestZone(TestCase):
Zone('not.allowed', [])
self.assertTrue('missing ending dot' in str(ctx.exception))
def test_whitespace(self):
with self.assertRaises(Exception) as ctx:
Zone('space not allowed.', [])
self.assertTrue('whitespace not allowed' in str(ctx.exception))
def test_sub_zones(self):
# NS for exactly the sub is allowed