A Python port of the Invisible Internet Project (I2P)
at main 25 lines 811 B view raw
1"""Tests for auth middleware — TDD: tests before implementation.""" 2 3import pytest 4from i2p_apps.console.auth import check_password, generate_password_hash 5 6 7class TestPasswordAuth: 8 def test_hash_generation(self): 9 h = generate_password_hash("secret") 10 assert h is not None 11 assert len(h) > 0 12 assert h != "secret" 13 14 def test_check_correct_password(self): 15 h = generate_password_hash("mypassword") 16 assert check_password("mypassword", h) is True 17 18 def test_check_wrong_password(self): 19 h = generate_password_hash("mypassword") 20 assert check_password("wrong", h) is False 21 22 def test_different_passwords_different_hashes(self): 23 h1 = generate_password_hash("pass1") 24 h2 = generate_password_hash("pass2") 25 assert h1 != h2