Merge "Pass insecure option to HTTPClient"

This commit is contained in:
Jenkins
2016-02-12 00:10:03 +00:00
committed by Gerrit Code Review
2 changed files with 19 additions and 0 deletions

View File

@@ -628,6 +628,8 @@ class OpenStackCinderShell(object):
if not auth_plugin: if not auth_plugin:
auth_session = self._get_keystone_session() auth_session = self._get_keystone_session()
insecure = self.options.insecure
self.cs = client.Client(options.os_volume_api_version, os_username, self.cs = client.Client(options.os_volume_api_version, os_username,
os_password, os_tenant_name, os_auth_url, os_password, os_tenant_name, os_auth_url,
region_name=os_region_name, region_name=os_region_name,
@@ -640,6 +642,7 @@ class OpenStackCinderShell(object):
bypass_url=bypass_url, bypass_url=bypass_url,
retries=options.retries, retries=options.retries,
http_log_debug=args.debug, http_log_debug=args.debug,
insecure=insecure,
cacert=cacert, auth_system=os_auth_system, cacert=cacert, auth_system=os_auth_system,
auth_plugin=auth_plugin, auth_plugin=auth_plugin,
session=auth_session) session=auth_session)

View File

@@ -23,6 +23,7 @@ import requests
from six import moves from six import moves
from testtools import matchers from testtools import matchers
import cinderclient
from cinderclient import exceptions from cinderclient import exceptions
from cinderclient import auth_plugin from cinderclient import auth_plugin
from cinderclient import shell from cinderclient import shell
@@ -198,6 +199,21 @@ class ShellTest(utils.TestCase):
allow_redirects=True, allow_redirects=True,
**self.TEST_REQUEST_BASE) **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): class CinderClientArgumentParserTest(utils.TestCase):