diff options
author | Zuul <zuul@review.opendev.org> | 2022-08-29 22:26:14 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-08-29 22:26:14 +0000 |
commit | 71c7542a892d76a6631e919fdd7ecf636f834eaa (patch) | |
tree | b506976c56493951f2cc2810c497c0ab1324c9f4 | |
parent | 3207d71d547bcf519400c6c16192adf76886260a (diff) | |
parent | 536315e38ccc06193d9f8b83770aab8f671f6fa8 (diff) | |
download | designate-71c7542a892d76a6631e919fdd7ecf636f834eaa.tar.gz |
Merge "Validate MX records during recordset create or update"
-rw-r--r-- | designate/objects/rrdata_mx.py | 3 | ||||
-rw-r--r-- | designate/tests/unit/objects/test_rrdata_mx.py | 13 |
2 files changed, 15 insertions, 1 deletions
diff --git a/designate/objects/rrdata_mx.py b/designate/objects/rrdata_mx.py index 7d924358..99387d1e 100644 --- a/designate/objects/rrdata_mx.py +++ b/designate/objects/rrdata_mx.py @@ -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 diff --git a/designate/tests/unit/objects/test_rrdata_mx.py b/designate/tests/unit/objects/test_rrdata_mx.py index 1344bf26..9c9e4469 100644 --- a/designate/tests/unit/objects/test_rrdata_mx.py +++ b/designate/tests/unit/objects/test_rrdata_mx.py @@ -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'), ]) ) |