From b670b73e446f9c707392ace6b802dcfdedecf71a Mon Sep 17 00:00:00 2001 From: Cory Stone Date: Wed, 27 Jan 2016 15:09:45 -0600 Subject: [PATCH] Pass insecure option to HTTPClient This option was silently being ignored. Closes-Bug: #1538648 Change-Id: I3a1b5268e87cbc9803924be95b374d76b72a3a5d --- cinderclient/shell.py | 3 +++ cinderclient/tests/unit/test_shell.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/cinderclient/shell.py b/cinderclient/shell.py index fc840e9f6..17dabddd1 100644 --- a/cinderclient/shell.py +++ b/cinderclient/shell.py @@ -628,6 +628,8 @@ class OpenStackCinderShell(object): if not auth_plugin: auth_session = self._get_keystone_session() + insecure = self.options.insecure + self.cs = client.Client(options.os_volume_api_version, os_username, os_password, os_tenant_name, os_auth_url, region_name=os_region_name, @@ -640,6 +642,7 @@ class OpenStackCinderShell(object): bypass_url=bypass_url, retries=options.retries, http_log_debug=args.debug, + insecure=insecure, cacert=cacert, auth_system=os_auth_system, auth_plugin=auth_plugin, session=auth_session) diff --git a/cinderclient/tests/unit/test_shell.py b/cinderclient/tests/unit/test_shell.py index af6d1fa0a..a2439f2fa 100644 --- a/cinderclient/tests/unit/test_shell.py +++ b/cinderclient/tests/unit/test_shell.py @@ -23,6 +23,7 @@ import requests from six import moves from testtools import matchers +import cinderclient from cinderclient import exceptions from cinderclient import auth_plugin from cinderclient import shell @@ -198,6 +199,21 @@ class ShellTest(utils.TestCase): allow_redirects=True, **self.TEST_REQUEST_BASE) + @mock.patch.object(cinderclient.client.HTTPClient, 'authenticate', + side_effect=exceptions.Unauthorized('No')) + # Easiest way to make cinderclient use httpclient is a None session + @mock.patch.object(cinderclient.shell.OpenStackCinderShell, + '_get_keystone_session', return_value=None) + def test_http_client_insecure(self, mock_authenticate, mock_session): + self.make_env(include={'CINDERCLIENT_INSECURE': True}) + + _shell = shell.OpenStackCinderShell() + + # This "fails" but instantiates the client. + self.assertRaises(exceptions.CommandError, _shell.main, ['list']) + + self.assertEqual(False, _shell.cs.client.verify_cert) + class CinderClientArgumentParserTest(utils.TestCase):