"""Local-auth bcrypt helpers.""" from __future__ import annotations import pytest from mimic.auth.password import check_password, hash_password def test_hash_then_check_succeeds() -> None: hashed = hash_password("Sup3rSecret!", rounds=4) assert check_password("Sup3rSecret!", hashed) is True def test_check_rejects_wrong_password() -> None: hashed = hash_password("right", rounds=4) assert check_password("wrong", hashed) is False def test_empty_password_raises() -> None: with pytest.raises(ValueError, match="must not be empty"): hash_password("") def test_check_missing_hash_returns_false() -> None: assert check_password("anything", None) is False assert check_password("anything", "") is False def test_check_invalid_hash_returns_false() -> None: assert check_password("anything", "not-a-bcrypt-hash") is False