File 0001-Handle-upper-cased-endpoints.patch of Package python-heatclient
From 4ca53e306d1ac9fda7dbaaafd7a602100d67fdbf Mon Sep 17 00:00:00 2001
From: Angus Salkeld <asalkeld@mirantis.com>
Date: Wed, 27 Aug 2014 11:03:16 +1000
Subject: [PATCH] Handle upper cased endpoints
The location header returns a lower cased hostname so make sure
we match on a case-less endpoint.
Change-Id: I58b53b73d4c4e06b8b3026966cbb72963a0fec9a
Closes-bug: #1308992
---
heatclient/common/http.py | 2 +-
heatclient/tests/test_common_http.py | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
Index: python-heatclient-0.2.9/heatclient/common/http.py
===================================================================
--- python-heatclient-0.2.9.orig/heatclient/common/http.py
+++ python-heatclient-0.2.9/heatclient/common/http.py
@@ -210,7 +210,7 @@ class HTTPClient(object):
if location is None:
message = "Location not returned with 302"
raise exc.InvalidEndpoint(message=message)
- elif location.startswith(self.endpoint):
+ elif location.lower().startswith(self.endpoint.lower()):
return location[len(self.endpoint):]
else:
message = "Prohibited endpoint redirect %s" % location
Index: python-heatclient-0.2.9/heatclient/tests/test_common_http.py
===================================================================
--- python-heatclient-0.2.9.orig/heatclient/tests/test_common_http.py
+++ python-heatclient-0.2.9/heatclient/tests/test_common_http.py
@@ -415,6 +415,38 @@ class HttpClientTest(testtools.TestCase)
self.assertEqual(200, resp.status_code)
self.m.VerifyAll()
+ def test_http_manual_redirect_put_uppercase(self):
+ mock_conn = http.requests.request(
+ 'PUT', 'http://EXAMPLE.com:8004/foo',
+ allow_redirects=False,
+ headers={'Content-Type': 'application/json',
+ 'Accept': 'application/json',
+ 'User-Agent': 'python-heatclient'})
+ mock_conn.AndReturn(
+ fakes.FakeHTTPResponse(
+ 302, 'Found',
+ {'location': 'http://example.com:8004/foo/bar'},
+ ''))
+ mock_conn = http.requests.request(
+ 'PUT', 'http://EXAMPLE.com:8004/foo/bar',
+ allow_redirects=False,
+ headers={'Content-Type': 'application/json',
+ 'Accept': 'application/json',
+ 'User-Agent': 'python-heatclient'})
+ mock_conn.AndReturn(
+ fakes.FakeHTTPResponse(
+ 200, 'OK',
+ {'content-type': 'application/json'},
+ '{}'))
+
+ self.m.ReplayAll()
+
+ client = http.HTTPClient('http://EXAMPLE.com:8004/foo')
+ resp, body = client.json_request('PUT', '')
+
+ self.assertEqual(200, resp.status_code)
+ self.m.VerifyAll()
+
def test_http_manual_redirect_prohibited(self):
mock_conn = http.requests.request(
'DELETE', 'http://example.com:8004/foo',