You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.1 KiB
97 lines
3.1 KiB
6 years ago
|
# This file is part of the Trezor project.
|
||
8 years ago
|
#
|
||
6 years ago
|
# Copyright (C) 2012-2018 SatoshiLabs and contributors
|
||
8 years ago
|
#
|
||
|
# This library is free software: you can redistribute it and/or modify
|
||
6 years ago
|
# it under the terms of the GNU Lesser General Public License version 3
|
||
|
# as published by the Free Software Foundation.
|
||
8 years ago
|
#
|
||
|
# 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.
|
||
|
#
|
||
6 years ago
|
# 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>.
|
||
|
|
||
6 years ago
|
import pytest
|
||
8 years ago
|
|
||
7 years ago
|
from trezorlib import messages as proto
|
||
10 years ago
|
|
||
6 years ago
|
from .common import TrezorTest
|
||
|
|
||
7 years ago
|
|
||
7 years ago
|
@pytest.mark.skip_t2
|
||
7 years ago
|
class TestMsgClearsession(TrezorTest):
|
||
10 years ago
|
def test_clearsession(self):
|
||
|
self.setup_mnemonic_pin_passphrase()
|
||
|
|
||
|
with self.client:
|
||
6 years ago
|
self.client.set_expected_responses(
|
||
|
[
|
||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall),
|
||
|
proto.PinMatrixRequest(),
|
||
|
proto.PassphraseRequest(),
|
||
|
proto.Success(),
|
||
|
]
|
||
|
)
|
||
|
res = self.client.ping(
|
||
|
"random data",
|
||
|
button_protection=True,
|
||
|
pin_protection=True,
|
||
|
passphrase_protection=True,
|
||
|
)
|
||
|
assert res == "random data"
|
||
10 years ago
|
|
||
|
with self.client:
|
||
|
# pin and passphrase are cached
|
||
6 years ago
|
self.client.set_expected_responses(
|
||
|
[
|
||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall),
|
||
|
proto.Success(),
|
||
|
]
|
||
|
)
|
||
|
res = self.client.ping(
|
||
|
"random data",
|
||
|
button_protection=True,
|
||
|
pin_protection=True,
|
||
|
passphrase_protection=True,
|
||
|
)
|
||
|
assert res == "random data"
|
||
10 years ago
|
|
||
|
self.client.clear_session()
|
||
|
|
||
|
# session cache is cleared
|
||
|
with self.client:
|
||
6 years ago
|
self.client.set_expected_responses(
|
||
|
[
|
||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall),
|
||
|
proto.PinMatrixRequest(),
|
||
|
proto.PassphraseRequest(),
|
||
|
proto.Success(),
|
||
|
]
|
||
|
)
|
||
|
res = self.client.ping(
|
||
|
"random data",
|
||
|
button_protection=True,
|
||
|
pin_protection=True,
|
||
|
passphrase_protection=True,
|
||
|
)
|
||
|
assert res == "random data"
|
||
10 years ago
|
|
||
|
with self.client:
|
||
|
# pin and passphrase are cached
|
||
6 years ago
|
self.client.set_expected_responses(
|
||
|
[
|
||
|
proto.ButtonRequest(code=proto.ButtonRequestType.ProtectCall),
|
||
|
proto.Success(),
|
||
|
]
|
||
|
)
|
||
|
res = self.client.ping(
|
||
|
"random data",
|
||
|
button_protection=True,
|
||
|
pin_protection=True,
|
||
|
passphrase_protection=True,
|
||
|
)
|
||
|
assert res == "random data"
|