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
This commit is contained in:
Manuel Desbonnet
2014-06-19 11:54:03 +01:00
parent 938031ad52
commit a945b3d448
2 changed files with 3 additions and 3 deletions

View File

@@ -117,7 +117,7 @@ class Controller(object):
def delete(self, image_id): def delete(self, image_id):
"""Delete an image.""" """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): def create(self, **kwargs):
"""Create an image.""" """Create an image."""

View File

@@ -118,7 +118,7 @@ fixtures = {
}, },
), ),
}, },
'v2/images/87b634c1-f893-33c9-28a9-e5673c99239a': { '/v2/images/87b634c1-f893-33c9-28a9-e5673c99239a': {
'DELETE': ( 'DELETE': (
{}, {},
{ {
@@ -496,7 +496,7 @@ class TestController(testtools.TestCase):
self.controller.delete('87b634c1-f893-33c9-28a9-e5673c99239a') self.controller.delete('87b634c1-f893-33c9-28a9-e5673c99239a')
expect = [ expect = [
('DELETE', ('DELETE',
'v2/images/87b634c1-f893-33c9-28a9-e5673c99239a', '/v2/images/87b634c1-f893-33c9-28a9-e5673c99239a',
{}, {},
None)] None)]
self.assertEqual(expect, self.api.calls) self.assertEqual(expect, self.api.calls)