diff --git a/README.md b/README.md index da22fad..8043a3e 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,15 @@ FastAPI Backend Platform for Acupedia Learning Content, Subscriptions, Pricing, and Payments. -[![Tests](https://img.shields.io/badge/tests-93%20passed-brightgreen)](#test-status--coverage) [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](#test-status--coverage) +[![Tests](https://img.shields.io/badge/tests-6%20failed-red)](#test-status--coverage) [![Coverage](https://img.shields.io/badge/coverage-73%25-yellow)](#test-status--coverage) | Metric | Status | | :--- | :--- | -| **Test Suite** | `PASSED` | -| **Tests Passing** | `93` | -| **Tests Failing** | `0` | -| **Core Coverage** | `100%` | -| **Last Updated** | `2026-10-19 06:13:19 UTC` | +| **Test Suite** | `FAILED` | +| **Tests Passing** | `92` | +| **Tests Failing** | `6` | +| **Core Coverage** | `73%` | +| **Last Updated** | `2026-10-22 06:02:56 UTC` | --- diff --git a/app/features/auth/security.py b/app/features/auth/security.py index 17a131f..736619c 100644 --- a/app/features/auth/security.py +++ b/app/features/auth/security.py @@ -7,6 +7,7 @@ import json import os import re import secrets +import string import time from typing import Any @@ -56,7 +57,7 @@ def validate_password_strength(password: str) -> None: raise WeakPasswordError( "Password must contain at least one number." ) - if not any(not c.isalnum() and not c.isspace() for c in password): + if not any(c in string.punctuation for c in password): raise WeakPasswordError( "Password must contain at least one special character." ) diff --git a/tests/test_password_validation.py b/tests/test_password_validation.py index b49e38a..a0d6e81 100644 --- a/tests/test_password_validation.py +++ b/tests/test_password_validation.py @@ -28,6 +28,11 @@ class TestPasswordValidation(unittest.TestCase): validate_password_strength("NoSpecial123") self.assertIn("special character", str(ctx.exception)) + def test_emoji_instead_of_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") diff --git a/tests/unit/test_security.py b/tests/unit/test_security.py index 80df6e5..f5d4d96 100644 --- a/tests/unit/test_security.py +++ b/tests/unit/test_security.py @@ -68,6 +68,10 @@ class TestPasswordValidationAndHashing: with pytest.raises(WeakPasswordError, match="special character"): validate_password_strength("Password 12345") + def test_password_strength_emoji_instead_of_special_char_fails(self) -> None: + with pytest.raises(WeakPasswordError, match="special character"): + validate_password_strength("Password😀12345") + def test_hash_and_verify_password_lifecycle(self) -> None: raw_pw = "SuperSecure#2026" hashed = hash_password(raw_pw)