From e337ae3f639d506a40538d6540ca5cdc4da9db61 Mon Sep 17 00:00:00 2001 From: Kieran Spear Date: Thu, 24 Oct 2013 18:50:36 +1100 Subject: [PATCH] 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 --- ceilometerclient/common/http.py | 2 +- ceilometerclient/tests/test_http.py | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ceilometerclient/common/http.py b/ceilometerclient/common/http.py index dd86740c..1a4b58c7 100644 --- a/ceilometerclient/common/http.py +++ b/ceilometerclient/common/http.py @@ -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) diff --git a/ceilometerclient/tests/test_http.py b/ceilometerclient/tests/test_http.py index 602db54c..ff85d3e1 100644 --- a/ceilometerclient/tests/test_http.py +++ b/ceilometerclient/tests/test_http.py @@ -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'