Merge "Make rebuilds with an emtpy name raise BadRequest."

This commit is contained in:
Jenkins 2012-04-28 12:10:18 +00:00 committed by Gerrit Code Review
commit 76bb37e049
2 changed files with 15 additions and 1 deletions

View File

@ -271,7 +271,10 @@ class ActionDeserializer(CommonDeserializer):
def _action_rebuild(self, node):
rebuild = {}
if node.hasAttribute("name"):
rebuild['name'] = node.getAttribute("name")
name = node.getAttribute("name")
if not name:
raise AttributeError("Name cannot be blank")
rebuild['name'] = name
if node.hasAttribute("auto_disk_config"):
rebuild['auto_disk_config'] = node.getAttribute("auto_disk_config")

View File

@ -887,3 +887,14 @@ class TestServerActionXMLDeserializer(test.TestCase):
self.deserializer.deserialize,
serial_request,
'action')
def test_rebuild_blank_name(self):
serial_request = """<?xml version="1.0" encoding="UTF-8"?>
<rebuild
xmlns="http://docs.openstack.org/compute/api/v1.1"
imageRef="http://localhost/images/1"
name=""/>"""
self.assertRaises(AttributeError,
self.deserializer.deserialize,
serial_request,
'action')