Skip to content

Commit

Permalink
test: correct issue in test_verify_address and generate golden snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
keiff3r committed Nov 26, 2024
1 parent eb79346 commit e569e4b
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 8 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/flex/test_verify_address_confirm_refused/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/stax/test_verify_address_confirm_refused/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 49 additions & 8 deletions tests/test_verify_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,75 @@
from application_client.boilerplate_response_unpacker import unpack_get_public_key_response
from ragger.bip import calculate_public_key_and_chaincode, CurveChoice
from ragger.error import ExceptionRAPDU
from ragger.navigator import NavInsID, NavIns
from ragger.navigator import NavInsID, NavIns, NavigateWithScenario


nbgl_instructions_address_confirmation = [NavInsID.SWIPE_CENTER_TO_LEFT,NavInsID.SWIPE_CENTER_TO_LEFT,
NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CONFIRM]
nbgl_instructions_address_confirmation_reject = [NavInsID.SWIPE_CENTER_TO_LEFT,NavInsID.SWIPE_CENTER_TO_LEFT,
NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CANCEL, NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CONFIRM]
bagl_instructions_address_confirmation = [NavInsID.RIGHT_CLICK,NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,NavInsID.BOTH_CLICK]

bagl_instructions_address_confirmation_reject = [NavInsID.RIGHT_CLICK,NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,NavInsID.RIGHT_CLICK,NavInsID.BOTH_CLICK]

# In this test we check that the VERIFY ADDRESS works in confirmation mode
def test_verify_address_confirm_legacy_path_accepted(backend, scenario_navigator):
def test_verify_address_confirm_legacy_path_accepted(backend, scenario_navigator: NavigateWithScenario, test_name: str, default_screenshot_path: str):
client = BoilerplateCommandSender(backend)
with client.verify_address(identity_index=0, credential_counter=0):
scenario_navigator.review_approve()
instructions = []
if backend.firmware.device.startswith(("stax", "flex")):
instructions.extend(nbgl_instructions_address_confirmation)
else:
instructions.extend(bagl_instructions_address_confirmation)

scenario_navigator.navigator.navigate_and_compare(
default_screenshot_path,
test_name,
instructions,
)

response = client.get_async_response().status
assert(response == 0x9000)

# In this test we check that the VERIFY ADDRESS works in confirmation mode
def test_verify_address_confirm_new_path_accepted(backend, scenario_navigator):
def test_verify_address_confirm_new_path_accepted(backend, scenario_navigator, test_name, default_screenshot_path):
client = BoilerplateCommandSender(backend)
with client.verify_address(identity_index=0, credential_counter=0, idp_index=0):
scenario_navigator.review_approve()
instructions = []
if backend.firmware.device.startswith(("stax", "flex")):
instructions.extend(nbgl_instructions_address_confirmation)
else:
instructions.extend(bagl_instructions_address_confirmation)

scenario_navigator.navigator.navigate_and_compare(
default_screenshot_path,
test_name,
instructions
)


response = client.get_async_response().status
assert(response == 0x9000)


# In this test we check that the VERIFY ADDRESS in confirmation mode replies an error if the user refuses
def test_verify_address_confirm_refused(backend, scenario_navigator):
def test_verify_address_confirm_refused(backend, scenario_navigator, test_name, default_screenshot_path):
client = BoilerplateCommandSender(backend)
try:
with client.verify_address(identity_index=0, credential_counter=0):
scenario_navigator.review_reject()
with client.verify_address(identity_index=0, credential_counter=0, idp_index=0):
instructions = []
if backend.firmware.device.startswith(("stax", "flex")):
instructions.extend(nbgl_instructions_address_confirmation_reject)
else:
instructions.extend(bagl_instructions_address_confirmation_reject)

scenario_navigator.navigator.navigate_and_compare(
default_screenshot_path,
test_name,
instructions,
)
except ExceptionRAPDU as e:
response = e.status

Expand Down

0 comments on commit e569e4b

Please sign in to comment.