from fooder.utils.password_helper import password_helper import pytest def test_password_hash_and_verify(faker): password = faker.password() hash = password_helper.hash(password) assert password_helper.verify(password, hash) def test_wrong_password_doesnt_verify(faker): password = faker.password() hash = password_helper.hash(password) password2 = faker.password() assert not password_helper.verify(password2, hash) def test_wrong_hash_breaks(faker): password = faker.password() with pytest.raises(Exception, match="hash"): assert not password_helper.verify(password, "invalid_hash")