1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

tests: more assertions on sd_protect

This commit is contained in:
matejcik 2019-10-21 12:01:44 +02:00
parent d9efd92c0a
commit ccd1940ea8
2 changed files with 22 additions and 9 deletions

View File

@ -93,6 +93,7 @@ def change_pin(client, remove=False):
@expect(proto.Success, field="message")
def sd_protect(client, operation):
ret = client.call(proto.SdProtect(operation=operation))
client.init_device()
return ret

View File

@ -23,29 +23,41 @@ from trezorlib.messages import SdProtectOperationType as Op
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
with pytest.raises(TrezorFailure):
device.sd_protect(client, Op.DISABLE)
# Enable SD protection
device.sd_protect(client, Op.ENABLE)
assert client.features.sd_protection is True
# Enabling SD protection should fail
with pytest.raises(TrezorFailure):
device.sd_protect(client, Op.ENABLE)
def test_sd_protect_refresh(client):
# Enable SD protection
device.sd_protect(client, Op.ENABLE)
# 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
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
with pytest.raises(TrezorFailure):
device.sd_protect(client, Op.REFRESH)
assert client.features.sd_protection is False