From 81559a88884fdde14d6ca6bd788c0e37ca3d56cf Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Tue, 20 Dec 2011 20:34:15 +0000 Subject: Set Location header in server create and rebuild actions The API documentation states that the Location header should be filled with the URL of the server. This change implemnts this for both the create and rebuild actions. Change-Id: Ic0372aeaea58c9288065e2cfc222ca9257d35c87 --- nova/tests/api/openstack/v2/test_servers.py | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/v2/test_servers.py b/nova/tests/api/openstack/v2/test_servers.py index 23621fd7f..a792a8998 100644 --- a/nova/tests/api/openstack/v2/test_servers.py +++ b/nova/tests/api/openstack/v2/test_servers.py @@ -3813,3 +3813,42 @@ class ServerXMLSerializationTest(test.TestCase): str(ip['version'])) self.assertEqual(str(ip_elem.get('addr')), str(ip['addr'])) + + +class ServerHeadersSerializationTest(test.TestCase): + def test_create_location(self): + selfhref = 'http://localhost/v2/fake/servers/%s' % FAKE_UUID + bookhref = 'http://localhost/fake/servers/%s' % FAKE_UUID + + serializer = servers.HeadersSerializer() + response = webob.Response() + server = { + 'links': [{ + 'rel': 'self', + 'href': selfhref, + }, { + 'rel': 'bookmark', + 'href': bookhref, + }], + } + serializer.create(response, {'server': server}) + self.assertEqual(response.headers['Location'], selfhref) + + def test_rebuild_location(self): + selfhref = 'http://localhost/v2/fake/servers/%s' % FAKE_UUID + bookhref = 'http://localhost/fake/servers/%s' % FAKE_UUID + + serializer = servers.HeadersSerializer() + response = webob.Response() + server = { + 'status': 'REBUILD', + 'links': [{ + 'rel': 'self', + 'href': selfhref, + }, { + 'rel': 'bookmark', + 'href': bookhref, + }], + } + serializer.action(response, {'server': server}) + self.assertEqual(response.headers['Location'], selfhref) -- cgit