Getting deleted recordsets returns a 404

Getting recordsets of a deleted domain from the
v2 api now returns a domain_not_found exception
similar to v1

Change-Id: I3532ddd139f534b5ac77c1fdfdd7c4cc326e1f5c
Closes-Bug: 1367954
This commit is contained in:
Vinod Mangalpally 2014-09-10 18:27:53 -05:00
parent 8f78272ca9
commit a31e41ecac
2 changed files with 21 additions and 1 deletions

View File

@ -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)

View File

@ -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)