mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-09 18:38:47 +00:00
tests: more assertions on sd_protect
This commit is contained in:
parent
d9efd92c0a
commit
ccd1940ea8
@ -93,6 +93,7 @@ def change_pin(client, remove=False):
|
|||||||
@expect(proto.Success, field="message")
|
@expect(proto.Success, field="message")
|
||||||
def sd_protect(client, operation):
|
def sd_protect(client, operation):
|
||||||
ret = client.call(proto.SdProtect(operation=operation))
|
ret = client.call(proto.SdProtect(operation=operation))
|
||||||
|
client.init_device()
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,29 +23,41 @@ from trezorlib.messages import SdProtectOperationType as Op
|
|||||||
pytestmark = [pytest.mark.skip_t1, pytest.mark.sd_card]
|
pytestmark = [pytest.mark.skip_t1, pytest.mark.sd_card]
|
||||||
|
|
||||||
|
|
||||||
def test_sd_protect_enable(client):
|
def test_enable_disable(client):
|
||||||
|
assert client.features.sd_protection is False
|
||||||
# Disabling SD protection should fail
|
# Disabling SD protection should fail
|
||||||
with pytest.raises(TrezorFailure):
|
with pytest.raises(TrezorFailure):
|
||||||
device.sd_protect(client, Op.DISABLE)
|
device.sd_protect(client, Op.DISABLE)
|
||||||
|
|
||||||
# Enable SD protection
|
# Enable SD protection
|
||||||
device.sd_protect(client, Op.ENABLE)
|
device.sd_protect(client, Op.ENABLE)
|
||||||
|
assert client.features.sd_protection is True
|
||||||
|
|
||||||
# Enabling SD protection should fail
|
# Enabling SD protection should fail
|
||||||
with pytest.raises(TrezorFailure):
|
with pytest.raises(TrezorFailure):
|
||||||
device.sd_protect(client, Op.ENABLE)
|
device.sd_protect(client, Op.ENABLE)
|
||||||
|
assert client.features.sd_protection is True
|
||||||
|
|
||||||
def test_sd_protect_refresh(client):
|
|
||||||
# Enable SD protection
|
|
||||||
device.sd_protect(client, Op.ENABLE)
|
|
||||||
|
|
||||||
# Refresh SD protection
|
|
||||||
device.sd_protect(client, Op.REFRESH)
|
|
||||||
|
|
||||||
# Disable SD protection
|
# Disable SD protection
|
||||||
device.sd_protect(client, Op.DISABLE)
|
device.sd_protect(client, Op.DISABLE)
|
||||||
|
assert client.features.sd_protection is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_refresh(client):
|
||||||
|
assert client.features.sd_protection is False
|
||||||
|
# Enable SD protection
|
||||||
|
device.sd_protect(client, Op.ENABLE)
|
||||||
|
assert client.features.sd_protection is True
|
||||||
|
|
||||||
|
# Refresh SD protection
|
||||||
|
device.sd_protect(client, Op.REFRESH)
|
||||||
|
assert client.features.sd_protection is True
|
||||||
|
|
||||||
|
# Disable SD protection
|
||||||
|
device.sd_protect(client, Op.DISABLE)
|
||||||
|
assert client.features.sd_protection is False
|
||||||
|
|
||||||
# Refreshing SD protection should fail
|
# Refreshing SD protection should fail
|
||||||
with pytest.raises(TrezorFailure):
|
with pytest.raises(TrezorFailure):
|
||||||
device.sd_protect(client, Op.REFRESH)
|
device.sd_protect(client, Op.REFRESH)
|
||||||
|
assert client.features.sd_protection is False
|
||||||
|
Loading…
Reference in New Issue
Block a user