Skip to content

Commit

Permalink
tests - display TC Flash Hash right after setting TC code
Browse files Browse the repository at this point in the history
  • Loading branch information
odudex committed Dec 11, 2024
1 parent 4515932 commit 2d94a05
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/krux/pages/settings_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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"
Expand Down
16 changes: 14 additions & 2 deletions tests/pages/test_settings_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2d94a05

Please sign in to comment.