nits
This commit is contained in:
parent
00b2f67d55
commit
0420d4b6eb
@ -1083,15 +1083,12 @@ disable this feature.
|
||||
# just a tourist
|
||||
return
|
||||
|
||||
|
||||
# re-use existing PIN if there for some reason
|
||||
new_pin = tp.has_sp_unlock()
|
||||
|
||||
if not new_pin:
|
||||
# all existing PINS
|
||||
have = set(tp.all_tricks())
|
||||
have.add(pa.pin.decode())
|
||||
|
||||
have = tp.all_tricks()
|
||||
main_pin = pa.pin.decode()
|
||||
while 1:
|
||||
lll = LoginUX()
|
||||
lll.is_setting = True
|
||||
@ -1101,14 +1098,17 @@ disable this feature.
|
||||
if new_pin is None:
|
||||
return
|
||||
|
||||
if (new_pin not in have):
|
||||
tp.define_unlock_pin(new_pin)
|
||||
break
|
||||
# weak check - does not spot hidden trick pins
|
||||
if (new_pin != main_pin) and (new_pin not in have):
|
||||
# verify uniqueness with SE2
|
||||
b, slot = tp.get_by_pin(new_pin)
|
||||
if slot is None:
|
||||
tp.define_unlock_pin(new_pin)
|
||||
break
|
||||
|
||||
await ux_show_story("That PIN (%s) is already in use. All PIN codes must be unique."
|
||||
% new_pin)
|
||||
await tp.err_unique_pin(new_pin)
|
||||
|
||||
# all features disabled to to start
|
||||
# all features disabled to start
|
||||
settings.set('sssp', dict(en=False, pol={}))
|
||||
settings.save()
|
||||
|
||||
|
||||
@ -407,6 +407,12 @@ class TrickPinMgmt:
|
||||
b, slot = tp.update_slot(pin.encode(), new=True,
|
||||
tc_flags=flags, tc_arg=arg, secret=new_secret)
|
||||
except: pass
|
||||
|
||||
@staticmethod
|
||||
async def err_unique_pin(pin):
|
||||
# standardized error UX
|
||||
return await ux_show_story(
|
||||
"That PIN (%s) is already in use. All PIN codes must be unique." % pin)
|
||||
|
||||
|
||||
tp = TrickPinMgmt()
|
||||
@ -552,8 +558,7 @@ class TrickPinMenu(MenuSystem):
|
||||
have.remove(existing_pin)
|
||||
|
||||
if (new_pin == self.current_pin) or (new_pin in have):
|
||||
await ux_show_story("That PIN (%s) is already in use. All PIN codes must be unique." % new_pin)
|
||||
return
|
||||
return await tp.err_unique_pin(new_pin)
|
||||
|
||||
# check if we "forgot" this pin, and read it back if we did.
|
||||
# - important this is after the above checks so we don't reveal any trick pin used
|
||||
|
||||
@ -301,8 +301,10 @@ def new_trick_pin(goto_trick_menu, pick_menu_item, cap_menu, press_select,
|
||||
time.sleep(.1)
|
||||
m = cap_menu()
|
||||
assert m[0] == f'[{new_pin}]'
|
||||
assert set(m[1:]) == {'Duress Wallet', 'Just Reboot', 'Wipe Seed', \
|
||||
'Delta Mode', 'Look Blank', 'Brick Self', 'Login Countdown'}
|
||||
assert set(m[1:]) == {'Duress Wallet', 'Just Reboot', 'Wipe Seed', 'Delta Mode',
|
||||
'Look Blank', 'Policy Unlock',
|
||||
'Policy Unlock & Wipe' if is_q1 else 'P.U. & Wipe',
|
||||
'Brick Self', 'Login Countdown'}
|
||||
|
||||
pick_menu_item(op_mode)
|
||||
|
||||
|
||||
@ -524,11 +524,15 @@ def test_remove_sssp(setup_sssp, pick_menu_item, press_select, cap_story, cap_me
|
||||
assert "spending policy settings forgotten" in story
|
||||
press_select()
|
||||
|
||||
time.sleep(.1)
|
||||
assert not settings_get("sssp")
|
||||
|
||||
tps = settings_get("tp")
|
||||
if tps:
|
||||
assert "11-11" not in tps
|
||||
|
||||
assert not settings_get("sssp")
|
||||
|
||||
|
||||
def test_use_main_pin_as_unlock(setup_sssp, cap_story):
|
||||
# not allowed
|
||||
@ -540,4 +544,26 @@ def test_use_main_pin_as_unlock(setup_sssp, cap_story):
|
||||
assert "already in use" in story
|
||||
assert "PIN codes must be unique" in story
|
||||
|
||||
|
||||
@pytest.mark.parametrize("hide", [True, False])
|
||||
def test_use_trick_pin_as_unlock(hide, setup_sssp, cap_story, new_trick_pin, pick_menu_item,
|
||||
press_select, clear_all_tricks):
|
||||
clear_all_tricks()
|
||||
pin = "11-11"
|
||||
new_trick_pin(pin, 'Wipe Seed', 'Wipe the seed and maybe do more')
|
||||
pick_menu_item('Wipe & Reboot')
|
||||
press_select()
|
||||
press_select()
|
||||
if hide:
|
||||
pick_menu_item(f"↳{pin}")
|
||||
pick_menu_item("Hide Trick")
|
||||
press_select() # confirm
|
||||
|
||||
with pytest.raises(Exception):
|
||||
setup_sssp(pin)
|
||||
|
||||
_, story = cap_story()
|
||||
assert "already in use" in story
|
||||
assert "PIN codes must be unique" in story
|
||||
|
||||
# EOF
|
||||
|
||||
Loading…
Reference in New Issue
Block a user