Fix handling driver_info[agent_verify_ca] == False
Because of using 'or', it will only be respected when verify_ca is also False in the configuration. Change-Id: Ie000463fa8ac2cd739a9d8f256346472fe3f4288
This commit is contained in:
parent
416a0951c8
commit
ce5baa3803
@ -89,9 +89,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)
|
||||
|
@ -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'}
|
||||
|
4
releasenotes/notes/verify-bool-ab3607429e005bed.yaml
Normal file
4
releasenotes/notes/verify-bool-ab3607429e005bed.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes overriding ``agent_verify_ca`` with ``False`` via ``driver_info``.
|
Loading…
Reference in New Issue
Block a user