diff --git a/designate/api/v2/controllers/recordsets.py b/designate/api/v2/controllers/recordsets.py index 3d72dd683..ceb719e3f 100644 --- a/designate/api/v2/controllers/recordsets.py +++ b/designate/api/v2/controllers/recordsets.py @@ -53,6 +53,10 @@ class RecordSetsController(rest.RestController): request = pecan.request context = request.environ['context'] + # NOTE: We need to ensure the domain actually exists, otherwise we may + # return deleted recordsets instead of a domain not found + self.central_api.get_domain(context, zone_id) + # Extract the pagination params marker, limit, sort_key, sort_dir = self._get_paging_params(params) diff --git a/designate/tests/test_api/test_v2/test_recordsets.py b/designate/tests/test_api/test_v2/test_recordsets.py index e87cf80ac..5ad855cff 100644 --- a/designate/tests/test_api/test_v2/test_recordsets.py +++ b/designate/tests/test_api/test_v2/test_recordsets.py @@ -225,13 +225,29 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def test_get_recordsets_invalid_id(self): self._assert_invalid_uuid(self.client.get, '/zones/%s/recordsets') - @patch.object(central_service.Service, 'find_recordsets', + @patch.object(central_service.Service, 'get_domain', side_effect=messaging.MessagingTimeout()) def test_get_recordsets_timeout(self, _): url = '/zones/ba751950-6193-11e3-949a-0800200c9a66/recordsets' self._assert_exception('timeout', 504, self.client.get, url) + def test_get_deleted_recordsets(self): + zone = self.create_domain(fixture=1) + self.create_recordset(zone) + url = '/zones/%s/recordsets' % zone['id'] + + response = self.client.get(url) + + # Check the headers are what we expect + self.assertEqual(200, response.status_int) + + # now delete the domain and get the recordsets + self.client.delete('/zones/%s' % zone['id'], status=204) + + # Check that we get a domain_not_found error + self._assert_exception('domain_not_found', 404, self.client.get, url) + def test_get_recordset(self): # Create a recordset recordset = self.create_recordset(self.domain)