mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 23:08:14 +00:00
python/tests: Add SD protection device test.
This commit is contained in:
parent
6350b1c61c
commit
262434ea1b
@ -1,4 +1,4 @@
|
||||
from trezor import config, log, loop, res, ui
|
||||
from trezor import config, io, log, loop, res, ui, utils
|
||||
from trezor.pin import pin_to_int, show_pin_timeout
|
||||
|
||||
from apps.common import storage
|
||||
@ -72,6 +72,19 @@ async def lockscreen() -> None:
|
||||
await ui.click()
|
||||
|
||||
|
||||
if utils.EMULATOR:
|
||||
# Ensure the emulated SD card is FAT32 formatted.
|
||||
sd = io.SDCard()
|
||||
fs = io.FatFS()
|
||||
sd.power(True)
|
||||
try:
|
||||
fs.mount()
|
||||
except OSError:
|
||||
fs.mkfs()
|
||||
else:
|
||||
fs.unmount()
|
||||
sd.power(False)
|
||||
|
||||
ui.display.backlight(ui.BACKLIGHT_NONE)
|
||||
ui.backlight_fade(ui.BACKLIGHT_NORMAL)
|
||||
config.init(show_pin_timeout)
|
||||
|
62
tests/device_tests/test_msg_sd_protect.py
Normal file
62
tests/device_tests/test_msg_sd_protect.py
Normal file
@ -0,0 +1,62 @@
|
||||
# This file is part of the Trezor project.
|
||||
#
|
||||
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
||||
#
|
||||
# This library is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import debuglink, device, messages as proto
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
|
||||
from ..common import MNEMONIC12
|
||||
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
class TestMsgSdProtect:
|
||||
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
|
||||
def test_sd_protect(self, client):
|
||||
|
||||
# Disabling SD protection should fail
|
||||
with pytest.raises(TrezorFailure):
|
||||
device.sd_protect(client, proto.SdProtectOperationType.DISABLE)
|
||||
|
||||
# Enable SD protection
|
||||
device.sd_protect(client, proto.SdProtectOperationType.ENABLE)
|
||||
|
||||
# Enabling SD protection should fail
|
||||
with pytest.raises(TrezorFailure):
|
||||
device.sd_protect(client, proto.SdProtectOperationType.ENABLE)
|
||||
|
||||
# Wipe
|
||||
device.wipe(client)
|
||||
debuglink.load_device_by_mnemonic(
|
||||
client,
|
||||
mnemonic=MNEMONIC12,
|
||||
pin="",
|
||||
passphrase_protection=False,
|
||||
label="test",
|
||||
)
|
||||
|
||||
# Enable SD protection
|
||||
device.sd_protect(client, proto.SdProtectOperationType.ENABLE)
|
||||
|
||||
# Refresh SD protection
|
||||
device.sd_protect(client, proto.SdProtectOperationType.REFRESH)
|
||||
|
||||
# Disable SD protection
|
||||
device.sd_protect(client, proto.SdProtectOperationType.DISABLE)
|
||||
|
||||
# Refreshing SD protection should fail
|
||||
with pytest.raises(TrezorFailure):
|
||||
device.sd_protect(client, proto.SdProtectOperationType.REFRESH)
|
Loading…
Reference in New Issue
Block a user