Merge "Check unknown event name when create external server event"
This commit is contained in:
commit
ed637dead2
@ -60,6 +60,10 @@ class ServerExternalEventsController(wsgi.Controller):
|
||||
raise webob.exc.HTTPBadRequest(
|
||||
_('Invalid event status `%s\'') % status)
|
||||
|
||||
if client_event.get('name') not in external_event_obj.EVENT_NAMES:
|
||||
raise webob.exc.HTTPBadRequest(
|
||||
_('Invalid event name %s') % client_event.get('name'))
|
||||
|
||||
try:
|
||||
event.instance_uuid = client_event.pop('server_uuid')
|
||||
event.name = client_event.pop('name')
|
||||
|
@ -12,7 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.api.validation import parameter_types
|
||||
from nova.objects import external_event as external_event_obj
|
||||
|
||||
create = {
|
||||
@ -26,7 +25,10 @@ create = {
|
||||
'server_uuid': {
|
||||
'type': 'string', 'format': 'uuid'
|
||||
},
|
||||
'name': parameter_types.name,
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'enum': external_event_obj.EVENT_NAMES
|
||||
},
|
||||
'status': {
|
||||
'type': 'string',
|
||||
'enum': external_event_obj.EVENT_STATUSES,
|
||||
|
@ -147,6 +147,12 @@ class ServerExternalEventsTestV21(test.NoDBTestCase):
|
||||
self.assertRaises(self.invalid_error,
|
||||
self.api.create, self.req, body=body)
|
||||
|
||||
def test_create_unkown_events(self):
|
||||
self.event_1['name'] = 'unkown_event'
|
||||
body = {'events': self.event_1}
|
||||
self.assertRaises(self.invalid_error,
|
||||
self.api.create, self.req, body=body)
|
||||
|
||||
|
||||
@mock.patch('nova.objects.instance.Instance.get_by_uuid', fake_get_by_uuid)
|
||||
class ServerExternalEventsTestV2(ServerExternalEventsTestV21):
|
||||
|
Loading…
Reference in New Issue
Block a user