core: do not clear cache on ClearSession

pull/803/head
Tomas Susanka 4 years ago committed by Pavol Rusnak
parent da4743c234
commit 15ed5cd19e
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -92,8 +92,12 @@ async def handle_Cancel(ctx: wire.Context, msg: Cancel) -> NoReturn:
async def handle_ClearSession(ctx: wire.Context, msg: ClearSession) -> Success:
cache.clear()
return Success(message="Session cleared")
"""
This is currently a no-op on T. This should be called LockSession/LockDevice
and lock the device. In other words the cache should stay but the PIN should
be forgotten and required again.
"""
return Success()
async def handle_Ping(ctx: wire.Context, msg: Ping) -> Success:

@ -76,24 +76,6 @@ class TestStorageCache(unittest.TestCase):
call_Initialize(session_id=new_session_id)
self.assertIsNone(cache.get(KEY))
@mock_storage
def test_ClearSession(self):
def call_Initialize(**kwargs):
msg = Initialize(**kwargs)
return await_result(handle_Initialize(DUMMY_CONTEXT, msg))
def call_ClearSession():
return await_result(handle_ClearSession(DUMMY_CONTEXT, ClearSession()))
session_id = call_Initialize().session_id
cache.set(KEY, "hello")
self.assertEqual(cache.get(KEY), "hello")
call_ClearSession()
self.assertIsNone(cache.get(KEY))
new_session_id = cache.get_session_id()
self.assertNotEqual(session_id, new_session_id)
if __name__ == "__main__":
unittest.main()

@ -98,23 +98,6 @@ def test_session_enable_passphrase(client):
assert _get_xpub(client, passphrase="A") == XPUB_PASSPHRASE_A
@pytest.mark.skip_ui
def test_clear_session(client):
session_id = _init_session(client)
# session id remains the same
new_session_id = _init_session(client, session_id=session_id)
assert session_id == new_session_id
# by clearing the session, the id is lost
response = client.call(messages.ClearSession())
assert isinstance(response, messages.Success)
# cannot resume the old session now
new_session_id = _init_session(client, session_id=session_id)
assert session_id != new_session_id
@pytest.mark.skip_ui
@pytest.mark.setup_client(passphrase=True)
def test_clear_session_passphrase(client):
@ -124,9 +107,9 @@ def test_clear_session_passphrase(client):
# now the passphrase is cached
assert _get_xpub(client, passphrase=None) == XPUB_PASSPHRASE_A
# ClearSession will erase the cached passphrase
response = client.call(messages.ClearSession())
assert isinstance(response, messages.Success)
# Erase the cached passphrase
response = client.call(messages.Initialize())
assert isinstance(response, messages.Features)
# we have to enter passphrase again
assert _get_xpub(client, passphrase="A") == XPUB_PASSPHRASE_A

Loading…
Cancel
Save