diff options
author | Julia Kreger <juliaashleykreger@gmail.com> | 2023-05-03 07:34:37 -0700 |
---|---|---|
committer | Julia Kreger <juliaashleykreger@gmail.com> | 2023-05-03 07:34:37 -0700 |
commit | 03cd9788e6ad658641b0c3328d10636c5aab96a4 (patch) | |
tree | 03d8571836b95fd3e941465342b27551cb055dbf /ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py | |
parent | 7f281392c219decdfc1a34dc672a86e360230ac9 (diff) | |
download | ironic-03cd9788e6ad658641b0c3328d10636c5aab96a4.tar.gz |
Support longer checksums for redfish firmware upgrade
Previoulsy only SHA1 hashes were supported, now we support
SHA256 and SHA512 by length.
Change-Id: Iddb196faca4008837595a3d0923f55d0e9d2aea5
Diffstat (limited to 'ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py')
-rw-r--r-- | ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py b/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py index 61bc23e48..0bbc38eba 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py @@ -256,6 +256,30 @@ class FirmwareUtilsTestCase(base.TestCase): mock_compute_file_checksum.assert_called_with( file_path, algorithm='sha1') + @mock.patch.object(fileutils, 'compute_file_checksum', autospec=True) + def test_verify_checksum_sha256(self, mock_compute_file_checksum): + checksum = 'a' * 64 + file_path = '/tmp/bios.exe' + mock_compute_file_checksum.return_value = checksum + node = mock.Mock(uuid='9f0f6795-f74e-4b5a-850e-72f586a92435') + + firmware_utils.verify_checksum(node, checksum, file_path) + + mock_compute_file_checksum.assert_called_with( + file_path, algorithm='sha256') + + @mock.patch.object(fileutils, 'compute_file_checksum', autospec=True) + def test_verify_checksum_sha512(self, mock_compute_file_checksum): + checksum = 'a' * 128 + file_path = '/tmp/bios.exe' + mock_compute_file_checksum.return_value = checksum + node = mock.Mock(uuid='9f0f6795-f74e-4b5a-850e-72f586a92435') + + firmware_utils.verify_checksum(node, checksum, file_path) + + mock_compute_file_checksum.assert_called_with( + file_path, algorithm='sha512') + @mock.patch.object(os, 'makedirs', autospec=True) @mock.patch.object(shutil, 'copyfile', autospec=True) @mock.patch.object(os, 'link', autospec=True) |