mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-11 15:12:44 +00:00
chore: rename management_session to seedless_session everywhere
[no changelog]
This commit is contained in:
parent
f0f9a78959
commit
47cbe363e5
@ -125,8 +125,7 @@ def _from_env(name: str) -> bool:
|
||||
@click.option("-V", "--valgrind", is_flag=True, help="Use valgrind instead of debugger (-D)")
|
||||
@click.option("-t", "--temporary-profile", is_flag=True, help="Create an empty temporary profile")
|
||||
@click.option("-w", "--watch", is_flag=True, help="Restart emulator if sources change")
|
||||
@click.option("-X", "--extra-arg", "extra_args", multiple=True, help="Extra argument to pass to micropython")
|
||||
# fmt: on
|
||||
@click.option("-X", "--extra-arg", "extra_args", multiple=True, help="Extra argument to pass to micropython")# fmt: on
|
||||
@click.argument("command", nargs=-1, type=click.UNPROCESSED)
|
||||
def cli(
|
||||
disable_animation: bool,
|
||||
@ -282,10 +281,10 @@ def cli(
|
||||
label = "Emulator"
|
||||
|
||||
assert emulator.client is not None
|
||||
trezorlib.device.wipe(emulator.client.get_management_session())
|
||||
trezorlib.device.wipe(emulator.client.get_seedless_session())
|
||||
|
||||
trezorlib.debuglink.load_device(
|
||||
emulator.client.get_management_session(),
|
||||
emulator.client.get_seedless_session(),
|
||||
mnemonics,
|
||||
pin=None,
|
||||
passphrase_protection=False,
|
||||
|
@ -203,7 +203,7 @@ def get_allocated_session_index(channel_id: bytes, session_id: bytes) -> int | N
|
||||
return None
|
||||
|
||||
|
||||
def is_management_session(session_cache: SessionThpCache) -> bool:
|
||||
def is_seedless_session(session_cache: SessionThpCache) -> bool:
|
||||
return _get_session_state(session_cache) == _SEEDLESS_STATE
|
||||
|
||||
|
||||
|
@ -23,11 +23,11 @@ def get_new_session_context(
|
||||
return SessionContext(channel_ctx, session_cache)
|
||||
|
||||
|
||||
def get_new_management_session_ctx(
|
||||
def get_new_seedless_session_ctx(
|
||||
channel_ctx: Channel, session_id: int
|
||||
) -> SeedlessSessionContext:
|
||||
"""
|
||||
Creates new `ManagementSessionContext` that is not backed by a cache entry.
|
||||
Creates new `SeedlessSessionContext` that is not backed by a cache entry.
|
||||
|
||||
Seed cannot be derived with this type of session.
|
||||
"""
|
||||
@ -38,7 +38,7 @@ def get_session_from_cache(
|
||||
channel_ctx: Channel, session_id: int
|
||||
) -> GenericSessionContext | None:
|
||||
"""
|
||||
Returns a `SessionContext` (or `ManagementSessionContext`) reconstructed from a cache or `None` if backing cache is not found.
|
||||
Returns a `SessionContext` (or `SeedlessSessionContext`) reconstructed from a cache or `None` if backing cache is not found.
|
||||
"""
|
||||
session_id_bytes = session_id.to_bytes(1, "big")
|
||||
session_cache = cache_thp.get_allocated_session(
|
||||
@ -46,6 +46,6 @@ def get_session_from_cache(
|
||||
)
|
||||
if session_cache is None:
|
||||
return None
|
||||
elif cache_thp.is_management_session(session_cache):
|
||||
elif cache_thp.is_seedless_session(session_cache):
|
||||
return SeedlessSessionContext(channel_ctx, session_id)
|
||||
return SessionContext(channel_ctx, session_cache)
|
||||
|
@ -200,10 +200,10 @@ class TrezorConnection:
|
||||
def get_client(self) -> TrezorClient:
|
||||
return get_client(self.get_transport())
|
||||
|
||||
def get_management_session(self) -> Session:
|
||||
def get_seedless_session(self) -> Session:
|
||||
client = self.get_client()
|
||||
management_session = client.get_management_session()
|
||||
return management_session
|
||||
seedless_session = client.get_seedless_session()
|
||||
return seedless_session
|
||||
|
||||
@contextmanager
|
||||
def client_context(self):
|
||||
@ -253,7 +253,7 @@ class TrezorConnection:
|
||||
"""
|
||||
try:
|
||||
if management:
|
||||
session = self.get_management_session()
|
||||
session = self.get_seedless_session()
|
||||
else:
|
||||
session = self.get_session(
|
||||
derive_cardano=derive_cardano,
|
||||
@ -294,8 +294,8 @@ def with_session(
|
||||
management: bool = False,
|
||||
must_resume: bool = False,
|
||||
) -> t.Callable[[FuncWithSession], t.Callable[P, R]]:
|
||||
"""Provides a Click command with parameter `session=obj.get_session(...)` or
|
||||
`session=obj.get_management_session()` based on the parameters provided.
|
||||
"""Provides a Click command with parameter `session=obj.get_session(...)`
|
||||
based on the parameters provided.
|
||||
|
||||
If default parameters are ok, this decorator can be used without parentheses.
|
||||
|
||||
|
@ -320,10 +320,10 @@ def reboot_to_bootloader(obj: "TrezorConnection") -> None:
|
||||
|
||||
Currently only supported on Trezor Model One.
|
||||
"""
|
||||
# avoid using @with_management_session because it closes the session afterwards,
|
||||
# avoid using @with_session because it closes the session afterwards,
|
||||
# which triggers double prompt on device
|
||||
with obj.client_context() as client:
|
||||
device.reboot_to_bootloader(client.get_management_session())
|
||||
device.reboot_to_bootloader(client.get_seedless_session())
|
||||
|
||||
|
||||
@cli.command()
|
||||
|
@ -656,7 +656,7 @@ def update(
|
||||
against data.trezor.io information, if available.
|
||||
"""
|
||||
with obj.client_context() as client:
|
||||
management_session = client.get_management_session()
|
||||
seedless_session = client.get_seedless_session()
|
||||
if sum(bool(x) for x in (filename, url, version)) > 1:
|
||||
click.echo("You can use only one of: filename, url, version.")
|
||||
sys.exit(1)
|
||||
@ -712,7 +712,7 @@ def update(
|
||||
if _is_strict_update(client, firmware_data):
|
||||
header_size = _get_firmware_header_size(firmware_data)
|
||||
device.reboot_to_bootloader(
|
||||
management_session,
|
||||
seedless_session,
|
||||
boot_command=messages.BootCommand.INSTALL_UPGRADE,
|
||||
firmware_header=firmware_data[:header_size],
|
||||
language_data=language_data,
|
||||
@ -722,7 +722,7 @@ def update(
|
||||
click.echo(
|
||||
"WARNING: Seamless installation not possible, language data will not be uploaded."
|
||||
)
|
||||
device.reboot_to_bootloader(management_session)
|
||||
device.reboot_to_bootloader(seedless_session)
|
||||
|
||||
click.echo("Waiting for bootloader...")
|
||||
while True:
|
||||
@ -739,7 +739,7 @@ def update(
|
||||
sys.exit(1)
|
||||
|
||||
upload_firmware_into_device(
|
||||
session=client.get_management_session(), firmware_data=firmware_data
|
||||
session=client.get_seedless_session(), firmware_data=firmware_data
|
||||
)
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ class TrezorClient:
|
||||
passphrase_callback: t.Callable[[Session, t.Any], t.Any] | None = None
|
||||
pin_callback: t.Callable[[Session, t.Any], t.Any] | None = None
|
||||
|
||||
_management_session: Session | None = None
|
||||
_seedless_session: Session | None = None
|
||||
_features: messages.Features | None = None
|
||||
_protocol_version: int
|
||||
_setup_pin: str | None = None # Should by used only by conftest
|
||||
@ -167,21 +167,21 @@ class TrezorClient:
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
def get_management_session(self, new_session: bool = False) -> Session:
|
||||
def get_seedless_session(self, new_session: bool = False) -> Session:
|
||||
from .transport.session import SessionV1, SessionV2
|
||||
|
||||
if not new_session and self._management_session is not None:
|
||||
return self._management_session
|
||||
if not new_session and self._seedless_session is not None:
|
||||
return self._seedless_session
|
||||
if isinstance(self.protocol, ProtocolV1):
|
||||
self._management_session = SessionV1.new(
|
||||
self._seedless_session = SessionV1.new(
|
||||
client=self,
|
||||
passphrase="",
|
||||
derive_cardano=False,
|
||||
)
|
||||
elif isinstance(self.protocol, ProtocolV2):
|
||||
self._management_session = SessionV2(client=self, id=b"\x00")
|
||||
assert self._management_session is not None
|
||||
return self._management_session
|
||||
self._seedless_session = SessionV2(client=self, id=b"\x00")
|
||||
assert self._seedless_session is not None
|
||||
return self._seedless_session
|
||||
|
||||
def invalidate(self) -> None:
|
||||
self._is_invalidated = True
|
||||
|
@ -1311,7 +1311,7 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
self.transport = transport
|
||||
self.ui: DebugUI = DebugUI(self.debug)
|
||||
|
||||
self.reset_debug_features(new_management_session=True)
|
||||
self.reset_debug_features(new_seedless_session=True)
|
||||
self.sync_responses()
|
||||
|
||||
# So that we can choose right screenshotting logic (T1 vs TT)
|
||||
@ -1325,11 +1325,13 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
return self.debug.layout_type
|
||||
|
||||
def get_new_client(self) -> TrezorClientDebugLink:
|
||||
new_client = TrezorClientDebugLink(self.transport, self.debug.allow_interactions)
|
||||
new_client = TrezorClientDebugLink(
|
||||
self.transport, self.debug.allow_interactions
|
||||
)
|
||||
new_client.debug.screenshot_recording_dir = self.debug.screenshot_recording_dir
|
||||
return new_client
|
||||
|
||||
def reset_debug_features(self, new_management_session: bool = False) -> None:
|
||||
def reset_debug_features(self, new_seedless_session: bool = False) -> None:
|
||||
"""
|
||||
Prepare the debugging client for a new testcase.
|
||||
|
||||
@ -1343,8 +1345,8 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
t.Type[protobuf.MessageType],
|
||||
t.Callable[[protobuf.MessageType], protobuf.MessageType] | None,
|
||||
] = {}
|
||||
if new_management_session:
|
||||
self._management_session = self.get_management_session(new_session=True)
|
||||
if new_seedless_session:
|
||||
self._seedless_session = self.get_seedless_session(new_session=True)
|
||||
|
||||
@property
|
||||
def button_callback(self):
|
||||
@ -1455,7 +1457,7 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
# self.debug.close()
|
||||
|
||||
def lock(self) -> None:
|
||||
s = SessionDebugWrapper(self.get_management_session())
|
||||
s = SessionDebugWrapper(self.get_seedless_session())
|
||||
s.lock()
|
||||
|
||||
def get_session(
|
||||
@ -1565,7 +1567,7 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
else:
|
||||
input_flow = None
|
||||
|
||||
self.reset_debug_features(new_management_session=False)
|
||||
self.reset_debug_features(new_seedless_session=False)
|
||||
|
||||
if exc_type is None:
|
||||
# If no other exception was raised, evaluate missed responses
|
||||
@ -1638,14 +1640,14 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
|
||||
def _raw_read(self) -> protobuf.MessageType:
|
||||
__tracebackhide__ = True # for pytest # pylint: disable=W0612
|
||||
resp = self.get_management_session()._read()
|
||||
resp = self.get_seedless_session()._read()
|
||||
resp = self._filter_message(resp)
|
||||
if self.actual_responses is not None:
|
||||
self.actual_responses.append(resp)
|
||||
return resp
|
||||
|
||||
def _raw_write(self, msg: protobuf.MessageType) -> None:
|
||||
return self.get_management_session()._write(self._filter_message(msg))
|
||||
return self.get_seedless_session()._write(self._filter_message(msg))
|
||||
|
||||
@staticmethod
|
||||
def _expectation_lines(expected: list[MessageFilter], current: int) -> list[str]:
|
||||
@ -1720,11 +1722,11 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
try:
|
||||
# self.protocol.write(messages.Cancel())
|
||||
message = "SYNC" + secrets.token_hex(8)
|
||||
self.get_management_session()._write(messages.Ping(message=message))
|
||||
self.get_seedless_session()._write(messages.Ping(message=message))
|
||||
resp = None
|
||||
while resp != messages.Success(message=message):
|
||||
try:
|
||||
resp = self.get_management_session()._read()
|
||||
resp = self.get_seedless_session()._read()
|
||||
|
||||
raise Exception
|
||||
|
||||
|
@ -106,7 +106,7 @@ def main() -> None:
|
||||
devices = wait_for_devices()
|
||||
transport = choose_device(devices)
|
||||
client = TrezorClient(transport)
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
|
||||
rootdir = os.environ["encfs_root"] # Read "man encfs" for more
|
||||
passw_file = os.path.join(rootdir, "password.dat")
|
||||
|
@ -146,7 +146,7 @@ def main() -> None:
|
||||
return
|
||||
|
||||
client = TrezorClient(transport=transport)
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
|
||||
print()
|
||||
print("Confirm operation on Trezor")
|
||||
|
@ -15,7 +15,7 @@ from trezorlib.transport import get_transport
|
||||
def main() -> None:
|
||||
try:
|
||||
client = TrezorClient(get_transport())
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return
|
||||
|
@ -34,7 +34,7 @@ BIP32_PATH = parse_path("10016h/0")
|
||||
def encrypt(type: str, domain: str, secret: str) -> str:
|
||||
transport = get_transport()
|
||||
client = TrezorClient(transport)
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
dom = type.upper() + ": " + domain
|
||||
enc = encrypt_keyvalue(session, BIP32_PATH, dom, secret.encode(), False, True)
|
||||
return enc.hex()
|
||||
@ -43,7 +43,7 @@ def encrypt(type: str, domain: str, secret: str) -> str:
|
||||
def decrypt(type: str, domain: str, secret: bytes) -> bytes:
|
||||
transport = get_transport()
|
||||
client = TrezorClient(transport)
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
dom = type.upper() + ": " + domain
|
||||
dec = decrypt_keyvalue(session, BIP32_PATH, dom, secret, False, True)
|
||||
return dec
|
||||
|
@ -60,7 +60,7 @@ CENTER_BUTTON = buttons.grid35(1, 2)
|
||||
|
||||
def set_autolock_delay(device_handler: "BackgroundDeviceHandler", delay_ms: int):
|
||||
debug = device_handler.debuglink()
|
||||
Session(device_handler.client.get_management_session()).lock()
|
||||
Session(device_handler.client.get_seedless_session()).lock()
|
||||
device_handler.run_with_session(device.apply_settings, auto_lock_delay_ms=delay_ms) # type: ignore
|
||||
|
||||
assert "PinKeyboard" in debug.read_layout().all_components()
|
||||
|
@ -52,7 +52,7 @@ def test_backup_slip39_custom(
|
||||
|
||||
assert features.initialized is False
|
||||
|
||||
session = device_handler.client.get_management_session()
|
||||
session = device_handler.client.get_seedless_session()
|
||||
device_handler.run_with_provided_session(
|
||||
session,
|
||||
device.setup,
|
||||
|
@ -34,7 +34,7 @@ PIN4 = "1234"
|
||||
@pytest.mark.setup_client(pin=PIN4)
|
||||
def test_hold_to_lock(device_handler: "BackgroundDeviceHandler"):
|
||||
debug = device_handler.debuglink()
|
||||
session = device_handler.client.get_management_session()
|
||||
session = device_handler.client.get_seedless_session()
|
||||
session.call(messages.LockDevice())
|
||||
session.refresh_features()
|
||||
|
||||
|
@ -92,7 +92,7 @@ def prepare(
|
||||
|
||||
tap = False
|
||||
|
||||
Session(device_handler.client.get_management_session()).lock()
|
||||
Session(device_handler.client.get_seedless_session()).lock()
|
||||
|
||||
# Setup according to the wanted situation
|
||||
if situation == Situation.PIN_INPUT:
|
||||
|
@ -312,7 +312,7 @@ def _client_unlocked(
|
||||
|
||||
test_ui = request.config.getoption("ui")
|
||||
|
||||
_raw_client.reset_debug_features(new_management_session=True)
|
||||
_raw_client.reset_debug_features(new_seedless_session=True)
|
||||
_raw_client.open()
|
||||
if isinstance(_raw_client.protocol, ProtocolV1):
|
||||
try:
|
||||
@ -337,7 +337,7 @@ def _client_unlocked(
|
||||
try:
|
||||
if _raw_client.is_invalidated:
|
||||
_raw_client = _get_raw_client(request)
|
||||
session = _raw_client.get_management_session()
|
||||
session = _raw_client.get_seedless_session()
|
||||
wipe_device(session)
|
||||
sleep(1.5) # Makes tests more stable (wait for wipe to finish)
|
||||
break
|
||||
@ -361,7 +361,7 @@ def _client_unlocked(
|
||||
lang = request.session.config.getoption("lang") or "en"
|
||||
assert isinstance(lang, str)
|
||||
translations.set_language(
|
||||
SessionDebugWrapper(_raw_client.get_management_session()), lang
|
||||
SessionDebugWrapper(_raw_client.get_seedless_session()), lang
|
||||
)
|
||||
|
||||
setup_params = dict(
|
||||
@ -381,7 +381,7 @@ def _client_unlocked(
|
||||
setup_params["passphrase"], str
|
||||
)
|
||||
if not setup_params["uninitialized"]:
|
||||
session = _raw_client.get_management_session(new_session=True)
|
||||
session = _raw_client.get_seedless_session(new_session=True)
|
||||
debuglink.load_device(
|
||||
session,
|
||||
mnemonic=setup_params["mnemonic"], # type: ignore
|
||||
@ -420,7 +420,7 @@ def session(
|
||||
request: pytest.FixtureRequest, _client_unlocked: Client
|
||||
) -> t.Generator[SessionDebugWrapper, None, None]:
|
||||
if bool(request.node.get_closest_marker("uninitialized_session")):
|
||||
session = _client_unlocked.get_management_session()
|
||||
session = _client_unlocked.get_seedless_session()
|
||||
else:
|
||||
derive_cardano = bool(request.node.get_closest_marker("cardano"))
|
||||
passphrase = _client_unlocked.passphrase or ""
|
||||
|
@ -30,7 +30,7 @@ from ...translations import set_language
|
||||
@pytest.mark.models("core")
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_recovery(client: Client):
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
mnemonic = reset(session)
|
||||
session = client.get_session()
|
||||
address_before = btc.get_address(session, "Bitcoin", parse_path("m/44h/0h/0h/0/0"))
|
||||
@ -38,7 +38,7 @@ def test_reset_recovery(client: Client):
|
||||
lang = client.features.language or "en"
|
||||
device.wipe(session)
|
||||
client = client.get_new_client()
|
||||
session = Session(client.get_management_session())
|
||||
session = Session(client.get_seedless_session())
|
||||
set_language(session, lang[:2])
|
||||
recover(session, mnemonic)
|
||||
session = client.get_session()
|
||||
|
@ -33,7 +33,7 @@ from ...translations import set_language
|
||||
@pytest.mark.models("core")
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_recovery(client: Client):
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
mnemonics = reset(session)
|
||||
session = client.get_session()
|
||||
address_before = btc.get_address(session, "Bitcoin", parse_path("m/44h/0h/0h/0/0"))
|
||||
@ -53,11 +53,11 @@ def test_reset_recovery(client: Client):
|
||||
+ mnemonics[22:25],
|
||||
]
|
||||
for combination in test_combinations:
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
lang = client.features.language or "en"
|
||||
device.wipe(session)
|
||||
client = client.get_new_client()
|
||||
session = Session(client.get_management_session())
|
||||
session = Session(client.get_seedless_session())
|
||||
set_language(session, lang[:2])
|
||||
recover(session, combination)
|
||||
session = client.get_session()
|
||||
|
@ -36,17 +36,17 @@ from ...translations import set_language
|
||||
@pytest.mark.models("core")
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_recovery(client: Client):
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
mnemonics = reset(session)
|
||||
session = client.get_session()
|
||||
address_before = btc.get_address(session, "Bitcoin", parse_path("m/44h/0h/0h/0/0"))
|
||||
|
||||
for share_subset in itertools.combinations(mnemonics, 3):
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
lang = client.features.language or "en"
|
||||
device.wipe(session)
|
||||
client = client.get_new_client()
|
||||
session = Session(client.get_management_session())
|
||||
session = Session(client.get_seedless_session())
|
||||
set_language(session, lang[:2])
|
||||
selected_mnemonics = share_subset
|
||||
recover(session, selected_mnemonics)
|
||||
|
@ -37,7 +37,7 @@ def test_reset_device_slip39_advanced(client: Client):
|
||||
with client:
|
||||
IF = InputFlowSlip39AdvancedResetRecovery(client, False)
|
||||
client.set_input_flow(IF.get())
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
# No PIN, no passphrase, don't display random
|
||||
device.setup(
|
||||
session,
|
||||
|
@ -66,11 +66,11 @@ def test_device_id_same(client: Client):
|
||||
|
||||
|
||||
def test_device_id_different(client: Client):
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
id1 = client.features.device_id
|
||||
device.wipe(session)
|
||||
client = client.get_new_client()
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
|
||||
id2 = client.features.device_id
|
||||
|
||||
|
@ -213,7 +213,7 @@ def test_language_is_removed_after_wipe(client: Client):
|
||||
# Wipe device
|
||||
device.wipe(session)
|
||||
client = client.get_new_client()
|
||||
session = Session(client.get_management_session())
|
||||
session = Session(client.get_seedless_session())
|
||||
assert session.features.language == "en-US"
|
||||
|
||||
# Load it again
|
||||
|
@ -114,7 +114,7 @@ def test_load_device_utf(client: Client):
|
||||
passphrase_nfd = (
|
||||
"Neuve\u030cr\u030citelne\u030c bezpec\u030cne\u0301 hesli\u0301c\u030cko"
|
||||
)
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
debuglink.load_device(
|
||||
session,
|
||||
mnemonic=words_nfkd,
|
||||
@ -129,7 +129,7 @@ def test_load_device_utf(client: Client):
|
||||
|
||||
device.wipe(session)
|
||||
client = client.get_new_client()
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
debuglink.load_device(
|
||||
session,
|
||||
mnemonic=words_nfc,
|
||||
@ -144,7 +144,7 @@ def test_load_device_utf(client: Client):
|
||||
|
||||
device.wipe(session)
|
||||
client = client.get_new_client()
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
debuglink.load_device(
|
||||
session,
|
||||
mnemonic=words_nfkc,
|
||||
@ -159,7 +159,7 @@ def test_load_device_utf(client: Client):
|
||||
|
||||
device.wipe(session)
|
||||
client = client.get_new_client()
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
debuglink.load_device(
|
||||
session,
|
||||
mnemonic=words_nfd,
|
||||
|
@ -68,7 +68,7 @@ def test_refresh(session: Session):
|
||||
|
||||
|
||||
def test_wipe(client: Client):
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
# Enable SD protection
|
||||
device.sd_protect(session, Op.ENABLE)
|
||||
assert session.features.sd_protection is True
|
||||
@ -76,7 +76,7 @@ def test_wipe(client: Client):
|
||||
# Wipe device (this wipes internal storage)
|
||||
device.wipe(session)
|
||||
client = client.get_new_client()
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
assert session.features.sd_protection is False
|
||||
|
||||
# Restore device to working status
|
||||
|
@ -53,7 +53,7 @@ def test_autolock_not_retained(session: Session):
|
||||
|
||||
device.wipe(session)
|
||||
client = client.get_new_client()
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
|
||||
assert client.features.auto_lock_delay_ms > 10_000
|
||||
|
||||
|
@ -243,7 +243,7 @@ def test_wipe_device(session: Session):
|
||||
session.set_expected_responses([messages.ButtonRequest, messages.Success])
|
||||
device.wipe(session)
|
||||
client = session.client.get_new_client()
|
||||
session = Session(client.get_management_session())
|
||||
session = Session(client.get_seedless_session())
|
||||
with session, session.client as client:
|
||||
client.use_pin_sequence([PIN4])
|
||||
session.set_expected_responses([messages.Features])
|
||||
|
@ -412,7 +412,7 @@ def test_passphrase_length(client: Client):
|
||||
@pytest.mark.protocol("protocol_v1")
|
||||
def test_hide_passphrase_from_host(client: Client):
|
||||
# Without safety checks, turning it on fails
|
||||
session = client.get_management_session()
|
||||
session = client.get_seedless_session()
|
||||
with pytest.raises(TrezorFailure, match="Safety checks are strict"), client:
|
||||
device.apply_settings(session, hide_passphrase_from_host=True)
|
||||
|
||||
|
@ -20,9 +20,9 @@ from ..upgrade_tests import core_only
|
||||
def test_safety_checks_level_after_reboot(
|
||||
core_emulator: Emulator, set_level: SafetyCheckLevel, after_level: SafetyCheckLevel
|
||||
):
|
||||
device.wipe(core_emulator.client.get_management_session())
|
||||
device.wipe(core_emulator.client.get_seedless_session())
|
||||
debuglink.load_device(
|
||||
core_emulator.client.get_management_session(),
|
||||
core_emulator.client.get_seedless_session(),
|
||||
mnemonic=MNEMONIC12,
|
||||
pin="",
|
||||
passphrase_protection=False,
|
||||
|
@ -159,7 +159,7 @@ def test_recovery_on_old_wallet(core_emulator: Emulator):
|
||||
|
||||
# while keyboard is open, hit the device with Initialize/GetFeatures
|
||||
if device_handler.client.protocol_version == ProtocolVersion.PROTOCOL_V1:
|
||||
device_handler.client.get_management_session().call(messages.Initialize())
|
||||
device_handler.client.get_seedless_session().call(messages.Initialize())
|
||||
device_handler.client.refresh_features()
|
||||
|
||||
# try entering remaining 19 words
|
||||
|
@ -11,10 +11,10 @@ WIPE_CODE = "9876"
|
||||
|
||||
|
||||
def setup_device_legacy(client: Client, pin: str, wipe_code: str) -> None:
|
||||
device.wipe(client.get_management_session())
|
||||
device.wipe(client.get_seedless_session())
|
||||
client = client.get_new_client()
|
||||
debuglink.load_device(
|
||||
client.get_management_session(),
|
||||
client.get_seedless_session(),
|
||||
MNEMONIC12,
|
||||
pin,
|
||||
passphrase_protection=False,
|
||||
@ -23,14 +23,14 @@ def setup_device_legacy(client: Client, pin: str, wipe_code: str) -> None:
|
||||
|
||||
with client:
|
||||
client.use_pin_sequence([PIN, WIPE_CODE, WIPE_CODE])
|
||||
device.change_wipe_code(client.get_management_session())
|
||||
device.change_wipe_code(client.get_seedless_session())
|
||||
|
||||
|
||||
def setup_device_core(client: Client, pin: str, wipe_code: str) -> None:
|
||||
device.wipe(client.get_management_session())
|
||||
device.wipe(client.get_seedless_session())
|
||||
client = client.get_new_client()
|
||||
debuglink.load_device(
|
||||
client.get_management_session(),
|
||||
client.get_seedless_session(),
|
||||
MNEMONIC12,
|
||||
pin,
|
||||
passphrase_protection=False,
|
||||
@ -39,7 +39,7 @@ def setup_device_core(client: Client, pin: str, wipe_code: str) -> None:
|
||||
|
||||
with client:
|
||||
client.use_pin_sequence([pin, wipe_code, wipe_code])
|
||||
device.change_wipe_code(client.get_management_session())
|
||||
device.change_wipe_code(client.get_seedless_session())
|
||||
|
||||
|
||||
@core_only
|
||||
|
@ -71,7 +71,7 @@ def screen_recording(
|
||||
client.debug.set_screen_text_file(None)
|
||||
client.debug.watch_layout(False)
|
||||
# Instead of client.init_device() we create a new management session
|
||||
client.get_management_session()
|
||||
client.get_seedless_session()
|
||||
client.debug.stop_recording()
|
||||
|
||||
result = testcase.build_result(request)
|
||||
|
@ -71,7 +71,7 @@ def test_upgrade_load(gen: str, tag: str) -> None:
|
||||
|
||||
with EmulatorWrapper(gen, tag) as emu:
|
||||
debuglink.load_device_by_mnemonic(
|
||||
emu.client.get_management_session(),
|
||||
emu.client.get_seedless_session(),
|
||||
mnemonic=MNEMONIC,
|
||||
pin="",
|
||||
passphrase_protection=False,
|
||||
@ -102,7 +102,7 @@ def test_upgrade_load_pin(gen: str, tag: str) -> None:
|
||||
|
||||
with EmulatorWrapper(gen, tag) as emu:
|
||||
debuglink.load_device_by_mnemonic(
|
||||
Session(emu.client.get_management_session()),
|
||||
Session(emu.client.get_seedless_session()),
|
||||
mnemonic=MNEMONIC,
|
||||
pin=PIN,
|
||||
passphrase_protection=False,
|
||||
@ -142,7 +142,7 @@ def test_storage_upgrade_progressive(gen: str, tags: List[str]):
|
||||
|
||||
with EmulatorWrapper(gen, tags[0]) as emu:
|
||||
debuglink.load_device_by_mnemonic(
|
||||
emu.client.get_management_session(),
|
||||
emu.client.get_seedless_session(),
|
||||
mnemonic=MNEMONIC,
|
||||
pin=PIN,
|
||||
passphrase_protection=False,
|
||||
@ -176,7 +176,7 @@ def test_upgrade_wipe_code(gen: str, tag: str):
|
||||
|
||||
with EmulatorWrapper(gen, tag) as emu:
|
||||
debuglink.load_device_by_mnemonic(
|
||||
emu.client.get_management_session(),
|
||||
emu.client.get_seedless_session(),
|
||||
mnemonic=MNEMONIC,
|
||||
pin=PIN,
|
||||
passphrase_protection=False,
|
||||
@ -185,7 +185,7 @@ def test_upgrade_wipe_code(gen: str, tag: str):
|
||||
|
||||
# Set wipe code.
|
||||
emu.client.use_pin_sequence([PIN, WIPE_CODE, WIPE_CODE])
|
||||
session = Session(emu.client.get_management_session())
|
||||
session = Session(emu.client.get_seedless_session())
|
||||
session.refresh_features()
|
||||
device.change_wipe_code(session)
|
||||
|
||||
@ -199,7 +199,7 @@ def test_upgrade_wipe_code(gen: str, tag: str):
|
||||
|
||||
# Check that wipe code is set by changing the PIN to it.
|
||||
emu.client.use_pin_sequence([PIN, WIPE_CODE, WIPE_CODE])
|
||||
session = Session(emu.client.get_management_session())
|
||||
session = Session(emu.client.get_seedless_session())
|
||||
session.refresh_features()
|
||||
with pytest.raises(
|
||||
exceptions.TrezorFailure,
|
||||
@ -362,7 +362,7 @@ def test_upgrade_shamir_recovery(gen: str, tag: Optional[str]):
|
||||
@for_all("core", core_minimum_version=(2, 1, 9))
|
||||
def test_upgrade_shamir_backup(gen: str, tag: Optional[str]):
|
||||
with EmulatorWrapper(gen, tag) as emu:
|
||||
session = Session(emu.client.get_management_session())
|
||||
session = Session(emu.client.get_seedless_session())
|
||||
# Generate a new encrypted master secret and record it.
|
||||
device.setup(
|
||||
session,
|
||||
@ -433,13 +433,13 @@ def test_upgrade_u2f(gen: str, tag: str):
|
||||
"""Check U2F counter stayed the same after an upgrade."""
|
||||
with EmulatorWrapper(gen, tag) as emu:
|
||||
debuglink.load_device_by_mnemonic(
|
||||
emu.client.get_management_session(),
|
||||
emu.client.get_seedless_session(),
|
||||
mnemonic=MNEMONIC,
|
||||
pin="",
|
||||
passphrase_protection=False,
|
||||
label=LABEL,
|
||||
)
|
||||
session = emu.client.get_management_session()
|
||||
session = emu.client.get_seedless_session()
|
||||
fido.set_counter(session, 10)
|
||||
|
||||
counter = fido.get_next_counter(session)
|
||||
|
@ -49,14 +49,14 @@ def emulator(gen: str, tag: str) -> Iterator[Emulator]:
|
||||
with EmulatorWrapper(gen, tag) as emu:
|
||||
# set up a passphrase-protected device
|
||||
device.setup(
|
||||
emu.client.get_management_session(),
|
||||
emu.client.get_seedless_session(),
|
||||
pin_protection=False,
|
||||
skip_backup=True,
|
||||
entropy_check_count=0,
|
||||
backup_type=messages.BackupType.Bip39,
|
||||
)
|
||||
emu.client.invalidate()
|
||||
resp = emu.client.get_management_session().call(
|
||||
resp = emu.client.get_seedless_session().call(
|
||||
ApplySettingsCompat(use_passphrase=True, passphrase_source=SOURCE_HOST)
|
||||
)
|
||||
assert isinstance(resp, messages.Success)
|
||||
|
Loading…
Reference in New Issue
Block a user