From 5186ba9d8da150b8a07ea382c58ba5610e193f4c Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 23 Feb 2012 15:51:48 -0500 Subject: [PATCH] Test creating a server with metadata key too long. Related to bug 917484. Change-Id: Ie4bcf81741a268fd8319e1ecaad5639ad8c9b6f7 --- nova/tests/api/openstack/compute/test_servers.py | 30 ++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index ca2fdbc..87b75f2 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -1703,6 +1703,36 @@ class ServersControllerCreateTest(test.TestCase): self.assertRaises(webob.exc.HTTPRequestEntityTooLarge, self.controller.create, req, body) + def test_create_instance_metadata_key_too_long(self): + self.flags(quota_metadata_items=1) + image_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6' + image_href = 'http://localhost/v2/images/%s' % image_uuid + flavor_ref = 'http://localhost/123/flavors/3' + body = { + 'server': { + 'name': 'server_test', + 'imageRef': image_href, + 'flavorRef': flavor_ref, + 'metadata': { + ('trolololololololololololololololololololololololololo' + 'lololololololololololololololololololololololololololo' + 'lololololololololololololololololololololololololololo' + 'lololololololololololololololololololololololololololo' + 'lololololololololololololololololololololololololololo' + 'lololololololololololololololololololololololololololo' + 'lololololololololololo'): 'wut', + }, + }, + } + + req = fakes.HTTPRequest.blank('/v2/fake/servers') + req.method = 'POST' + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + + self.assertRaises(webob.exc.HTTPRequestEntityTooLarge, + self.controller.create, req, body) + def test_create_instance_invalid_key_name(self): image_href = 'http://localhost/v2/images/2' flavor_ref = 'http://localhost/flavors/3' -- 1.7.7.6