Propagate insecure arg to all requests
If the --insecure/-k flag is passed in, all requests should honor it. Change-Id: I7bbd9f481595f8a90db3e96f890ec9315b01000c Closes-Bug: #1633145
This commit is contained in:
parent
91b93498b7
commit
333cdde312
@ -29,14 +29,16 @@ class TestListParser(object):
|
||||
current Tempest environment.
|
||||
"""
|
||||
|
||||
def __init__(self, tempest_dir):
|
||||
def __init__(self, tempest_dir, insecure=False):
|
||||
"""
|
||||
Initialize the TestListParser.
|
||||
|
||||
:param tempest_dir: Absolute path of the Tempest directory.
|
||||
:param insecure: Whether https requests, if any, should be insecure.
|
||||
"""
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self.tempest_dir = tempest_dir
|
||||
self.insecure = insecure
|
||||
|
||||
def _get_tempest_test_ids(self):
|
||||
"""This does a 'testr list-tests' on the Tempest directory in order to
|
||||
@ -92,7 +94,8 @@ class TestListParser(object):
|
||||
:param list_location: file path or URL location of list file
|
||||
"""
|
||||
try:
|
||||
response = requests.get(list_location)
|
||||
response = requests.get(list_location,
|
||||
verify=not self.insecure)
|
||||
testcase_list = response.text.split('\n')
|
||||
test_mappings = self._form_test_id_mappings(testcase_list)
|
||||
# If the location isn't a valid URL, we assume it is a file path.
|
||||
|
@ -411,7 +411,8 @@ class RefstackClient:
|
||||
# If a test list was specified, have it take precedence.
|
||||
if self.args.test_list:
|
||||
self.logger.info("Normalizing test list...")
|
||||
parser = TestListParser(os.path.abspath(self.tempest_dir))
|
||||
parser = TestListParser(os.path.abspath(self.tempest_dir),
|
||||
insecure=self.args.insecure)
|
||||
parser.setup_venv(self.logger.getEffectiveLevel())
|
||||
# get whitelist
|
||||
list_file = parser.create_whitelist(self.args.test_list)
|
||||
@ -522,7 +523,8 @@ class RefstackClient:
|
||||
if locals()[param]:
|
||||
params.update({param: locals()[param]})
|
||||
try:
|
||||
resp = requests.get(endpoint, headers=headers, params=params)
|
||||
resp = requests.get(endpoint, headers=headers, params=params,
|
||||
verify=not self.args.insecure)
|
||||
resp.raise_for_status()
|
||||
except requests.exceptions.HTTPError as e:
|
||||
self.logger.info('Failed to list %s - %s ' % (endpoint, e))
|
||||
|
@ -26,7 +26,6 @@ from mock import MagicMock
|
||||
import unittest
|
||||
|
||||
import refstack_client.refstack_client as rc
|
||||
import refstack_client.list_parser as lp
|
||||
|
||||
|
||||
class TestRefstackClient(unittest.TestCase):
|
||||
@ -647,7 +646,10 @@ class TestRefstackClient(unittest.TestCase):
|
||||
sign_with='rsa_key'
|
||||
)
|
||||
|
||||
def test_run_tempest_with_test_list(self):
|
||||
@mock.patch('refstack_client.list_parser.TestListParser.create_whitelist')
|
||||
@mock.patch('refstack_client.list_parser.'
|
||||
'TestListParser.get_normalized_test_list')
|
||||
def test_run_tempest_with_test_list(self, mock_normalize, mock_whitelist):
|
||||
"""Test that the Tempest script runs with a test list file."""
|
||||
argv = self.mock_argv(verbose='-vv')
|
||||
argv.extend(['--test-list', 'test-list.txt'])
|
||||
@ -662,15 +664,13 @@ class TestRefstackClient(unittest.TestCase):
|
||||
client.get_passed_tests = MagicMock(return_value=[{'name': 'test'}])
|
||||
client._save_json_results = MagicMock()
|
||||
client.post_results = MagicMock()
|
||||
lp.TestListParser.get_normalized_test_list = MagicMock(
|
||||
return_value="/tmp/some-list")
|
||||
lp.TestListParser.create_whitelist = MagicMock(
|
||||
return_value="/tmp/some-list")
|
||||
mock_normalize.return_value = '/tmp/some-list'
|
||||
mock_whitelist.return_value = '/tmp/some-list'
|
||||
client._get_keystone_config = MagicMock(
|
||||
return_value=self.v2_config)
|
||||
client.test()
|
||||
|
||||
lp.TestListParser.create_whitelist.assert_called_with('test-list.txt')
|
||||
mock_whitelist.assert_called_with('test-list.txt')
|
||||
mock_popen.assert_called_with(
|
||||
['%s/tools/with_venv.sh' % self.test_path, 'ostestr', '--serial',
|
||||
'--no-slowest', '--whitelist_file', '/tmp/some-list'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user