From 532f368a14289c116d4f383b6c808d864a34a693 Mon Sep 17 00:00:00 2001 From: grdddj Date: Mon, 2 Oct 2023 15:45:45 +0200 Subject: [PATCH] feat(core): not allowing to send empty PIN in T2B1 [no changelog] --- .../rust/src/ui/model_tr/component/input_methods/pin.rs | 5 ++++- tests/click_tests/test_pin.py | 7 +++++++ tests/ui_tests/fixtures.json | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/embed/rust/src/ui/model_tr/component/input_methods/pin.rs b/core/embed/rust/src/ui/model_tr/component/input_methods/pin.rs index 7af6455af..3c2206bb0 100644 --- a/core/embed/rust/src/ui/model_tr/component/input_methods/pin.rs +++ b/core/embed/rust/src/ui/model_tr/component/input_methods/pin.rs @@ -262,7 +262,10 @@ where self.show_real_pin = true; self.update(ctx); } - PinAction::Enter => return Some(CancelConfirmMsg::Confirmed), + PinAction::Enter if !self.is_empty() => { + // ENTER is not valid when the PIN is empty + return Some(CancelConfirmMsg::Confirmed); + } PinAction::Digit(ch) if !self.is_full() => { self.textbox.append(ctx, ch); // Choosing random digit to be shown next diff --git a/tests/click_tests/test_pin.py b/tests/click_tests/test_pin.py index 927e31a11..3c34ad181 100644 --- a/tests/click_tests/test_pin.py +++ b/tests/click_tests/test_pin.py @@ -224,6 +224,13 @@ def test_pin_long(device_handler: "BackgroundDeviceHandler"): _input_see_confirm(debug, PIN24) +@pytest.mark.setup_client(pin=PIN4) +def test_pin_empty_cannot_send(device_handler: "BackgroundDeviceHandler"): + with prepare(device_handler) as debug: + _input_see_confirm(debug, "") + _input_see_confirm(debug, PIN4) + + @pytest.mark.setup_client(pin=PIN24) def test_pin_long_delete(device_handler: "BackgroundDeviceHandler"): with prepare(device_handler) as debug: diff --git a/tests/ui_tests/fixtures.json b/tests/ui_tests/fixtures.json index 89b584a21..f470928cb 100644 --- a/tests/ui_tests/fixtures.json +++ b/tests/ui_tests/fixtures.json @@ -757,6 +757,7 @@ "TR_test_passphrase_tr.py::test_passphrase_loop_all_characters": "5079e557c3ee648d7778154d65ac0f0200e2ee7e6cc88d46dfb753e314582bed", "TR_test_pin.py::test_pin_change": "5820a43c03708f208059365711b2a46427c279c7462c2c529a73e5ad560bc36b", "TR_test_pin.py::test_pin_delete_hold": "8f8be800e39bcfc95236abcfbb69477776885471605fe82da5d81fcfe04c397e", +"TR_test_pin.py::test_pin_empty_cannot_send": "40e337e5ef45335d8b521135f4ffca25b5578b6d9af2d91aa9650fb61fde29f1", "TR_test_pin.py::test_pin_incorrect": "852bf321191682d6cf67c06098ef87571a42f1337609ea90bf476296b344bab4", "TR_test_pin.py::test_pin_long": "d2a86a95b38b8c09c04f0e02a118b62174e835c3ea58aace2d46d9af2a1c561b", "TR_test_pin.py::test_pin_long_delete": "6006261b91ea207efb220cd20cf5574e775e8e4ce04eb6f86f924f12fd818a2f", @@ -2035,6 +2036,7 @@ "TT_test_pin.py::test_pin_cancel": "05f5f819be61fec8c7c4341fd23c1bccf78cff93f05d573dd4f528bb0f1edbf5", "TT_test_pin.py::test_pin_change": "199d5ccb7760efcaafcc1156274c66d983c4b65c5bac4ebc27b14a060bd1ba4c", "TT_test_pin.py::test_pin_delete_hold": "8fc7930af448875005381482abd1751a980fbb2606d8b764b33bfb3cb1fad483", +"TT_test_pin.py::test_pin_empty_cannot_send": "0f7d5bd47f9f61133fbba9a1db1486e48dfd53d71d1b7a7d4a22d7062e7ade52", "TT_test_pin.py::test_pin_incorrect": "27f7eea0673208eddadf462de2da644675c71ab7a96858b3eda9d1299579cd47", "TT_test_pin.py::test_pin_long": "42186e29bbae2d52ca2f7616b7812502f485c4677f458f96c2440c8f21b14dff", "TT_test_pin.py::test_pin_long_delete": "53dced36adc89e59dd0fd1b885d1a1508d5988e77870f12625bc594302067180",