Skip to content

Commit 2573c7e

Browse files
committed
common-mock: mock btg_key_validator so we can test failure states
Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
1 parent db6ad78 commit 2573c7e

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

include/hal/common-mock-func.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,3 +793,20 @@ amdtool_on_amd_mock() {
793793
cap_upd_tool_mock() {
794794
return 0
795795
}
796+
797+
################################################################################
798+
# cap_upd_tool
799+
################################################################################
800+
# Leave empty to call original tool, set to "true" to return 1 otherwise
801+
# return 0
802+
TEST_KEY_VALIDATOR_FAIL="${TEST_KEY_VALIDATOR_RESULT:-}"
803+
804+
btg_key_validator_mock() {
805+
if [ -z "${TEST_KEY_VALIDATOR_FAIL}" ]; then
806+
btg_key_validator "$@"
807+
elif [ "${TEST_KEY_VALIDATOR_FAIL}" = "true" ]; then
808+
return 1
809+
else
810+
return 0
811+
fi
812+
}

include/hal/dts-hal.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ RDMSR="tool_wrapper rdmsr"
6060
LSPCI="tool_wrapper lspci"
6161
LSUSB="tool_wrapper lsusb"
6262
DUMP_PCRS="tool_wrapper dump_pcrs"
63+
BTG_KEY_VALIDATOR="tool_wrapper btg_key_validator"
6364

6465
################################################################################
6566
# Tools wrapper.

scripts/dasharo-deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ fuse_workflow() {
14731473
check_if_ac
14741474
download_bios
14751475
verify_artifacts bios
1476-
btg_key_validator --file "$BIOS_UPDATE_FILE" --key-hash "$INTEL_BTG_HASH"
1476+
$BTG_KEY_VALIDATOR --file "$BIOS_UPDATE_FILE" --key-hash "$INTEL_BTG_HASH"
14771477
error_check "Firmware Intel BootGuard signature check failed. Aborting...
14781478
Platform has not been fused and no changes were made."
14791479
# Ask user for confirmation:

0 commit comments

Comments
 (0)