Merge "Return 204 instead of 200 for root-disable API"

This commit is contained in:
Zuul 2018-03-07 05:14:42 +00:00 committed by Gerrit Code Review
commit e6600ccc1a
8 changed files with 12 additions and 7 deletions

View File

@ -1,4 +1,4 @@
HTTP/1.1 200 OK
HTTP/1.1 204 No Content
Content-Type: application/json
Content-Length: 0
Date: Mon, 18 Mar 2013 19:09:17 GMT

View File

@ -92,7 +92,7 @@ Disable root user
Disables the root user.
Normal response codes: 202
Normal response codes: 204
Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404), badMethod(405), overLimit(413), unprocessableEntity(422),

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Peviously root disable API returns a HTTP 200 response without any content,
a HTTP 204 reponse which is more appropriate will be returned now.

View File

@ -120,7 +120,7 @@ class DefaultRootController(BaseDatastoreRootController):
if not is_root_enabled:
raise exception.RootHistoryNotFound()
models.Root.delete(context, instance_id)
return wsgi.Result(None, 200)
return wsgi.Result(None, 204)
class ClusterRootController(DefaultRootController):

View File

@ -184,5 +184,5 @@ class TestRoot(object):
reh = self.dbaas_admin.management.root_enabled_history
self.root_enabled_timestamp = reh(instance_info.id).enabled
self.dbaas.root.delete(instance_info.id)
assert_equal(200, self.dbaas.last_http_code)
assert_equal(204, self.dbaas.last_http_code)
self._verify_root_timestamp(instance_info.id)

View File

@ -124,7 +124,7 @@ class TestRootOnCreate(object):
is still enabled.
"""
self.dbaas.root.delete(self.instance_id)
assert_equal(200, self.dbaas.last_http_code)
assert_equal(204, self.dbaas.last_http_code)
enabled = self.enabled(self.instance_id).rootEnabled
assert_equal(200, self.dbaas.last_http_code)

View File

@ -508,7 +508,7 @@ class Root(Example):
self.snippet(
"disable_root_user",
"/instances/%s/root" % json_instance.id,
"DELETE", 200, "OK",
"DELETE", 204, "No Content",
lambda client: client.root.delete(json_instance.id))
# restore root for subsequent tests

View File

@ -120,7 +120,7 @@ class RootActionsRunner(TestRunner):
raise SkipTest("No valid root password defined in %s."
% self.test_helper.get_class_name())
def run_disable_root(self, expected_http_code=200):
def run_disable_root(self, expected_http_code=204):
self.restored_root_creds2 = list(self.current_root_creds)
self.assert_root_disable(self.instance_info.id, expected_http_code)