Fix regression bug after removing posixpath in http.py
After removing posixpath.normpath(url) in http.py, the code has a regression bug that the url like 'http://example.com:80/test' can not work. The code urlparse.urljoin() can not work as '%s%s' % (self.endpoint_path, url). Fixes bug #1230032 Change-Id: Ie7266fc3a067b92dfeed169086b4bf6a87dedbd6
This commit is contained in:
@@ -144,6 +144,34 @@ class TestClient(testtools.TestCase):
|
||||
resp, body = self.client.raw_request('GET', '/v1/images/detail')
|
||||
self.assertEqual(resp, fake)
|
||||
|
||||
def test_customized_path_raw_request(self):
|
||||
"""
|
||||
Verify the customized path being used for HTTP requests
|
||||
reflects accurately
|
||||
"""
|
||||
|
||||
def check_request(method, path, **kwargs):
|
||||
self.assertEqual(method, 'GET')
|
||||
self.assertEqual(path, '/customized-path/v1/images/detail')
|
||||
|
||||
# NOTE(yuyangbj): see bug 1230032 to get more info
|
||||
endpoint = 'http://example.com:9292/customized-path'
|
||||
client = http.HTTPClient(endpoint, token=u'abc123')
|
||||
self.assertEqual(client.endpoint_path, '/customized-path')
|
||||
|
||||
httplib.HTTPConnection.request(
|
||||
mox.IgnoreArg(),
|
||||
mox.IgnoreArg(),
|
||||
headers=mox.IgnoreArg()).WithSideEffects(check_request)
|
||||
|
||||
# fake the response returned by httplib
|
||||
fake = utils.FakeResponse({}, StringIO.StringIO('Ok'))
|
||||
httplib.HTTPConnection.getresponse().AndReturn(fake)
|
||||
self.mock.ReplayAll()
|
||||
|
||||
resp, body = client.raw_request('GET', '/v1/images/detail')
|
||||
self.assertEqual(resp, fake)
|
||||
|
||||
def test_connection_refused_raw_request(self):
|
||||
"""
|
||||
Should receive a CommunicationError if connection refused.
|
||||
|
||||
Reference in New Issue
Block a user