From ccd1940ea897b476179e5828efeb12d11a049db9 Mon Sep 17 00:00:00 2001 From: matejcik Date: Mon, 21 Oct 2019 12:01:44 +0200 Subject: [PATCH] tests: more assertions on sd_protect --- python/src/trezorlib/device.py | 1 + tests/device_tests/test_msg_sd_protect.py | 30 ++++++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/python/src/trezorlib/device.py b/python/src/trezorlib/device.py index 357dfdfd24..ac7d650d7c 100644 --- a/python/src/trezorlib/device.py +++ b/python/src/trezorlib/device.py @@ -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 diff --git a/tests/device_tests/test_msg_sd_protect.py b/tests/device_tests/test_msg_sd_protect.py index e55d4a7ff9..7d88247b4b 100644 --- a/tests/device_tests/test_msg_sd_protect.py +++ b/tests/device_tests/test_msg_sd_protect.py @@ -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