diff --git a/sonic_installer/main.py b/sonic_installer/main.py index d78259317e..54f465aee2 100644 --- a/sonic_installer/main.py +++ b/sonic_installer/main.py @@ -579,11 +579,16 @@ def install(url, force, skip_platform_check=False, skip_migration=False, skip_pa # Calling verification script by default - signature will be checked if enabled in bios echo_and_log("Verifing image {} signature...".format(binary_image_version)) - if not bootloader.verify_image_sign(image_path): - echo_and_log('Error: Failed verify image signature', LOG_ERR) - raise click.Abort() - else: - echo_and_log('Verification successful') + try: + if not bootloader.verify_image_sign(image_path): + echo_and_log('Error: Failed verify image signature', LOG_ERR) + raise click.Abort() + else: + echo_and_log('Verification successful') + except AttributeError: + echo_and_log("Skip Verifing image {} signature,".format(binary_image_version) + + " method not implemented for the current bootloader type: {}".format(bootloader.__class__.__name__)) + pass echo_and_log("Installing image {} and setting it as default...".format(binary_image_version)) with SWAPAllocator(not skip_setup_swap, swap_mem_size, total_mem_threshold, available_mem_threshold): diff --git a/tests/test_sonic_installer.py b/tests/test_sonic_installer.py index 0f8fcdb8ca..a8b862b878 100644 --- a/tests/test_sonic_installer.py +++ b/tests/test_sonic_installer.py @@ -52,6 +52,13 @@ def rootfs_path_mock(path): result = runner.invoke(sonic_installer.commands["install"], [sonic_image_filename, "-y"]) print(result.output) + assert result.exit_code != 0 + mock_bootloader_verify_image_sign_not_implemented = mock_bootloader + mock_bootloader_verify_image_sign_not_implemented.verify_image_sign = Mock(side_effect=AttributeError) + get_bootloader.return_value=mock_bootloader_verify_image_sign_not_implemented + result = runner.invoke(sonic_installer.commands["install"], [sonic_image_filename, "-y"]) + print(result.output) + assert result.exit_code != 0 # Assert bootloader install API was called mock_bootloader.install_image.assert_called_with(f"./{sonic_image_filename}") @@ -89,6 +96,11 @@ def rootfs_path_mock(path): call(["umount", "-f", "-R", mounted_image_folder], raise_exception=False), call(["umount", "-r", "-f", mounted_image_folder], raise_exception=False), call(["rm", "-rf", mounted_image_folder], raise_exception=False), + call(['mkdir', '-p', mounted_image_folder]), + call(["mount", "-t", "squashfs", mounted_image_folder, mounted_image_folder]), + call(["sonic-cfggen", "-d", "-y", f"{mounted_image_folder}/etc/sonic/sonic_version.yml", "-t", f"{mounted_image_folder}/usr/share/sonic/templates/sonic-environment.j2"]), + call(["umount", "-r", "-f", mounted_image_folder], raise_exception=True), + call(["rm", "-rf", mounted_image_folder], raise_exception=True), ] assert run_command_or_raise.call_args_list == expected_call_list