From a945b3d448a9eba1851e99c3961516cbb1dd4f86 Mon Sep 17 00:00:00 2001 From: Manuel Desbonnet Date: Thu, 19 Jun 2014 11:54:03 +0100 Subject: [PATCH] Prepend '/' to the delete url for the v2 client ... and update tests to match. The missing slash results in a non-absolute DELETE request being sent to the API. E.g. DELETE v2/images/62fac489-23b4-4929-87af-2e7236e8542b HTTP/1.1 This is not strictly valid http/1.1 - rfc2616 specifies that the path must be absolute. This doesn't cause a problem for the API server, but this can cause problems if the API server is fronted by something else (see #133161). It also means that the curl command logged in debug mode has a bad url. E.g. curl -i -X DELETE ... http://10.0.0.13:9292v2/images/... Change-Id: Ib0c749dedbfcf07303fcddae4512db61b0f3fd78 Closes-bug: #1327101 --- glanceclient/v2/images.py | 2 +- tests/v2/test_images.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/glanceclient/v2/images.py b/glanceclient/v2/images.py index cb57143..53b65ef 100644 --- a/glanceclient/v2/images.py +++ b/glanceclient/v2/images.py @@ -117,7 +117,7 @@ class Controller(object): def delete(self, image_id): """Delete an image.""" - self.http_client.json_request('DELETE', 'v2/images/%s' % image_id) + self.http_client.json_request('DELETE', '/v2/images/%s' % image_id) def create(self, **kwargs): """Create an image.""" diff --git a/tests/v2/test_images.py b/tests/v2/test_images.py index 149e096..eeabb88 100644 --- a/tests/v2/test_images.py +++ b/tests/v2/test_images.py @@ -118,7 +118,7 @@ fixtures = { }, ), }, - 'v2/images/87b634c1-f893-33c9-28a9-e5673c99239a': { + '/v2/images/87b634c1-f893-33c9-28a9-e5673c99239a': { 'DELETE': ( {}, { @@ -496,7 +496,7 @@ class TestController(testtools.TestCase): self.controller.delete('87b634c1-f893-33c9-28a9-e5673c99239a') expect = [ ('DELETE', - 'v2/images/87b634c1-f893-33c9-28a9-e5673c99239a', + '/v2/images/87b634c1-f893-33c9-28a9-e5673c99239a', {}, None)] self.assertEqual(expect, self.api.calls)