Include unsupported url scheme with ClientException
This was an attempt to reveal some more info about failing jenkins jobs such as here [1] where glance_store is receiving a swiftclient exception because of 'unsupported scheme in url'. It seems worth merging the more helpful exception message. [1] http://logs.openstack.org/91/155291/7/check/gate-tempest-dsvm-neutron-src-python-swiftclient/4adac1e/ Change-Id: I0f3411efd42d045b07d6d1000f59a06865d8034b
This commit is contained in:
parent
45cce75e50
commit
47f089fbca
@ -170,7 +170,8 @@ class HTTPConnection(object):
|
||||
self.requests_args = {}
|
||||
self.request_session = requests.Session()
|
||||
if self.parsed_url.scheme not in ('http', 'https'):
|
||||
raise ClientException("Unsupported scheme")
|
||||
raise ClientException('Unsupported scheme "%s" in url "%s"'
|
||||
% (self.parsed_url.scheme, url))
|
||||
self.requests_args['verify'] = not insecure
|
||||
if cacert and not insecure:
|
||||
# verify requests parameter is used to pass the CA_BUNDLE file
|
||||
|
@ -975,6 +975,29 @@ class TestGetCapabilities(MockHttpTest):
|
||||
|
||||
class TestHTTPConnection(MockHttpTest):
|
||||
|
||||
def test_bad_url_scheme(self):
|
||||
url = u'www.test.com'
|
||||
exc = self.assertRaises(c.ClientException, c.http_connection, url)
|
||||
expected = u'Unsupported scheme "" in url "www.test.com"'
|
||||
self.assertEqual(expected, str(exc))
|
||||
|
||||
url = u'://www.test.com'
|
||||
exc = self.assertRaises(c.ClientException, c.http_connection, url)
|
||||
expected = u'Unsupported scheme "" in url "://www.test.com"'
|
||||
self.assertEqual(expected, str(exc))
|
||||
|
||||
url = u'blah://www.test.com'
|
||||
exc = self.assertRaises(c.ClientException, c.http_connection, url)
|
||||
expected = u'Unsupported scheme "blah" in url "blah://www.test.com"'
|
||||
self.assertEqual(expected, str(exc))
|
||||
|
||||
def test_ok_url_scheme(self):
|
||||
for scheme in ('http', 'https', 'HTTP', 'HTTPS'):
|
||||
url = u'%s://www.test.com' % scheme
|
||||
parsed_url, conn = c.http_connection(url)
|
||||
self.assertEqual(scheme.lower(), parsed_url.scheme)
|
||||
self.assertEqual(u'%s://www.test.com' % scheme, conn.url)
|
||||
|
||||
def test_ok_proxy(self):
|
||||
conn = c.http_connection(u'http://www.test.com/',
|
||||
proxy='http://localhost:8080')
|
||||
|
Loading…
x
Reference in New Issue
Block a user