|
|
@ -18,7 +18,7 @@ import pytest
|
|
|
|
|
|
|
|
|
|
|
|
from trezorlib import btc, device, messages
|
|
|
|
from trezorlib import btc, device, messages
|
|
|
|
from trezorlib.client import MAX_PIN_LENGTH, PASSPHRASE_TEST_PATH
|
|
|
|
from trezorlib.client import MAX_PIN_LENGTH, PASSPHRASE_TEST_PATH
|
|
|
|
from trezorlib.exceptions import Cancelled
|
|
|
|
from trezorlib.exceptions import Cancelled, TrezorFailure
|
|
|
|
|
|
|
|
|
|
|
|
PIN4 = "1234"
|
|
|
|
PIN4 = "1234"
|
|
|
|
PIN60 = "789456" * 10
|
|
|
|
PIN60 = "789456" * 10
|
|
|
@ -172,3 +172,31 @@ def test_change_failed(client):
|
|
|
|
client.init_device()
|
|
|
|
client.init_device()
|
|
|
|
assert client.features.pin_protection is True
|
|
|
|
assert client.features.pin_protection is True
|
|
|
|
_check_pin(client, PIN4)
|
|
|
|
_check_pin(client, PIN4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.setup_client(pin=PIN4)
|
|
|
|
|
|
|
|
def test_change_invalid_current(client):
|
|
|
|
|
|
|
|
assert client.features.pin_protection is True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check current PIN value
|
|
|
|
|
|
|
|
_check_pin(client, PIN4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Let's set new PIN
|
|
|
|
|
|
|
|
def input_flow():
|
|
|
|
|
|
|
|
yield # do you want to change pin?
|
|
|
|
|
|
|
|
client.debug.press_yes()
|
|
|
|
|
|
|
|
yield # enter wrong current pin
|
|
|
|
|
|
|
|
client.debug.input(PIN60)
|
|
|
|
|
|
|
|
yield
|
|
|
|
|
|
|
|
client.debug.press_no()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with client, pytest.raises(TrezorFailure):
|
|
|
|
|
|
|
|
client.set_expected_responses([messages.ButtonRequest] * 3 + [messages.Failure])
|
|
|
|
|
|
|
|
client.set_input_flow(input_flow)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
device.change_pin(client)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check that there's still old PIN protection
|
|
|
|
|
|
|
|
client.init_device()
|
|
|
|
|
|
|
|
assert client.features.pin_protection is True
|
|
|
|
|
|
|
|
_check_pin(client, PIN4)
|
|
|
|