Fix cacert argument to HTTPS connection
This fixes a typo that broke the client for HTTPS URLs. Added a basic test to cover this case. Coverage is very low in common/http.py. Change-Id: Ic440f20f463c3b8558a7639f1015096a01496cf8 Closes-bug: 1244091
This commit is contained in:
@@ -59,7 +59,7 @@ class HTTPClient(object):
|
||||
|
||||
if parts.scheme == 'https':
|
||||
_class = VerifiedHTTPSConnection
|
||||
_kwargs['ca_cert'] = kwargs.get('cacert', None)
|
||||
_kwargs['cacert'] = kwargs.get('cacert', None)
|
||||
_kwargs['cert_file'] = kwargs.get('cert_file', None)
|
||||
_kwargs['key_file'] = kwargs.get('key_file', None)
|
||||
_kwargs['insecure'] = kwargs.get('insecure', False)
|
||||
|
@@ -14,35 +14,42 @@
|
||||
# under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
from ceilometerclient.tests import utils
|
||||
|
||||
from ceilometerclient.common import http
|
||||
|
||||
fixtures = {}
|
||||
from ceilometerclient.tests import utils
|
||||
|
||||
|
||||
class HttpClientTest(utils.BaseTestCase):
|
||||
url = 'http://localhost'
|
||||
|
||||
def test_url_generation_trailing_slash_in_base(self):
|
||||
client = http.HTTPClient('http://localhost/')
|
||||
client = http.HTTPClient("%s/" % self.url)
|
||||
url = client._make_connection_url('/v1/resources')
|
||||
print(client.connection_params)
|
||||
self.assertEqual(url, '/v1/resources')
|
||||
|
||||
def test_url_generation_without_trailing_slash_in_base(self):
|
||||
client = http.HTTPClient('http://localhost')
|
||||
client = http.HTTPClient(self.url)
|
||||
url = client._make_connection_url('/v1/resources')
|
||||
print(client.connection_params)
|
||||
self.assertEqual(url, '/v1/resources')
|
||||
|
||||
def test_url_generation_prefix_slash_in_path(self):
|
||||
client = http.HTTPClient('http://localhost/')
|
||||
client = http.HTTPClient("%s/" % self.url)
|
||||
url = client._make_connection_url('/v1/resources')
|
||||
print(client.connection_params)
|
||||
self.assertEqual(url, '/v1/resources')
|
||||
|
||||
def test_url_generation_without_prefix_slash_in_path(self):
|
||||
client = http.HTTPClient('http://localhost')
|
||||
client = http.HTTPClient(self.url)
|
||||
url = client._make_connection_url('v1/resources')
|
||||
print(client.connection_params)
|
||||
self.assertEqual(url, '/v1/resources')
|
||||
|
||||
def test_get_connection(self):
|
||||
client = http.HTTPClient(self.url)
|
||||
self.assertIsNotNone(client.get_connection())
|
||||
|
||||
|
||||
class HttpsClientTest(HttpClientTest):
|
||||
url = 'https://localhost'
|
||||
|
Reference in New Issue
Block a user