Merge "Validate MX records during recordset create or update"

This commit is contained in:
Zuul 2022-08-29 22:26:14 +00:00 committed by Gerrit Code Review
commit 71c7542a89
2 changed files with 15 additions and 1 deletions

View File

@ -35,6 +35,9 @@ class MX(Record):
if repr(int(priority)) != priority:
raise ValueError('Value is not an integer')
if not exchange.endswith('.'):
raise ValueError('Domain %s does not end with a dot' % exchange)
self.priority = int(priority)
self.exchange = exchange

View File

@ -34,7 +34,18 @@ class RRDataMXTest(oslotest.base.BaseTestCase):
record_set = objects.RecordSet(
name='www.example.org.', type='MX',
records=objects.RecordList(objects=[
objects.Record(data='-0 mail.example.org.',
objects.Record(data='-0 mail.example.test.',
status='ACTIVE'),
])
)
self.assertRaises(InvalidObject, record_set.validate)
def test_validate_mx_not_fqdn(self):
record_set = objects.RecordSet(
name='www.example.org.', type='MX',
records=objects.RecordList(objects=[
objects.Record(data='10 mail.example.test',
status='ACTIVE'),
])
)