bug(password-validation):fixed the regex for rejecting emoji as special character in password
This commit is contained in:
parent
e9e34741dd
commit
c9c0064341
12
README.md
12
README.md
|
|
@ -3,15 +3,15 @@
|
|||
FastAPI Backend Platform for Acupedia Learning Content, Subscriptions, Pricing, and Payments.
|
||||
|
||||
<!-- START_TEST_STATUS -->
|
||||
[](#test-status--coverage) [](#test-status--coverage)
|
||||
[](#test-status--coverage) [](#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` |
|
||||
<!-- END_TEST_STATUS -->
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue