diff --git a/src/krux/pages/settings_page.py b/src/krux/pages/settings_page.py index 56acd7e3..5ba00e1d 100644 --- a/src/krux/pages/settings_page.py +++ b/src/krux/pages/settings_page.py @@ -23,7 +23,7 @@ import board import lcd -from ..display import FONT_HEIGHT, FONT_WIDTH, PORTRAIT, BOTTOM_PROMPT_LINE +from ..display import FONT_HEIGHT, FONT_WIDTH, PORTRAIT from ..themes import theme, GREEN, ORANGE from ..settings import ( CategorySetting, @@ -193,8 +193,6 @@ def enter_modify_tc_code(self): flash_filler = FillFlash(self.ctx) flash_filler.fill_flash_with_camera_entropy() - from .flash_tools import FlashHash - # Asks if the user wants to set TC Flash Hash at boot self.ctx.display.clear() if not Settings().security.boot_flash_hash and self.prompt( @@ -205,6 +203,7 @@ def enter_modify_tc_code(self): store.save_settings() # Shows TC Flash Hash + from .flash_tools import FlashHash tc_code_bytes = tamper_check_code.encode() # Tamper Check Code hash will be used in "TC Flash Hash" diff --git a/tests/pages/test_settings_page.py b/tests/pages/test_settings_page.py index 73a71c2f..d8895055 100644 --- a/tests/pages/test_settings_page.py +++ b/tests/pages/test_settings_page.py @@ -420,10 +420,16 @@ def test_set_first_tc_code(amigo, mocker): new=mocker.MagicMock(), ) mocker.patch("machine.unique_id", return_value=b"\x01" * 32) + mocker.patch("krux.pages.flash_tools.FlashHash", new=mocker.MagicMock()) mock_file = MockFile() mocker.patch("builtins.open", mock_open(mock_file)) ctx = create_ctx( - mocker, [BUTTON_ENTER, BUTTON_PAGE, BUTTON_ENTER] # Skip checking TC Flash Hash + mocker, + [ + BUTTON_ENTER, + BUTTON_PAGE, + BUTTON_ENTER, + ], # Skip TC Flash Hash at boot ) ctx.tc_code_enabled = False settings_page = SettingsPage(ctx) @@ -463,11 +469,17 @@ def test_set_new_tc_code(amigo, mocker): mocker.patch( "krux.pages.tc_code_verification.TCCodeVerification.capture", return_value=True ) + mocker.patch("krux.pages.flash_tools.FlashHash", new=mocker.MagicMock()) mocker.patch("machine.unique_id", return_value=b"\x01" * 32) mock_file = MockFile() mocker.patch("builtins.open", mock_open(mock_file)) ctx = create_ctx( - mocker, [BUTTON_ENTER, BUTTON_PAGE, BUTTON_ENTER] # Skip checking TC Flash Hash + mocker, + [ + BUTTON_ENTER, + BUTTON_PAGE, + BUTTON_ENTER, + ], # Skip TC Flash Hash at boot ) ctx.tc_code_enabled = True settings_page = SettingsPage(ctx)