summaryrefslogtreecommitdiff
path: root/ironic/tests/unit
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-02-18 19:53:52 +0000
committerGerrit Code Review <review@openstack.org>2021-02-18 19:53:52 +0000
commit314ceade83b56bd57b7f2f93311fc2ae7f252b5c (patch)
tree369c00261a732429896e3cbcd9643f86f10bee42 /ironic/tests/unit
parent73a600afa2a46d24f16f39f8665ea38d7194181a (diff)
parent46b34a73bf523f6dac37b4133a3e6c9f4fb77659 (diff)
downloadironic-314ceade83b56bd57b7f2f93311fc2ae7f252b5c.tar.gz
Merge "Prevent redfish-virtual-media from being used with Dell nodes" into stable/victoria
Diffstat (limited to 'ironic/tests/unit')
-rw-r--r--ironic/tests/unit/drivers/modules/drac/test_boot.py26
-rw-r--r--ironic/tests/unit/drivers/modules/redfish/test_boot.py49
2 files changed, 74 insertions, 1 deletions
diff --git a/ironic/tests/unit/drivers/modules/drac/test_boot.py b/ironic/tests/unit/drivers/modules/drac/test_boot.py
index d73ef69d7..bed8be2ef 100644
--- a/ironic/tests/unit/drivers/modules/drac/test_boot.py
+++ b/ironic/tests/unit/drivers/modules/drac/test_boot.py
@@ -25,13 +25,15 @@ from oslo_utils import importutils
from ironic.common import boot_devices
from ironic.common import exception
from ironic.conductor import task_manager
+from ironic.drivers.modules import deploy_utils
from ironic.drivers.modules.drac import boot as drac_boot
+from ironic.tests.unit.db import utils as db_utils
from ironic.tests.unit.drivers.modules.drac import utils as test_utils
from ironic.tests.unit.objects import utils as obj_utils
sushy = importutils.try_import('sushy')
-INFO_DICT = test_utils.INFO_DICT
+INFO_DICT = dict(db_utils.get_test_redfish_info(), **test_utils.INFO_DICT)
@mock.patch.object(drac_boot, 'redfish_utils', autospec=True)
@@ -42,6 +44,28 @@ class DracBootTestCase(test_utils.BaseDracTest):
self.node = obj_utils.create_test_node(
self.context, driver='idrac', driver_info=INFO_DICT)
+ @mock.patch.object(deploy_utils, 'validate_image_properties',
+ autospec=True)
+ def test_validate_correct_vendor(self, mock_redfish_utils,
+ mock_validate_image_properties):
+ with task_manager.acquire(self.context, self.node.uuid,
+ shared=True) as task:
+ task.node.instance_info.update(
+ {'kernel': 'kernel',
+ 'ramdisk': 'ramdisk',
+ 'image_source': 'http://image/source'}
+ )
+
+ task.node.driver_info.update(
+ {'deploy_kernel': 'kernel',
+ 'deploy_ramdisk': 'ramdisk',
+ 'bootloader': 'bootloader'}
+ )
+
+ task.node.properties['vendor'] = "Dell Inc."
+
+ task.driver.boot.validate(task)
+
def test__set_boot_device_persistent(self, mock_redfish_utils):
mock_system = mock_redfish_utils.get_system.return_value
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_boot.py b/ironic/tests/unit/drivers/modules/redfish/test_boot.py
index 180173599..d8ac69a1b 100644
--- a/ironic/tests/unit/drivers/modules/redfish/test_boot.py
+++ b/ironic/tests/unit/drivers/modules/redfish/test_boot.py
@@ -295,6 +295,55 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase):
@mock.patch.object(redfish_utils, 'parse_driver_info', autospec=True)
@mock.patch.object(deploy_utils, 'validate_image_properties',
autospec=True)
+ def test_validate_correct_vendor(self, mock_validate_image_properties,
+ mock_parse_driver_info):
+ with task_manager.acquire(self.context, self.node.uuid,
+ shared=True) as task:
+ task.node.instance_info.update(
+ {'kernel': 'kernel',
+ 'ramdisk': 'ramdisk',
+ 'image_source': 'http://image/source'}
+ )
+
+ task.node.driver_info.update(
+ {'deploy_kernel': 'kernel',
+ 'deploy_ramdisk': 'ramdisk',
+ 'bootloader': 'bootloader'}
+ )
+
+ task.node.properties['vendor'] = "Ironic Co."
+
+ task.driver.boot.validate(task)
+
+ @mock.patch.object(redfish_utils, 'parse_driver_info', autospec=True)
+ @mock.patch.object(deploy_utils, 'validate_image_properties',
+ autospec=True)
+ def test_validate_incompatible_with_idrac(self,
+ mock_validate_image_properties,
+ mock_parse_driver_info):
+ with task_manager.acquire(self.context, self.node.uuid,
+ shared=True) as task:
+ task.node.instance_info.update(
+ {'kernel': 'kernel',
+ 'ramdisk': 'ramdisk',
+ 'image_source': 'http://image/source'}
+ )
+
+ task.node.driver_info.update(
+ {'deploy_kernel': 'kernel',
+ 'deploy_ramdisk': 'ramdisk',
+ 'bootloader': 'bootloader'}
+ )
+
+ task.node.properties['vendor'] = "Dell Inc."
+
+ self.assertRaisesRegex(exception.InvalidParameterValue,
+ "with vendor Dell Inc.",
+ task.driver.boot.validate, task)
+
+ @mock.patch.object(redfish_utils, 'parse_driver_info', autospec=True)
+ @mock.patch.object(deploy_utils, 'validate_image_properties',
+ autospec=True)
def test_validate_missing(self, mock_validate_image_properties,
mock_parse_driver_info):
with task_manager.acquire(self.context, self.node.uuid,