summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/drivers/modules
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-08-10 02:11:51 +0000
committerGerrit Code Review <review@openstack.org>2022-08-10 02:11:51 +0000
commit3d3a67daf7d2969d8da691d12351ab5bb32eca80 (patch)
tree44acefbe2d519c2942dfa1ce565173342322b3cb /ironic/tests/unit/drivers/modules
parentf8f83811c42138c943989510548fe24cc71c88f9 (diff)
parent64d7a7f3077bc000a18c4a0c56f122941b262483 (diff)
downloadironic-3d3a67daf7d2969d8da691d12351ab5bb32eca80.tar.gz
Merge "Fix iRMC driver to use certification file in HTTPS"
Diffstat (limited to 'ironic/tests/unit/drivers/modules')
-rw-r--r--ironic/tests/unit/drivers/modules/irmc/test_boot.py1
-rw-r--r--ironic/tests/unit/drivers/modules/irmc/test_common.py42
-rw-r--r--ironic/tests/unit/drivers/modules/irmc/test_raid.py4
3 files changed, 45 insertions, 2 deletions
diff --git a/ironic/tests/unit/drivers/modules/irmc/test_boot.py b/ironic/tests/unit/drivers/modules/irmc/test_boot.py
index cd367cef0..6b57c7504 100644
--- a/ironic/tests/unit/drivers/modules/irmc/test_boot.py
+++ b/ironic/tests/unit/drivers/modules/irmc/test_boot.py
@@ -63,6 +63,7 @@ PARSED_IFNO = {
'irmc_snmp_port': 161,
'irmc_snmp_version': snmp.SNMP_V2C,
'irmc_sensor_method': 'ipmitool',
+ 'irmc_verify_ca': True,
}
diff --git a/ironic/tests/unit/drivers/modules/irmc/test_common.py b/ironic/tests/unit/drivers/modules/irmc/test_common.py
index 7598fc16b..9dbb380ba 100644
--- a/ironic/tests/unit/drivers/modules/irmc/test_common.py
+++ b/ironic/tests/unit/drivers/modules/irmc/test_common.py
@@ -16,6 +16,7 @@
Test class for common methods used by iRMC modules.
"""
+import os
from unittest import mock
from oslo_config import cfg
@@ -71,6 +72,7 @@ class IRMCValidateParametersTestCase(BaseIRMCTest):
self.assertEqual(snmp.SNMP_V2C, info['irmc_snmp_version'])
self.assertEqual(161, info['irmc_snmp_port'])
self.assertEqual('public', info['irmc_snmp_community'])
+ self.assertTrue(info['irmc_verify_ca'])
def test_parse_driver_info_snmpv3(self):
self.node.driver_info['irmc_snmp_version'] = 'v3'
@@ -111,6 +113,7 @@ class IRMCValidateParametersTestCase(BaseIRMCTest):
self.assertEqual(443, info['irmc_port'])
self.assertEqual(60, info['irmc_client_timeout'])
self.assertEqual('ipmitool', info['irmc_sensor_method'])
+ self.assertEqual(True, info['irmc_verify_ca'])
def test_parse_driver_info_missing_address(self):
del self.node.driver_info['irmc_address']
@@ -274,6 +277,41 @@ class IRMCValidateParametersTestCase(BaseIRMCTest):
self.assertRaises(exception.InvalidParameterValue,
irmc_common.parse_driver_info, self.node)
+ @mock.patch.object(os.path, 'isabs', return_value=True, autospec=True)
+ @mock.patch.object(os.path, 'isdir', return_value=True, autospec=True)
+ def test_parse_driver_info_dir_path_verify_ca(self, mock_isdir,
+ mock_isabs):
+ fake_path = 'absolute/path/to/a/valid/CA'
+ self.node.driver_info['irmc_verify_ca'] = fake_path
+ info = irmc_common.parse_driver_info(self.node)
+ self.assertEqual(fake_path, info['irmc_verify_ca'])
+ mock_isdir.assert_called_once_with(fake_path)
+ mock_isabs.assert_called_once_with(fake_path)
+
+ @mock.patch.object(os.path, 'isabs', return_value=True, autospec=True)
+ @mock.patch.object(os.path, 'isfile', return_value=True, autospec=True)
+ def test_parse_driver_info_file_path_verify_ca(self, mock_isfile,
+ mock_isabs):
+ fake_path = 'absolute/path/to/a/valid/ca.pem'
+ self.node.driver_info['irmc_verify_ca'] = fake_path
+ info = irmc_common.parse_driver_info(self.node)
+ self.assertEqual(fake_path, info['irmc_verify_ca'])
+ mock_isfile.assert_called_once_with(fake_path)
+ mock_isabs.assert_called_once_with(fake_path)
+
+ def test_parse_driver_info_string_bool_verify_ca(self):
+ self.node.driver_info['irmc_verify_ca'] = "False"
+ info = irmc_common.parse_driver_info(self.node)
+ self.assertFalse(info['irmc_verify_ca'])
+
+ def test_parse_driver_info_invalid_verify_ca(self):
+ self.node.driver_info['irmc_verify_ca'] = "1234"
+ self.assertRaises(exception.InvalidParameterValue,
+ irmc_common.parse_driver_info, self.node)
+ self.node.driver_info['irmc_verify_ca'] = 1234
+ self.assertRaises(exception.InvalidParameterValue,
+ irmc_common.parse_driver_info, self.node)
+
class IRMCCommonMethodsTestCase(BaseIRMCTest):
@@ -283,6 +321,7 @@ class IRMCCommonMethodsTestCase(BaseIRMCTest):
self.info['irmc_port'] = 80
self.info['irmc_auth_method'] = 'digest'
self.info['irmc_client_timeout'] = 60
+ self.info['irmc_verify_ca'] = True
mock_scci.get_client.return_value = 'get_client'
returned_mock_scci_get_client = irmc_common.get_irmc_client(self.node)
mock_scci.get_client.assert_called_with(
@@ -291,6 +330,7 @@ class IRMCCommonMethodsTestCase(BaseIRMCTest):
self.info['irmc_password'],
port=self.info['irmc_port'],
auth_method=self.info['irmc_auth_method'],
+ verify=self.info['irmc_verify_ca'],
client_timeout=self.info['irmc_client_timeout'])
self.assertEqual('get_client', returned_mock_scci_get_client)
@@ -314,6 +354,7 @@ class IRMCCommonMethodsTestCase(BaseIRMCTest):
self.info['irmc_port'] = 80
self.info['irmc_auth_method'] = 'digest'
self.info['irmc_client_timeout'] = 60
+ self.info['irmc_verify_ca'] = True
mock_scci.get_report.return_value = 'get_report'
returned_mock_scci_get_report = irmc_common.get_irmc_report(self.node)
mock_scci.get_report.assert_called_with(
@@ -322,6 +363,7 @@ class IRMCCommonMethodsTestCase(BaseIRMCTest):
self.info['irmc_password'],
port=self.info['irmc_port'],
auth_method=self.info['irmc_auth_method'],
+ verify=self.info['irmc_verify_ca'],
client_timeout=self.info['irmc_client_timeout'])
self.assertEqual('get_report', returned_mock_scci_get_report)
diff --git a/ironic/tests/unit/drivers/modules/irmc/test_raid.py b/ironic/tests/unit/drivers/modules/irmc/test_raid.py
index eefe7ff3a..54a0a0dd6 100644
--- a/ironic/tests/unit/drivers/modules/irmc/test_raid.py
+++ b/ironic/tests/unit/drivers/modules/irmc/test_raid.py
@@ -702,8 +702,8 @@ class IRMCRaidConfigurationInternalMethodsTestCase(test_common.BaseIRMCTest):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
raid._commit_raid_config(task)
- get_raid_adapter_mock.assert_called_once_with(
- irmc_common.parse_driver_info(task.node))
+ irmc_info = irmc_common.parse_driver_info(task.node)
+ get_raid_adapter_mock.assert_called_once_with(irmc_info)
update_raid_info_mock.assert_called_once_with(
task.node, task.node.raid_config)
set_async_step_flags_mock.assert_called_once_with(