mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-07 14:00:57 +00:00
test: fix handling of PASSPHRASE_ON_DEVICE
[no changelog]
This commit is contained in:
parent
f1772c6651
commit
75803e41da
@ -126,7 +126,7 @@ class TrezorClient:
|
|||||||
|
|
||||||
def get_session(
|
def get_session(
|
||||||
self,
|
self,
|
||||||
passphrase: str | None = None,
|
passphrase: str | object | None = None,
|
||||||
derive_cardano: bool = False,
|
derive_cardano: bool = False,
|
||||||
) -> Session:
|
) -> Session:
|
||||||
"""
|
"""
|
||||||
@ -141,6 +141,7 @@ class TrezorClient:
|
|||||||
passphrase = ""
|
passphrase = ""
|
||||||
return SessionV1.new(self, passphrase, derive_cardano)
|
return SessionV1.new(self, passphrase, derive_cardano)
|
||||||
if isinstance(self.protocol, ProtocolV2):
|
if isinstance(self.protocol, ProtocolV2):
|
||||||
|
assert isinstance(passphrase, str) or passphrase is None
|
||||||
return SessionV2.new(self, passphrase, derive_cardano)
|
return SessionV2.new(self, passphrase, derive_cardano)
|
||||||
raise NotImplementedError # TODO
|
raise NotImplementedError # TODO
|
||||||
|
|
||||||
|
@ -1457,10 +1457,10 @@ class TrezorClientDebugLink(TrezorClient):
|
|||||||
|
|
||||||
def get_session(
|
def get_session(
|
||||||
self,
|
self,
|
||||||
passphrase: str | None = "",
|
passphrase: str | object | None = "",
|
||||||
derive_cardano: bool = False,
|
derive_cardano: bool = False,
|
||||||
) -> Session:
|
) -> Session:
|
||||||
if passphrase is not None:
|
if isinstance(passphrase, str):
|
||||||
passphrase = Mnemonic.normalize_string(passphrase)
|
passphrase = Mnemonic.normalize_string(passphrase)
|
||||||
return super().get_session(passphrase, derive_cardano)
|
return super().get_session(passphrase, derive_cardano)
|
||||||
|
|
||||||
|
@ -93,7 +93,10 @@ class SessionV1(Session):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new(
|
def new(
|
||||||
cls, client: TrezorClient, passphrase: str = "", derive_cardano: bool = False
|
cls,
|
||||||
|
client: TrezorClient,
|
||||||
|
passphrase: str | object = "",
|
||||||
|
derive_cardano: bool = False,
|
||||||
) -> SessionV1:
|
) -> SessionV1:
|
||||||
assert isinstance(client.protocol, ProtocolV1)
|
assert isinstance(client.protocol, ProtocolV1)
|
||||||
session_id = client.features.session_id
|
session_id = client.features.session_id
|
||||||
|
@ -21,6 +21,7 @@ from typing import TYPE_CHECKING
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import btc, device, exceptions, messages
|
from trezorlib import btc, device, exceptions, messages
|
||||||
|
from trezorlib.client import PASSPHRASE_ON_DEVICE
|
||||||
from trezorlib.debuglink import LayoutType
|
from trezorlib.debuglink import LayoutType
|
||||||
from trezorlib.debuglink import SessionDebugWrapper as Session
|
from trezorlib.debuglink import SessionDebugWrapper as Session
|
||||||
from trezorlib.protobuf import MessageType
|
from trezorlib.protobuf import MessageType
|
||||||
@ -210,8 +211,10 @@ def test_autolock_passphrase_keyboard(device_handler: "BackgroundDeviceHandler")
|
|||||||
debug = device_handler.debuglink()
|
debug = device_handler.debuglink()
|
||||||
|
|
||||||
# get address
|
# get address
|
||||||
device_handler.run_with_session(common.get_test_address) # type: ignore
|
session = Session(
|
||||||
|
device_handler.client.get_session(passphrase=PASSPHRASE_ON_DEVICE)
|
||||||
|
)
|
||||||
|
device_handler.run_with_provided_session(session, common.get_test_address) # type: ignore
|
||||||
assert "PassphraseKeyboard" in debug.read_layout().all_components()
|
assert "PassphraseKeyboard" in debug.read_layout().all_components()
|
||||||
|
|
||||||
if debug.layout_type is LayoutType.TR:
|
if debug.layout_type is LayoutType.TR:
|
||||||
@ -252,8 +255,10 @@ def test_autolock_interrupts_passphrase(device_handler: "BackgroundDeviceHandler
|
|||||||
debug = device_handler.debuglink()
|
debug = device_handler.debuglink()
|
||||||
|
|
||||||
# get address
|
# get address
|
||||||
device_handler.run_with_session(common.get_test_address) # type: ignore
|
session = Session(
|
||||||
|
device_handler.client.get_session(passphrase=PASSPHRASE_ON_DEVICE)
|
||||||
|
)
|
||||||
|
device_handler.run_with_provided_session(session, common.get_test_address) # type: ignore
|
||||||
assert "PassphraseKeyboard" in debug.read_layout().all_components()
|
assert "PassphraseKeyboard" in debug.read_layout().all_components()
|
||||||
|
|
||||||
if debug.layout_type is LayoutType.TR:
|
if debug.layout_type is LayoutType.TR:
|
||||||
|
Loading…
Reference in New Issue
Block a user