diff --git a/core/tests/test_apps.common.keychain.py b/core/tests/test_apps.common.keychain.py index 8d7d267f063..dce92a155a1 100644 --- a/core/tests/test_apps.common.keychain.py +++ b/core/tests/test_apps.common.keychain.py @@ -1,6 +1,9 @@ from common import * +from mock_storage import mock_storage + from storage import cache +import storage.device from apps.common import HARDENED from apps.common.paths import path_is_hardened from apps.common.keychain import LRUCache, Keychain, with_slip44_keychain, get_keychain @@ -9,13 +12,13 @@ class TestKeychain(unittest.TestCase): + @mock_storage def test_verify_path(self): n = [ [44 | HARDENED, 134 | HARDENED], [44 | HARDENED, 11 | HARDENED], ] keychain = Keychain(b"", "secp256k1", n) - unrestricted_keychain = Keychain(b"", "secp256k1", n, restrict=False) correct = ( [44 | HARDENED, 134 | HARDENED], @@ -24,18 +27,20 @@ def test_verify_path(self): ) for path in correct: keychain.verify_path(path) - unrestricted_keychain.verify_path(path) - fails = [ + fails = ( [44 | HARDENED, 134], # path does not match [44, 134], # path does not match (non-hardened items) [44 | HARDENED, 13 | HARDENED], # invalid second item - ] + ) for f in fails: with self.assertRaises(wire.DataError): keychain.verify_path(f) - # unrestricted keychain allows all paths - unrestricted_keychain.verify_path(f) + + # turn off restrictions + storage.device.set_unsafe_prompts_allowed(True) + for path in correct + fails: + keychain.verify_path(path) def test_verify_path_special_ed25519(self): n = [[44 | HARDENED, 134 | HARDENED]]