Browse Source

Only allow ALIAS on APEX

pull/621/head
Ross McFarland 5 years ago
parent
commit
19798e3acf
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
7 changed files with 28 additions and 73 deletions
  1. +8
    -0
      octodns/record/__init__.py
  2. +0
    -37
      tests/fixtures/constellix-records.json
  3. +0
    -14
      tests/fixtures/dnsmadeeasy-records.json
  4. +3
    -9
      tests/test_octodns_provider_constellix.py
  5. +3
    -9
      tests/test_octodns_provider_dnsmadeeasy.py
  6. +2
    -2
      tests/test_octodns_provider_mythicbeasts.py
  7. +12
    -2
      tests/test_octodns_record.py

+ 8
- 0
octodns/record/__init__.py View File

@ -782,6 +782,14 @@ class AliasRecord(_ValueMixin, Record):
_type = 'ALIAS'
_value_type = AliasValue
@classmethod
def validate(cls, name, fqdn, data):
reasons = []
if name != '':
reasons.append('non-root ALIAS not allowed')
reasons.extend(super(AliasRecord, cls).validate(name, fqdn, data))
return reasons
class CaaValue(EqualityTupleMixin):
# https://tools.ietf.org/html/rfc6844#page-5


+ 0
- 37
tests/fixtures/constellix-records.json View File

@ -523,43 +523,6 @@
"roundRobinFailover": [],
"pools": [],
"poolsDetail": []
}, {
"id": 1808603,
"type": "ANAME",
"recordType": "aname",
"name": "sub",
"recordOption": "roundRobin",
"noAnswer": false,
"note": "",
"ttl": 1800,
"gtdRegion": 1,
"parentId": 123123,
"parent": "domain",
"source": "Domain",
"modifiedTs": 1565153387855,
"value": [{
"value": "aname.unit.tests.",
"disableFlag": false
}],
"roundRobin": [{
"value": "aname.unit.tests.",
"disableFlag": false
}],
"geolocation": null,
"recordFailover": {
"disabled": false,
"failoverType": 1,
"failoverTypeStr": "Normal (always lowest level)",
"values": []
},
"failover": {
"disabled": false,
"failoverType": 1,
"failoverTypeStr": "Normal (always lowest level)",
"values": []
},
"pools": [],
"poolsDetail": []
}, {
"id": 1808520,
"type": "A",


+ 0
- 14
tests/fixtures/dnsmadeeasy-records.json View File

@ -320,20 +320,6 @@
"name": "",
"value": "aname.unit.tests.",
"id": 11189895,
"type": "ANAME"
}, {
"failover": false,
"monitor": false,
"sourceId": 123123,
"dynamicDns": false,
"failed": false,
"gtdLocation": "DEFAULT",
"hardLink": false,
"ttl": 1800,
"source": 1,
"name": "sub",
"value": "aname",
"id": 11189896,
"type": "ANAME"
}, {
"failover": false,


+ 3
- 9
tests/test_octodns_provider_constellix.py View File

@ -42,12 +42,6 @@ class TestConstellixProvider(TestCase):
'value': 'aname.unit.tests.'
}))
expected.add_record(Record.new(expected, 'sub', {
'ttl': 1800,
'type': 'ALIAS',
'value': 'aname.unit.tests.'
}))
for record in list(expected.records):
if record.name == 'sub' and record._type == 'NS':
expected._remove_record(record)
@ -107,14 +101,14 @@ class TestConstellixProvider(TestCase):
zone = Zone('unit.tests.', [])
provider.populate(zone)
self.assertEquals(15, len(zone.records))
self.assertEquals(14, len(zone.records))
changes = self.expected.changes(zone, provider)
self.assertEquals(0, len(changes))
# 2nd populate makes no network calls/all from cache
again = Zone('unit.tests.', [])
provider.populate(again)
self.assertEquals(15, len(again.records))
self.assertEquals(14, len(again.records))
# bust the cache
del provider._zone_records[zone.name]
@ -169,7 +163,7 @@ class TestConstellixProvider(TestCase):
}),
])
self.assertEquals(18, provider._client._request.call_count)
self.assertEquals(17, provider._client._request.call_count)
provider._client._request.reset_mock()


+ 3
- 9
tests/test_octodns_provider_dnsmadeeasy.py View File

@ -44,12 +44,6 @@ class TestDnsMadeEasyProvider(TestCase):
'value': 'aname.unit.tests.'
}))
expected.add_record(Record.new(expected, 'sub', {
'ttl': 1800,
'type': 'ALIAS',
'value': 'aname.unit.tests.'
}))
for record in list(expected.records):
if record.name == 'sub' and record._type == 'NS':
expected._remove_record(record)
@ -108,14 +102,14 @@ class TestDnsMadeEasyProvider(TestCase):
zone = Zone('unit.tests.', [])
provider.populate(zone)
self.assertEquals(15, len(zone.records))
self.assertEquals(14, len(zone.records))
changes = self.expected.changes(zone, provider)
self.assertEquals(0, len(changes))
# 2nd populate makes no network calls/all from cache
again = Zone('unit.tests.', [])
provider.populate(again)
self.assertEquals(15, len(again.records))
self.assertEquals(14, len(again.records))
# bust the cache
del provider._zone_records[zone.name]
@ -180,7 +174,7 @@ class TestDnsMadeEasyProvider(TestCase):
'port': 30
}),
])
self.assertEquals(27, provider._client._request.call_count)
self.assertEquals(26, provider._client._request.call_count)
provider._client._request.reset_mock()


+ 2
- 2
tests/test_octodns_provider_mythicbeasts.py View File

@ -171,7 +171,7 @@ class TestMythicBeastsProvider(TestCase):
def test_command_generation(self):
zone = Zone('unit.tests.', [])
zone.add_record(Record.new(zone, 'prawf-alias', {
zone.add_record(Record.new(zone, '', {
'ttl': 60,
'type': 'ALIAS',
'value': 'alias.unit.tests.',
@ -228,7 +228,7 @@ class TestMythicBeastsProvider(TestCase):
)
expected_commands = [
'ADD prawf-alias.unit.tests 60 ANAME alias.unit.tests.',
'ADD unit.tests 60 ANAME alias.unit.tests.',
'ADD prawf-ns.unit.tests 300 NS alias.unit.tests.',
'ADD prawf-ns.unit.tests 300 NS alias2.unit.tests.',
'ADD prawf-a.unit.tests 60 A 1.2.3.4',


+ 12
- 2
tests/test_octodns_record.py View File

@ -1710,6 +1710,16 @@ class TestRecordValidation(TestCase):
'value': 'foo.bar.com.',
})
# root only
with self.assertRaises(ValidationError) as ctx:
Record.new(self.zone, 'nope', {
'type': 'ALIAS',
'ttl': 600,
'value': 'foo.bar.com.',
})
self.assertEquals(['non-root ALIAS not allowed'],
ctx.exception.reasons)
# missing value
with self.assertRaises(ValidationError) as ctx:
Record.new(self.zone, '', {
@ -1720,7 +1730,7 @@ class TestRecordValidation(TestCase):
# missing value
with self.assertRaises(ValidationError) as ctx:
Record.new(self.zone, 'www', {
Record.new(self.zone, '', {
'type': 'ALIAS',
'ttl': 600,
'value': None
@ -1729,7 +1739,7 @@ class TestRecordValidation(TestCase):
# empty value
with self.assertRaises(ValidationError) as ctx:
Record.new(self.zone, 'www', {
Record.new(self.zone, '', {
'type': 'ALIAS',
'ttl': 600,
'value': ''


Loading…
Cancel
Save