diff --git a/designate/central/service.py b/designate/central/service.py index 7be9a8123..4a5ae9ee6 100644 --- a/designate/central/service.py +++ b/designate/central/service.py @@ -156,25 +156,6 @@ class Service(rpc_service.Service): 'share a name with any ' 'other records') - if record_type == 'CNAME': - # CNAME's may not have children. Ever. - criterion = {'name': '%%.%s' % record_name} - records = self.storage_api.find_records(context, domain['id'], - criterion=criterion) - - if len(records) > 0: - raise exceptions.InvalidRecordLocation('CNAME records may not ' - 'have any child ' - 'records') - - else: - # No record may have a CNAME as a parent - if self._is_subrecord(context, domain, record_name, - {'type': 'CNAME'}): - raise exceptions.InvalidRecordLocation('CNAME records may not ' - 'have any child ' - 'records') - # Duplicate PTR's with the same name are not allowed if record_type == 'PTR': criterion = {'name': record_name, 'type': 'PTR'} diff --git a/designate/tests/test_central/test_service.py b/designate/tests/test_central/test_service.py index 80b8b4d91..215fa0257 100644 --- a/designate/tests/test_central/test_service.py +++ b/designate/tests/test_central/test_service.py @@ -800,12 +800,12 @@ class CentralServiceTest(CentralTestCase): self.central_service.create_record(context, domain['id'], values=values) - def test_create_cname_record_alongside_an_a_record(self): + def test_create_cname_record_above_an_a_record(self): context = self.get_admin_context() domain = self.create_domain() values = dict( - name='www.%s' % domain['name'], + name='t.www.%s' % domain['name'], type='A', data='127.0.0.1' ) @@ -813,23 +813,49 @@ class CentralServiceTest(CentralTestCase): self.central_service.create_record(context, domain['id'], values=values) - # Attempt to create a CNAME record alongside an A record - with self.assertRaises(exceptions.InvalidRecordLocation): - values = dict( - name='www.%s' % domain['name'], - type='CNAME', - data='example.org.' - ) + # Create a CNAME record alongside an A record + values = dict( + name='www.%s' % domain['name'], + type='CNAME', + data='example.org.' + ) - self.central_service.create_record(context, domain['id'], - values=values) + record = self.central_service.create_record(context, domain['id'], + values=values) - def test_create_cname_record_above_an_a_record(self): + self.assertIn('id', record) + + def test_create_cname_record_below_an_a_record(self): context = self.get_admin_context() domain = self.create_domain() values = dict( - name='t.www.%s' % domain['name'], + name='t.%s' % domain['name'], + type='A', + data='127.0.0.1' + ) + + self.central_service.create_record(context, domain['id'], + values=values) + + # Create a CNAME record alongside an A record + values = dict( + name='www.t.%s' % domain['name'], + type='CNAME', + data='example.org.' + ) + + record = self.central_service.create_record(context, domain['id'], + values=values) + + self.assertIn('id', record) + + def test_create_cname_record_alongside_an_a_record(self): + context = self.get_admin_context() + domain = self.create_domain() + + values = dict( + name='www.%s' % domain['name'], type='A', data='127.0.0.1' ) @@ -872,30 +898,6 @@ class CentralServiceTest(CentralTestCase): self.central_service.create_record(context, domain['id'], values=values) - def test_create_an_a_record_below_a_cname_record(self): - context = self.get_admin_context() - domain = self.create_domain() - - values = dict( - name='www.%s' % domain['name'], - type='CNAME', - data='example.org.' - ) - - self.central_service.create_record(context, domain['id'], - values=values) - - # Attempt to create a CNAME record alongside an A record - with self.assertRaises(exceptions.InvalidRecordLocation): - values = dict( - name='t.www.%s' % domain['name'], - type='A', - data='127.0.0.1' - ) - - self.central_service.create_record(context, domain['id'], - values=values) - def test_create_duplicate_ptr_record(self): context = self.get_admin_context() domain = self.create_domain(values={'name': '2.0.192.in-addr.arpa.'})