Compare commits

..

No commits in common. "29279bfd72a6fa296d1aa05a825bd88ca1f36c91" and "11a4e82609e4af47330f1ce893a7e20381cf5d2d" have entirely different histories.

2 changed files with 1 additions and 40 deletions

View File

@ -56,7 +56,7 @@ def validate_password_strength(password: str) -> None:
raise WeakPasswordError( raise WeakPasswordError(
"Password must contain at least one number." "Password must contain at least one number."
) )
if not any(not c.isalnum() and not c.isspace() for c in password): if not any(not c.isalnum() for c in password):
raise WeakPasswordError( raise WeakPasswordError(
"Password must contain at least one special character." "Password must contain at least one special character."
) )

View File

@ -1,39 +0,0 @@
import unittest
from app.features.auth.security import validate_password_strength
from app.features.auth.errors import WeakPasswordError
class TestPasswordValidation(unittest.TestCase):
def test_space_instead_of_special_char_fails(self):
with self.assertRaises(WeakPasswordError) as ctx:
validate_password_strength("Siraj 12345")
self.assertIn("special character", str(ctx.exception))
def test_too_short_fails(self):
with self.assertRaises(WeakPasswordError) as ctx:
validate_password_strength("Short1!")
self.assertIn("8 characters", str(ctx.exception))
def test_no_uppercase_fails(self):
with self.assertRaises(WeakPasswordError) as ctx:
validate_password_strength("lowercase1!")
self.assertIn("uppercase", str(ctx.exception))
def test_no_digit_fails(self):
with self.assertRaises(WeakPasswordError) as ctx:
validate_password_strength("NoNumbers!")
self.assertIn("number", str(ctx.exception))
def test_no_special_char_fails(self):
with self.assertRaises(WeakPasswordError) as ctx:
validate_password_strength("NoSpecial123")
self.assertIn("special character", str(ctx.exception))
def test_valid_passwords_pass(self):
# Must not raise any exceptions
validate_password_strength("Siraj@12345")
validate_password_strength("ValidPassword123!")
validate_password_strength("P@ssw0rd2026")
validate_password_strength("Strong#Pass1")
if __name__ == "__main__":
unittest.main()