diff --git a/api-ref/source/dns-api-v2-service-status.inc b/api-ref/source/dns-api-v2-service-status.inc index 533fa3e32..7b97236c8 100644 --- a/api-ref/source/dns-api-v2-service-status.inc +++ b/api-ref/source/dns-api-v2-service-status.inc @@ -10,7 +10,7 @@ using HTTP. List Statuses ============= -.. rest_method:: GET /v2/service_status +.. rest_method:: GET /v2/service_statuses List all Services and statuses. diff --git a/api-ref/source/samples/service_status/service_status_list.json b/api-ref/source/samples/service_status/service_status_list.json index e1fd684dc..c87ebbed5 100644 --- a/api-ref/source/samples/service_status/service_status_list.json +++ b/api-ref/source/samples/service_status/service_status_list.json @@ -2,7 +2,7 @@ "service_statuses": [ { "links": { - "self": "http://127.0.0.1:9001/v2/service_status/af91edb5-ede8-453f-af13-feabdd088f9c" + "self": "http://127.0.0.1:9001/v2/service_statuses/af91edb5-ede8-453f-af13-feabdd088f9c" }, "hostname": "dns-2.example.com.", "status": "UP", @@ -15,6 +15,6 @@ } ], "links": { - "self": "http://127.0.0.1:9001/v2/service_status" + "self": "http://127.0.0.1:9001/v2/service_statuses" } } diff --git a/designate/api/v2/controllers/root.py b/designate/api/v2/controllers/root.py index 33f9d01d2..8c0617ff5 100644 --- a/designate/api/v2/controllers/root.py +++ b/designate/api/v2/controllers/root.py @@ -58,6 +58,13 @@ class RootController(object): errors = errors.ErrorsController() pools = pools.PoolsController() service_statuses = service_status.ServiceStatusController() + + # This is a compatibility workaround for a mistake published in the + # Designate API reference that listed the URL path as /v2/service_status + # instead of /v2/service_statuses as it was implemented. + # https://bugs.launchpad.net/designate/+bug/1919183 + service_status = service_statuses + tsigkeys = tsigkeys.TsigKeysController() recordsets = recordsets.RecordSetsViewController() quotas = quotas.QuotasController() diff --git a/designate/tests/test_api/test_v2/test_service_status.py b/designate/tests/test_api/test_v2/test_service_status.py index cce470683..f9c440acb 100644 --- a/designate/tests/test_api/test_v2/test_service_status.py +++ b/designate/tests/test_api/test_v2/test_service_status.py @@ -46,6 +46,42 @@ class ApiV2ServiceStatusTest(ApiV2TestCase): self._assert_paging(data, '/service_statuses', key='service_statuses') + def test_legacy_list_service_status(self): + """Test the legacy list service status path. + + Historically the Designate API reference showed the list + service status URL path as /v2/service_status where the actual + path was /v2/service_statuses. + + https://bugs.launchpad.net/designate/+bug/1919183 + + A compatibility workaround was added as this was a published + API reference. This test covers that alternate URL path. + """ + + # Set the policy file as this is an admin-only API + self.policy({'find_service_statuses': '@'}) + + response = self.client.get('/service_status/') + + # Check the headers are what we expect + self.assertEqual(200, response.status_int) + self.assertEqual('application/json', response.content_type) + + # Check the body structure is what we expect + self.assertIn('service_statuses', response.json) + self.assertIn('links', response.json) + self.assertIn('self', response.json['links']) + + # Test with 0 service_statuses + # Seeing that Central is started there will be 1 here already.. + self.assertEqual(0, len(response.json['service_statuses'])) + + data = [self.update_service_status( + hostname="foo%s" % i, service_name="bar") for i in range(0, 10)] + + self._assert_paging(data, '/service_status', key='service_statuses') + def test_get_service_status(self): service_status = self.update_service_status(fixture=0) diff --git a/releasenotes/notes/fix-service-status-ba18270651011ee6.yaml b/releasenotes/notes/fix-service-status-ba18270651011ee6.yaml new file mode 100644 index 000000000..8b53c34f9 --- /dev/null +++ b/releasenotes/notes/fix-service-status-ba18270651011ee6.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixed an issue with the API reference using the wrong path for list + service statuses. In addition a compatibility workaround was added + for the incorrect /v2/service_status path.