summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-02-18 02:49:58 +0000
committerGerrit Code Review <review@openstack.org>2022-02-18 02:49:58 +0000
commit99fe04953f3fe67298ceac6aee3025df5366e830 (patch)
tree0598d3e05f1e3f3eafbd6ce9c1ebf70bb1ca06b7
parentd2017f5399c6aaa04307be410877ed21cf61fce8 (diff)
parent2e6611b112df9d32128103ba72e46819840c003f (diff)
downloaddesignate-99fe04953f3fe67298ceac6aee3025df5366e830.tar.gz
Merge "Fix API reference for list service statuses"
-rw-r--r--api-ref/source/dns-api-v2-service-status.inc2
-rw-r--r--api-ref/source/samples/service_status/service_status_list.json4
-rw-r--r--designate/api/v2/controllers/root.py7
-rw-r--r--designate/tests/test_api/test_v2/test_service_status.py36
-rw-r--r--releasenotes/notes/fix-service-status-ba18270651011ee6.yaml6
5 files changed, 52 insertions, 3 deletions
diff --git a/api-ref/source/dns-api-v2-service-status.inc b/api-ref/source/dns-api-v2-service-status.inc
index 533fa3e3..7b97236c 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 e1fd684d..c87ebbed 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 33f9d01d..8c0617ff 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 cce47068..f9c440ac 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 00000000..8b53c34f
--- /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.