Files
seedPass/src/tests/test_password_length_constraints.py
2025-08-12 09:41:37 -04:00

33 lines
872 B
Python

import pytest
from pathlib import Path
import sys
sys.path.append(str(Path(__file__).resolve().parents[1]))
from seedpass.core.password_generation import PasswordGenerator, PasswordPolicy
from constants import MIN_PASSWORD_LENGTH
class DummyEnc:
def derive_seed_from_mnemonic(self, mnemonic):
return b"\x00" * 32
class DummyBIP85:
def derive_entropy(self, index: int, entropy_bytes: int, app_no: int = 32) -> bytes:
return bytes((index + i) % 256 for i in range(entropy_bytes))
def make_generator():
pg = PasswordGenerator.__new__(PasswordGenerator)
pg.encryption_manager = DummyEnc()
pg.bip85 = DummyBIP85()
pg.policy = PasswordPolicy()
return pg
def test_generate_password_too_short_raises():
pg = make_generator()
with pytest.raises(ValueError):
pg.generate_password(length=MIN_PASSWORD_LENGTH - 1)