1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-15 19:08:07 +00:00
trezor-firmware/tests/test_protect_call.py

35 lines
1.2 KiB
Python
Raw Normal View History

2013-01-14 13:44:11 +00:00
import unittest
import common
2013-09-01 01:35:31 +00:00
from bitkeylib.client import CallException, PinException
from bitkeylib import proto
2013-01-14 13:44:11 +00:00
class TestProtectCall(common.BitkeyTest):
2013-01-14 16:05:38 +00:00
def _some_protected_call(self):
# This method perform any call which have protection in the device
entropy_len = 10
entropy = self.bitkey.get_entropy(entropy_len)
self.assertEqual(len(entropy), entropy_len)
2013-01-14 13:44:11 +00:00
2013-01-14 16:05:38 +00:00
def test_no_protection(self):
2013-09-01 01:35:31 +00:00
self.bitkey.load_device(
seed='beyond neighbor scratch swirl embarrass doll cause also stick softly physical nice',
2013-09-01 01:35:31 +00:00
pin='')
2013-01-14 13:44:11 +00:00
2013-09-01 01:35:31 +00:00
self.assertEqual(self.bitkey.debuglink.read_pin()[0], '')
2013-01-14 16:05:38 +00:00
self._some_protected_call()
2013-09-01 01:35:31 +00:00
def test_pin(self):
self.bitkey.load_device(
seed='beyond neighbor scratch swirl embarrass doll cause also stick softly physical nice',
2013-09-01 01:35:31 +00:00
pin='2345')
2013-01-14 16:05:38 +00:00
2013-09-01 01:35:31 +00:00
self.assertEqual(self.bitkey.debuglink.read_pin()[0], '2345')
2013-01-14 16:05:38 +00:00
self._some_protected_call()
2013-01-14 13:44:11 +00:00
2013-01-14 16:05:38 +00:00
def test_incorrect_pin(self):
2013-09-01 01:35:31 +00:00
self.bitkey.setup_debuglink(button=True, pin_correct=False)
2013-01-14 16:05:38 +00:00
self.assertRaises(PinException, self._some_protected_call)
2013-01-14 13:44:11 +00:00
if __name__ == '__main__':
unittest.main()