From 8c933e75bd1958e5c0121c056edcbf5b216e947b Mon Sep 17 00:00:00 2001 From: Valentina1133 <141633821+Valentina1133@users.noreply.github.com> Date: Fri, 17 Nov 2023 17:54:57 +0300 Subject: [PATCH] test: test_unlock_keycard with correct and incorrect PUK added (#312) --- test/e2e/constants/keycard.py | 9 + .../gui/components/settings/keycard_popup.py | 14 +- test/e2e/gui/objects_map/component_names.py | 2 +- .../test_check_whats_on_keycard.py | 2 +- ...te_keycard_account_with_new_seed_phrase.py | 4 +- .../test_factory_reset_keycard.py | 8 +- .../test_setup_existing_account.py | 4 +- .../settings_keycard/test_unlock_keycard.py | 219 ++++++++++++++++++ 8 files changed, 248 insertions(+), 14 deletions(-) create mode 100644 test/e2e/tests/settings/settings_keycard/test_unlock_keycard.py diff --git a/test/e2e/constants/keycard.py b/test/e2e/constants/keycard.py index d28e375764..43b51c473a 100644 --- a/test/e2e/constants/keycard.py +++ b/test/e2e/constants/keycard.py @@ -4,6 +4,8 @@ from enum import Enum class Keycard(Enum): KEYCARD_PIN = '111111' KEYCARD_INCORRECT_PIN = '222222' + KEYCARD_CORRECT_PUK = '111111111111' + KEYCARD_INCORRECT_PUK = '222222222222' KEYCARD_NAME = 'Test Keycard' ACCOUNT_NAME = 'Test Account' KEYCARD_POPUP_HEADER_CREATE_SEED = 'Create a new Keycard account with a new seed phrase' @@ -40,6 +42,13 @@ class Keycard(Enum): KEYCARD_FACTORY_RESET_SUCCESSFUL = 'Keycard successfully factory reset' KEYCARD_YOU_CAN_USE_AS_EMPTY = 'You can now use this Keycard as if it\nwas a brand new empty Keycard' KEYCARD_INCORRECT_PIN_MESSAGE = 'PIN incorrect' + KEYCARD_4_ATTEMPTS_REMAINING = '4 attempts remaining' + KEYCARD_3_ATTEMPTS_REMAINING = '3 attempts remaining' KEYCARD_2_ATTEMPTS_REMAINING = '2 attempts remaining' KEYCARD_1_ATTEMPT_REMAINING = '1 attempt remaining' KEYCARD_LOCKED_INCORRECT_PIN = 'Pin entered incorrectly too many times' + KEYCARD_LOCKED_INCORRECT_PUK = 'Puk entered incorrectly too many times' + KEYCARD_UNLOCK = 'Unlock this Keycard' + KEYCARD_ENTER_PUK = 'Enter PUK' + KEYCARD_UNLOCK_SUCCESSFUL = 'Unlock successful' + KEYCARD_PUK_IS_INCORRECT = 'The PUK is incorrect, try entering it again' diff --git a/test/e2e/gui/components/settings/keycard_popup.py b/test/e2e/gui/components/settings/keycard_popup.py index 9c44e8f0c8..735337502a 100644 --- a/test/e2e/gui/components/settings/keycard_popup.py +++ b/test/e2e/gui/components/settings/keycard_popup.py @@ -43,6 +43,7 @@ class KeycardPopup(BasePopup): 'i_understand_the_key_pair_on_this_Keycard_will_be_deleted_StatusCheckBox') self._emoji_button = QObject('statusSmartIdenticonLetter_StatusLetterIdenticon') self._add_another_account_button = Button('add_another_account_StatusButton') + self._secondary_button = Button('secondary_StatusButton') self._color_radiobutton = QObject('color_StatusColorRadioButton') @property @@ -134,7 +135,7 @@ class KeycardPopup(BasePopup): return self @allure.step('Set pin') - def input_pin(self, pin): + def input_pin_or_puk(self, pin): driver.nativeType(pin) @allure.step('Click Next button') @@ -177,7 +178,7 @@ class KeycardPopup(BasePopup): @allure.step('Add another account') def add_account(self): - self._add_another_account_button.click() + self._secondary_button.click() return self @allure.step('Name account') @@ -225,8 +226,8 @@ class KeycardPopup(BasePopup): @allure.step('Import keycard via seed phrase') def import_keycard_via_seed_phrase(self, seed_phrase_words: list, pin: str, keycard_name: str, account_name: str): self.input_seed_phrase(seed_phrase_words) - self.input_pin(pin) - self.input_pin(pin) + self.input_pin_or_puk(pin) + self.input_pin_or_puk(pin) self.click_next() self.name_keycard_and_account(keycard_name, account_name) @@ -252,3 +253,8 @@ class KeycardPopup(BasePopup): @allure.step('Confirm that understand that keypair will be deleted in checkbox') def confirm_keypair_will_be_deleted(self, value: bool): self._understand_keypair_deleted_checkbox.set(value) + + @allure.step('Click Unlock using PUK') + def click_unlock_puk(self): + self._secondary_button.click() + return self diff --git a/test/e2e/gui/objects_map/component_names.py b/test/e2e/gui/objects_map/component_names.py index f16c338309..bf24344be0 100644 --- a/test/e2e/gui/objects_map/component_names.py +++ b/test/e2e/gui/objects_map/component_names.py @@ -345,4 +345,4 @@ switchTabBar_18_words_StatusSwitchTabButton = {"checkable": True, "container": s switchTabBar_24_words_StatusSwitchTabButton = {"checkable": True, "container": switchTabBar_StatusSwitchTabBar, "objectName": "24SeedButton", "text": "24 words", "type": "StatusSwitchTabButton", "visible": True} i_understand_the_key_pair_on_this_Keycard_will_be_deleted_StatusCheckBox = {"checkable": True, "container": statusDesktop_mainWindow_overlay, "id": "confirmation", "type": "StatusCheckBox", "visible": True} statusSmartIdenticonLetter_StatusLetterIdenticon = {"container": statusDesktop_mainWindow_overlay, "objectName": "statusSmartIdenticonLetter", "type": "StatusLetterIdenticon", "visible": True} -add_another_account_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "id": "secondaryButton", "type": "StatusButton", "unnamed": 1, "visible": True} +secondary_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "id": "secondaryButton", "type": "StatusButton", "unnamed": 1, "visible": True} diff --git a/test/e2e/tests/settings/settings_keycard/test_check_whats_on_keycard.py b/test/e2e/tests/settings/settings_keycard/test_check_whats_on_keycard.py index 5858cb1774..8e69dbc85b 100644 --- a/test/e2e/tests/settings/settings_keycard/test_check_whats_on_keycard.py +++ b/test/e2e/tests/settings/settings_keycard/test_check_whats_on_keycard.py @@ -122,7 +122,7 @@ def test_check_whats_on_keycard(main_screen: MainWindow, user_account): configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" pin = Keycard.KEYCARD_PIN.value keycard_name = 'Card-1 Name' - keycard_popup.input_pin(pin) + keycard_popup.input_pin_or_puk(pin) assert driver.waitFor(lambda: Keycard.KEYCARD_PIN_VERIFIED.value in keycard_popup.keycard_instructions), \ "There is no correct keycard instruction" diff --git a/test/e2e/tests/settings/settings_keycard/test_create_keycard_account_with_new_seed_phrase.py b/test/e2e/tests/settings/settings_keycard/test_create_keycard_account_with_new_seed_phrase.py index f206bb7643..979af17d5b 100644 --- a/test/e2e/tests/settings/settings_keycard/test_create_keycard_account_with_new_seed_phrase.py +++ b/test/e2e/tests/settings/settings_keycard/test_create_keycard_account_with_new_seed_phrase.py @@ -75,10 +75,10 @@ def test_create_keycard_account_with_new_seed_phrase(main_screen: MainWindow, na with step('Enter and repeat PIN and verify keycard popup instructions are correct'): pin = Keycard.KEYCARD_PIN.value - keycard_popup.input_pin(pin) + keycard_popup.input_pin_or_puk(pin) assert driver.waitFor(lambda: Keycard.KEYCARD_REPEAT_PIN.value in keycard_popup.keycard_instructions), \ "There is no correct keycard instruction" - keycard_popup.input_pin(pin) + keycard_popup.input_pin_or_puk(pin) assert driver.waitFor(lambda: Keycard.KEYCARD_PIN_SET.value in keycard_popup.keycard_instructions), \ "There is no correct keycard instruction" diff --git a/test/e2e/tests/settings/settings_keycard/test_factory_reset_keycard.py b/test/e2e/tests/settings/settings_keycard/test_factory_reset_keycard.py index 8e9798cd07..ea542dc487 100644 --- a/test/e2e/tests/settings/settings_keycard/test_factory_reset_keycard.py +++ b/test/e2e/tests/settings/settings_keycard/test_factory_reset_keycard.py @@ -39,7 +39,7 @@ def test_factory_reset_keycard(main_screen: MainWindow, user_account): configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" pin = Keycard.KEYCARD_PIN.value keycard_name = 'Card-1 Name' - keycard_popup.input_pin(pin) + keycard_popup.input_pin_or_puk(pin) assert driver.waitFor(lambda: Keycard.KEYCARD_PIN_VERIFIED.value in keycard_popup.keycard_instructions), \ "There is no correct keycard instruction" @@ -96,7 +96,7 @@ def test_factory_reset_keycard_incorrect_pin(main_screen: MainWindow, user_accou assert driver.waitFor(lambda: Keycard.KEYCARD_ENTER_PIN.value in keycard_popup.keycard_instructions, configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" incorrect_pin = Keycard.KEYCARD_INCORRECT_PIN.value - keycard_popup.input_pin(incorrect_pin) + keycard_popup.input_pin_or_puk(incorrect_pin) assert driver.waitFor( lambda: Keycard.KEYCARD_INCORRECT_PIN_MESSAGE.value in keycard_popup.keycard_instructions), \ @@ -110,7 +110,7 @@ def test_factory_reset_keycard_incorrect_pin(main_screen: MainWindow, user_accou assert driver.waitFor(lambda: Keycard.KEYCARD_ENTER_PIN_2.value in keycard_popup.keycard_instructions, configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" incorrect_pin = Keycard.KEYCARD_INCORRECT_PIN.value - keycard_popup.input_pin(incorrect_pin) + keycard_popup.input_pin_or_puk(incorrect_pin) assert driver.waitFor( lambda: Keycard.KEYCARD_INCORRECT_PIN_MESSAGE.value in keycard_popup.keycard_instructions), \ @@ -124,7 +124,7 @@ def test_factory_reset_keycard_incorrect_pin(main_screen: MainWindow, user_accou assert driver.waitFor(lambda: Keycard.KEYCARD_ENTER_PIN_2.value in keycard_popup.keycard_instructions, configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" incorrect_pin = Keycard.KEYCARD_INCORRECT_PIN.value - keycard_popup.input_pin(incorrect_pin) + keycard_popup.input_pin_or_puk(incorrect_pin) assert driver.waitFor( lambda: Keycard.KEYCARD_LOCKED.value in keycard_popup.keycard_instructions), \ diff --git a/test/e2e/tests/settings/settings_keycard/test_setup_existing_account.py b/test/e2e/tests/settings/settings_keycard/test_setup_existing_account.py index 049c53f9fd..8f7f3fcd23 100644 --- a/test/e2e/tests/settings/settings_keycard/test_setup_existing_account.py +++ b/test/e2e/tests/settings/settings_keycard/test_setup_existing_account.py @@ -104,10 +104,10 @@ def test_setup_keycard_with_existing_account(main_screen: MainWindow, user_accou with step('Insert PIN and repeat PIN and verify keycard popup instructions are correct'): pin = Keycard.KEYCARD_PIN.value - keycard_popup.input_pin(pin) + keycard_popup.input_pin_or_puk(pin) assert driver.waitFor(lambda: Keycard.KEYCARD_REPEAT_PIN.value in keycard_popup.keycard_instructions), \ "There is no correct keycard instruction" - keycard_popup.input_pin(pin) + keycard_popup.input_pin_or_puk(pin) assert driver.waitFor(lambda: Keycard.KEYCARD_PIN_SET.value in keycard_popup.keycard_instructions), \ "There is no correct keycard instruction" diff --git a/test/e2e/tests/settings/settings_keycard/test_unlock_keycard.py b/test/e2e/tests/settings/settings_keycard/test_unlock_keycard.py new file mode 100644 index 0000000000..c50fa9dd8c --- /dev/null +++ b/test/e2e/tests/settings/settings_keycard/test_unlock_keycard.py @@ -0,0 +1,219 @@ +import time + +import allure +import pytest +from allure import step + +import configs +import constants +import driver +from constants.keycard import Keycard +from gui.main_window import MainWindow +from gui.mocked_keycard_controller import MockedKeycardController + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/704607', 'Unlock Keycard') +@pytest.mark.case(704607) +@pytest.mark.parametrize('user_account', [constants.user.user_account_one]) +@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/274") +def test_unlock_keycard_using_correct_puk(main_screen: MainWindow, user_account): + main_screen.prepare() + + with step('Plug in reader'): + main_screen.hide() + keycard_controller = MockedKeycardController().wait_until_appears() + keycard_controller.plugin_reader() + keycard_controller.choose_mnemonic_metadata_keycard() + keycard_controller.register_keycard() + keycard_controller.insert_keycard_1() + main_screen.show() + + with step('Choose option Check whats on keycard in settings'): + keycard_settings = main_screen.left_panel.open_settings().left_panel.open_keycard_settings() + keycard_popup = keycard_settings.click_check_whats_on_keycard() + + with step('Enter incorrect PIN 3 times and verify keycard popup instructions are correct'): + assert driver.waitFor(lambda: Keycard.KEYCARD_ENTER_PIN.value in keycard_popup.keycard_instructions, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" + incorrect_pin = Keycard.KEYCARD_INCORRECT_PIN.value + keycard_popup.input_pin_or_puk(incorrect_pin) + time.sleep(1) + keycard_popup.input_pin_or_puk(incorrect_pin) + time.sleep(1) + keycard_popup.input_pin_or_puk(incorrect_pin) + time.sleep(1) + + assert driver.waitFor( + lambda: Keycard.KEYCARD_LOCKED.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + assert driver.waitFor( + lambda: Keycard.KEYCARD_LOCKED_INCORRECT_PIN.value in keycard_popup.keycard_instructions), \ + "There is no correct keycard instruction" + + with step('Click Unlock keycard button'): + keycard_popup.click_next() + + with step('Verify keycard popup instructions are correct'): + assert driver.waitFor( + lambda: Keycard.KEYCARD_UNLOCK.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + + with step('Click Unlock using PUK and enter incorrect PUK'): + keycard_popup.click_unlock_puk() + correct_puk = Keycard.KEYCARD_CORRECT_PUK.value + keycard_popup.input_pin_or_puk(correct_puk) + time.sleep(1) + keycard_popup.click_next() + + with step('Verify that asked to choose PIN'): + assert driver.waitFor(lambda: Keycard.KEYCARD_CHOOSE_PIN.value in keycard_popup.keycard_instructions, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" + assert Keycard.KEYCARD_PIN_NOTE.value in keycard_popup.keycard_instructions + + with step('Enter PIN and repeat PIN and verify keycard popup instructions are correct'): + pin = Keycard.KEYCARD_PIN.value + keycard_popup.input_pin_or_puk(pin) + assert driver.waitFor(lambda: Keycard.KEYCARD_REPEAT_PIN.value in keycard_popup.keycard_instructions), \ + "There is no correct keycard instruction" + keycard_popup.input_pin_or_puk(pin) + assert driver.waitFor(lambda: Keycard.KEYCARD_PIN_SET.value in keycard_popup.keycard_instructions), \ + "There is no correct keycard instruction" + keycard_popup.click_next() + + with step('Verify keycard popup instructions are correct'): + assert driver.waitFor( + lambda: Keycard.KEYCARD_UNLOCK_SUCCESSFUL.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/704608', 'Unlock Keycard: incorrect PUK') +@pytest.mark.case(704608) +@pytest.mark.parametrize('user_account', [constants.user.user_account_one]) +@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/274") +def test_unlock_keycard_using_incorrect_puk(main_screen: MainWindow, user_account): + main_screen.prepare() + + with step('Plug in reader'): + main_screen.hide() + keycard_controller = MockedKeycardController().wait_until_appears() + keycard_controller.plugin_reader() + keycard_controller.choose_mnemonic_metadata_keycard() + keycard_controller.register_keycard() + keycard_controller.insert_keycard_1() + main_screen.show() + + with step('Choose option Check whats on keycard in settings'): + keycard_settings = main_screen.left_panel.open_settings().left_panel.open_keycard_settings() + keycard_popup = keycard_settings.click_check_whats_on_keycard() + + with step('Enter incorrect PIN 3 times and verify keycard popup instructions are correct'): + assert driver.waitFor(lambda: Keycard.KEYCARD_ENTER_PIN.value in keycard_popup.keycard_instructions, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" + incorrect_pin = Keycard.KEYCARD_INCORRECT_PIN.value + keycard_popup.input_pin_or_puk(incorrect_pin) + time.sleep(1) + keycard_popup.input_pin_or_puk(incorrect_pin) + time.sleep(1) + keycard_popup.input_pin_or_puk(incorrect_pin) + time.sleep(1) + + assert driver.waitFor( + lambda: Keycard.KEYCARD_LOCKED.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + assert driver.waitFor( + lambda: Keycard.KEYCARD_LOCKED_INCORRECT_PIN.value in keycard_popup.keycard_instructions), \ + "There is no correct keycard instruction" + + with step('Click Unlock keycard button'): + keycard_popup.click_next() + + with step('Verify keycard popup instructions are correct'): + assert driver.waitFor( + lambda: Keycard.KEYCARD_UNLOCK.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + + with step('Click Unlock using PUK and enter incorrect PUK'): + keycard_popup.click_unlock_puk() + incorrect_puk = Keycard.KEYCARD_INCORRECT_PUK.value + keycard_popup.input_pin_or_puk(incorrect_puk) + time.sleep(1) + keycard_popup.click_next() + + with step('Verify that asked to choose PIN'): + assert driver.waitFor(lambda: Keycard.KEYCARD_CHOOSE_PIN.value in keycard_popup.keycard_instructions, + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), "There is no correct keycard instruction" + assert Keycard.KEYCARD_PIN_NOTE.value in keycard_popup.keycard_instructions + + with step('Enter PIN and repeat PIN and verify keycard popup instructions are correct'): + pin = Keycard.KEYCARD_PIN.value + keycard_popup.input_pin_or_puk(pin) + assert driver.waitFor(lambda: Keycard.KEYCARD_REPEAT_PIN.value in keycard_popup.keycard_instructions), \ + "There is no correct keycard instruction" + keycard_popup.input_pin_or_puk(pin) + assert driver.waitFor(lambda: Keycard.KEYCARD_PIN_SET.value in keycard_popup.keycard_instructions), \ + "There is no correct keycard instruction" + keycard_popup.click_next() + + with step('Verify keycard popup instructions are correct'): + assert driver.waitFor( + lambda: Keycard.KEYCARD_PUK_IS_INCORRECT.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + assert driver.waitFor( + lambda: Keycard.KEYCARD_4_ATTEMPTS_REMAINING.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + + with step('Enter incorrect PUK again'): + incorrect_puk = Keycard.KEYCARD_INCORRECT_PUK.value + keycard_popup.input_pin_or_puk(incorrect_puk) + time.sleep(1) + keycard_popup.click_next() + + with step('Verify keycard popup instructions are correct'): + assert driver.waitFor( + lambda: Keycard.KEYCARD_PUK_IS_INCORRECT.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + assert driver.waitFor( + lambda: Keycard.KEYCARD_3_ATTEMPTS_REMAINING.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + + with step('Enter incorrect PUK again'): + incorrect_puk = Keycard.KEYCARD_INCORRECT_PUK.value + keycard_popup.input_pin_or_puk(incorrect_puk) + time.sleep(1) + keycard_popup.click_next() + + with step('Verify keycard popup instructions are correct'): + assert driver.waitFor( + lambda: Keycard.KEYCARD_PUK_IS_INCORRECT.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + assert driver.waitFor( + lambda: Keycard.KEYCARD_2_ATTEMPTS_REMAINING.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + + with step('Enter incorrect PUK again'): + incorrect_puk = Keycard.KEYCARD_INCORRECT_PUK.value + keycard_popup.input_pin_or_puk(incorrect_puk) + time.sleep(1) + keycard_popup.click_next() + + with step('Verify keycard popup instructions are correct'): + assert driver.waitFor( + lambda: Keycard.KEYCARD_PUK_IS_INCORRECT.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + assert driver.waitFor( + lambda: Keycard.KEYCARD_1_ATTEMPT_REMAINING.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + + with step('Enter incorrect PUK again'): + incorrect_puk = Keycard.KEYCARD_INCORRECT_PUK.value + keycard_popup.input_pin_or_puk(incorrect_puk) + time.sleep(1) + keycard_popup.click_next() + + with step('Verify keycard is locked and it says that PUK entered incorrectly'): + assert driver.waitFor( + lambda: Keycard.KEYCARD_LOCKED.value in keycard_popup.keycard_instructions), \ + f"There is no correct keycard instruction {keycard_popup.keycard_instructions}" + assert driver.waitFor( + lambda: Keycard.KEYCARD_LOCKED_INCORRECT_PUK.value in keycard_popup.keycard_instructions), \ + "There is no correct keycard instruction"