diff --git a/core/src/apps/common/request_pin.py b/core/src/apps/common/request_pin.py index 3407867745..e81e25c13c 100644 --- a/core/src/apps/common/request_pin.py +++ b/core/src/apps/common/request_pin.py @@ -123,18 +123,26 @@ async def verify_user_pin( async def error_pin_invalid(ctx: wire.Context) -> NoReturn: - from apps.common.confirm import confirm + from trezor.ui.layouts import show_error - text = Text("Wrong PIN", ui.ICON_WRONG, ui.RED) - text.normal("The PIN you entered is", "invalid.") - await confirm(ctx, text, confirm=None, cancel="Close") + await show_error( + ctx, + "warning_wrong_pin", + header="Wrong PIN", + content="The PIN you entered is invalid.", + red=True, + ) raise wire.PinInvalid async def error_pin_matches_wipe_code(ctx: wire.Context) -> NoReturn: - from apps.common.confirm import confirm + from trezor.ui.layouts import show_error - text = Text("Invalid PIN", ui.ICON_WRONG, ui.RED) - text.normal("The new PIN must be", "different from your", "wipe code.") - await confirm(ctx, text, confirm=None, cancel="Close") + await show_error( + ctx, + "warning_invalid_new_pin", + header="Invalid PIN", + content="The new PIN must be different from your\nwipe code.", + red=True, + ) raise wire.PinInvalid diff --git a/tests/device_tests/test_msg_changepin_t2.py b/tests/device_tests/test_msg_changepin_t2.py index 723378f2a0..903d7ae5d9 100644 --- a/tests/device_tests/test_msg_changepin_t2.py +++ b/tests/device_tests/test_msg_changepin_t2.py @@ -18,7 +18,7 @@ import pytest from trezorlib import btc, device, messages from trezorlib.client import MAX_PIN_LENGTH, PASSPHRASE_TEST_PATH -from trezorlib.exceptions import Cancelled +from trezorlib.exceptions import Cancelled, TrezorFailure PIN4 = "1234" PIN60 = "789456" * 10 @@ -172,3 +172,31 @@ def test_change_failed(client): client.init_device() assert client.features.pin_protection is True _check_pin(client, PIN4) + + +@pytest.mark.setup_client(pin=PIN4) +def test_change_invalid_current(client): + assert client.features.pin_protection is True + + # Check current PIN value + _check_pin(client, PIN4) + + # Let's set new PIN + def input_flow(): + yield # do you want to change pin? + client.debug.press_yes() + yield # enter wrong current pin + client.debug.input(PIN60) + yield + client.debug.press_no() + + with client, pytest.raises(TrezorFailure): + client.set_expected_responses([messages.ButtonRequest] * 3 + [messages.Failure]) + client.set_input_flow(input_flow) + + device.change_pin(client) + + # Check that there's still old PIN protection + client.init_device() + assert client.features.pin_protection is True + _check_pin(client, PIN4) diff --git a/tests/ui_tests/fixtures.json b/tests/ui_tests/fixtures.json index 4112102dbb..6ffa771451 100644 --- a/tests/ui_tests/fixtures.json +++ b/tests/ui_tests/fixtures.json @@ -136,6 +136,7 @@ "test_msg_change_wipe_code_t2.py::test_set_wipe_code_mismatch": "3f29784c14941de5fe0595780e09bd68830e3d95c981cc99e4ebd1418f875748", "test_msg_change_wipe_code_t2.py::test_set_wipe_code_to_pin": "65d64d32e4fcc694e95e675bc2b4fbbf2d967cfc8f8fc852aeadbf58acefacf9", "test_msg_changepin_t2.py::test_change_failed": "63c1d90ce9bd9d7fdd627ce8b70b60518b373e235dcdb6713a1b5bc020e4466d", +"test_msg_changepin_t2.py::test_change_invalid_current": "25469fa710ef37444b2b99efda2527541087ae36926d6a95cc6dd3553a8effb7", "test_msg_changepin_t2.py::test_change_pin": "4cdff56add70b77cd901654fcdef6098cd38214567060c870865ee697efa6df5", "test_msg_changepin_t2.py::test_remove_pin": "64701aa15082e4d3f9639799c9d12c129dd60d1aed5f7203bfac2fd3665d1d19", "test_msg_changepin_t2.py::test_set_failed": "6ad935b038f00177fea7e7221204ca13b188ff2eb2e699b367592d1567c5bcd6",