implement keypad size

This commit is contained in:
2024-07-19 10:39:05 -05:00
parent b37c17eca6
commit 65d78867ca
13 changed files with 198 additions and 191 deletions

View File

@@ -1,4 +1,6 @@
import pytest
from src.models import KeypadSize
from src.user_cipher_keys import UserCipherKeys, CustomerInterface
from src.utils import generate_random_nonrepeating_list
@@ -18,20 +20,20 @@ def test_encode_decode_base64(passcode_len):
@pytest.mark.parametrize(
"numb_of_keys,attrs_per_key,max_nkode_len",
"keypad_size,max_nkode_len",
[
(10, 7, 10),
(9, 7, 10),
(8, 7, 12),
(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),
])
def test_decode_mask(numb_of_keys, attrs_per_key, max_nkode_len):
customer = CustomerInterface.new(numb_of_keys, attrs_per_key)
def test_decode_mask(keypad_size, max_nkode_len):
customer = CustomerInterface.new(keypad_size)
passcode_entry = generate_random_nonrepeating_list(
numb_of_keys * attrs_per_key,
max_val=(numb_of_keys*attrs_per_key))[:4]
keypad_size.numb_of_attrs,
max_val=keypad_size.numb_of_attrs)[:4]
passcode_values = [customer.attr_vals[idx] for idx in passcode_entry]
set_vals = customer.set_vals
user_keys = UserCipherKeys.new(numb_of_keys, attrs_per_key, set_vals, max_nkode_len)
user_keys = UserCipherKeys.new(keypad_size, set_vals, max_nkode_len)
passcode = user_keys.encipher_nkode(passcode_entry, customer)
orig_passcode_set_vals = [customer.get_attr_set_val(attr) for attr in passcode_values]