diff --git a/tests/device_tests/test_session_id_and_passphrase.py b/tests/device_tests/test_session_id_and_passphrase.py index f8949255f4..9dc059e978 100644 --- a/tests/device_tests/test_session_id_and_passphrase.py +++ b/tests/device_tests/test_session_id_and_passphrase.py @@ -50,7 +50,11 @@ XPUB_REQUEST = messages.GetPublicKey(address_n=ADDRESS_N, coin_name="Bitcoin") SESSIONS_STORED = 10 -def _get_xpub(session: Session, expected_passphrase_req: bool = False): +def _get_xpub( + session: Session, + expected_passphrase_req: bool = False, + passphrase_v1: str | None = None, +): """Get XPUB and check that the appropriate passphrase flow has happened.""" if expected_passphrase_req: expected_responses = [ @@ -61,6 +65,8 @@ def _get_xpub(session: Session, expected_passphrase_req: bool = False): ] else: expected_responses = [messages.PublicKey] + if passphrase_v1 is not None and session.session_version == Session.CODEC_V1: + session.passphrase = passphrase_v1 with session: session.set_expected_responses(expected_responses) @@ -90,9 +96,11 @@ def test_session_with_passphrase(client: Client): assert session3 != session_id assert _get_xpub(session3, expected_passphrase_req=True) == XPUB_PASSPHRASES["A"] - # Unknown session id is the same as setting it to None. - # _init_session(client, session_id=b"X" * 32) - # assert _get_xpub(passphrase="A") == XPUB_PASSPHRASES["A"] + # TODO: The following part is kept only for solving UI-diff in tests + # - it can be removed if fixtures are updated, imo + session4 = Session(client.get_session(passphrase="A")) + assert session4 != session_id + assert _get_xpub(session4, expected_passphrase_req=True) == XPUB_PASSPHRASES["A"] @pytest.mark.setup_client(passphrase=True) @@ -188,12 +196,6 @@ def test_max_sessions_with_passphrases(client: Client): sessions[passphrase] = session assert _get_xpub(session, expected_passphrase_req=True) == xpub - for passphrase, xpub in XPUB_PASSPHRASES.items(): - session = Session(client.get_session(passphrase=passphrase)) - assert session.id not in session_ids.values() - session_ids[passphrase] = session.id - sessions[passphrase] = session - assert _get_xpub(session, expected_passphrase_req=True) == xpub # passphrase is not prompted for the started the sessions, regardless the order # let's try 20 different orderings passphrases = list(XPUB_PASSPHRASES.keys()) @@ -220,7 +222,9 @@ def test_max_sessions_with_passphrases(client: Client): for passphrase in reversed(passphrases): resumed_session = Session(client.resume_session(sessions[passphrase])) _get_xpub( - resumed_session, expected_passphrase_req=True + resumed_session, + expected_passphrase_req=True, + passphrase_v1="whatever", ) # passphrase is prompted