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

Merge pull request #827 from octodns/at-sign-name-validation

Add a validation to catch name=@ and suggest name='' instead
This commit is contained in:
Ross McFarland
2022-01-01 13:58:35 -08:00
committed by GitHub
2 changed files with 13 additions and 0 deletions

View File

@@ -124,6 +124,8 @@ class Record(EqualityTupleMixin):
@classmethod
def validate(cls, name, fqdn, data):
reasons = []
if name == '@':
reasons.append('invalid name "@", use "" instead')
n = len(fqdn)
if n > 253:
reasons.append(f'invalid fqdn, "{fqdn}" is too long at {n} '

View File

@@ -1643,6 +1643,17 @@ class TestRecordValidation(TestCase):
zone = Zone('unit.tests.', [])
def test_base(self):
# name = '@'
with self.assertRaises(ValidationError) as ctx:
name = '@'
Record.new(self.zone, name, {
'ttl': 300,
'type': 'A',
'value': '1.2.3.4',
})
reason = ctx.exception.reasons[0]
self.assertTrue(reason.startswith('invalid name "@", use "" instead'))
# fqdn length, DNS defins max as 253
with self.assertRaises(ValidationError) as ctx:
# The . will put this over the edge