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:
@@ -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 = '@'
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user