Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed status validation. Fixes bug 960884.
Fixed the status value validation in os-hosts extension and added a negative
scenario in unit test for os-hosts extension.

Change-Id: Ib4166757561e531494a1a4d3070d7c8971b57dc5
  • Loading branch information
Unmesh Gurjar committed Mar 22, 2012
1 parent 66e152f commit b15bfc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nova/api/openstack/compute/contrib/hosts.py
Expand Up @@ -138,7 +138,7 @@ def update(self, req, id, body):
key = raw_key.lower().strip()
val = raw_val.lower().strip()
if key == "status":
if val[:6] in ("enable", "disabl"):
if val in ("enable", "disable"):
update_values['status'] = val.startswith("enable")
else:
explanation = _("Invalid status: '%s'") % raw_val
Expand Down
3 changes: 3 additions & 0 deletions nova/tests/api/openstack/compute/contrib/test_hosts.py
Expand Up @@ -159,6 +159,9 @@ def test_bad_status_value(self):
bad_body = {"status": "bad"}
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
self.req, "host_c1", body=bad_body)
bad_body2 = {"status": "disablabc"}
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
self.req, "host_c1", body=bad_body2)

def test_bad_update_key(self):
bad_body = {"crazy": "bad"}
Expand Down

0 comments on commit b15bfc2

Please sign in to comment.