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

@@ -1,4 +1,4 @@
from pydantic import BaseModel
from pydantic import BaseModel, model_validator
from src.models import KeypadSize
from src.utils import generate_random_nonrepeating_list
@@ -9,6 +9,13 @@ class CustomerAttributes(BaseModel):
set_vals: list[int]
keypad_size: KeypadSize
@model_validator(mode='after')
def check_keys_vs_attrs(self):
if self.keypad_size.is_dispersable:
raise ValueError("number of keys must be less than the number of "
"attributes per key to be dispersion resistant")
return self
@staticmethod
def new(keypad_size: KeypadSize):
assert (keypad_size.numb_of_keys <= 256)