Merge "Fix handling driver_info[agent_verify_ca] == False"

This commit is contained in:
Zuul 2021-07-20 08:25:42 +00:00 committed by Gerrit Code Review
commit 59563e9581
3 changed files with 33 additions and 3 deletions

View File

@ -98,9 +98,13 @@ class AgentClient(object):
})
def _get_verify(self, node):
value = (node.driver_internal_info.get('agent_verify_ca')
or node.driver_info.get('agent_verify_ca')
or CONF.agent.verify_ca)
# False is a valid value, don't use 'or'
value = node.driver_internal_info.get('agent_verify_ca')
if value is None:
value = node.driver_info.get('agent_verify_ca')
if value is None:
value = CONF.agent.verify_ca
if isinstance(value, str):
try:
value = strutils.bool_from_string(value, strict=True)

View File

@ -487,6 +487,28 @@ class TestAgentClient(base.TestCase):
timeout=60,
verify=False)
@mock.patch('os.path.exists', autospec=True, return_value=True)
def test__command_verify_disable_in_driver_info(self, mock_exists):
response_data = {'status': 'ok'}
self.client.session.post.return_value = MockResponse(response_data)
method = 'standby.run_image'
image_info = {'image_id': 'test_image'}
params = {'image_info': image_info}
self.node.driver_info['agent_verify_ca'] = False
url = self.client._get_command_url(self.node)
body = self.client._get_command_body(method, params)
response = self.client._command(self.node, method, params)
self.assertEqual(response, response_data)
self.client.session.post.assert_called_once_with(
url,
data=body,
params={'wait': 'false'},
timeout=60,
verify=False)
@mock.patch('os.path.exists', autospec=True, return_value=False)
def test__command_verify_invalid_file(self, mock_exists):
response_data = {'status': 'ok'}

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Fixes overriding ``agent_verify_ca`` with ``False`` via ``driver_info``.