test and validate signup with dispersable keypad and login with non-dispersable keypad

This commit is contained in:
2024-07-24 14:17:56 -05:00
parent 50dc917a90
commit 772c93c8a8
11 changed files with 227 additions and 142 deletions

View File

@@ -8,17 +8,17 @@ def nkode_api() -> NKodeAPI:
return NKodeAPI()
@pytest.mark.parametrize("keypad_size,user_passcode", [
(KeypadSize(numb_of_keys=10, attrs_per_key=7), [3, 10, 27, 68]),
(KeypadSize(numb_of_keys=10, attrs_per_key=7), [3, 10, 27, 68, 32]),
@pytest.mark.parametrize("keypad_size,passocode_len", [
(KeypadSize(numb_of_keys=10, attrs_per_key=11), 4),
(KeypadSize(numb_of_keys=10, attrs_per_key=12), 5),
])
def test_create_new_user_and_renew_keys(nkode_api, keypad_size, user_passcode):
def test_create_new_user_and_renew_keys(nkode_api, keypad_size, passocode_len):
username = "test_username"
nkode_policy = NKodePolicy() # default policy
customer_id = nkode_api.create_new_customer(keypad_size, nkode_policy)
session_id, set_interface = nkode_api.generate_index_interface(customer_id)
key_selection = lambda interface: [interface.index(attr) // keypad_size.attrs_per_key for attr in user_passcode]
user_passcode = set_interface[:passocode_len]
key_selection = lambda interface: [interface.index(attr) // keypad_size.numb_of_keys for attr in user_passcode]
set_key_selection = key_selection(set_interface)
confirm_interface = nkode_api.set_nkode(username, customer_id, set_key_selection, session_id)
@@ -31,6 +31,7 @@ def test_create_new_user_and_renew_keys(nkode_api, keypad_size, user_passcode):
)
assert successful_confirm
key_selection = lambda interface: [interface.index(attr) // keypad_size.attrs_per_key for attr in user_passcode]
login_interface = nkode_api.get_login_index_interface(username, customer_id)
login_key_selection = key_selection(login_interface)
successful_login = nkode_api.login(customer_id, username, login_key_selection)

View File

@@ -5,11 +5,11 @@ from src.models import KeypadSize
@pytest.mark.parametrize(
"keypad_size",
[KeypadSize(numb_of_keys=10, attrs_per_key=7)]
[KeypadSize(numb_of_keys=10, attrs_per_key=11)]
)
def test_attr_set_idx(keypad_size):
user_interface = UserInterface.new(keypad_size)
for attr_idx in range(70):
for attr_idx in range(keypad_size.numb_of_attrs):
user_interface_idx = user_interface.interface[attr_idx]
assert (attr_idx % keypad_size.attrs_per_key == user_interface_idx % keypad_size.attrs_per_key)

View File

@@ -22,9 +22,9 @@ def test_encode_decode_base64(passcode_len):
@pytest.mark.parametrize(
"keypad_size,max_nkode_len",
[
(KeypadSize(numb_of_keys=10, attrs_per_key=7), 10),
(KeypadSize(numb_of_keys=9, attrs_per_key=7), 10),
(KeypadSize(numb_of_keys=8, attrs_per_key=7), 12),
(KeypadSize(numb_of_keys=10, attrs_per_key=11), 10),
(KeypadSize(numb_of_keys=9, attrs_per_key=11), 10),
(KeypadSize(numb_of_keys=8, attrs_per_key=11), 12),
])
def test_decode_mask(keypad_size, max_nkode_len):
customer = CustomerAttributes.new(keypad_size)

View File

@@ -26,7 +26,7 @@ def test_shuffle_attrs(user_interface):
- the order in which the attributes move from key to key is random (i.e. the distance traveled is uniform)
"""
pre_shuffle_interface = user_interface.interface
user_interface.shuffle_interface()
user_interface.partial_interface_shuffle()
post_shuffle_interface = user_interface.interface
for i in range(1000):
assert (not all(