bug(password-validation):fixed the regex for rejecting emoji as special character in password #19
12
README.md
12
README.md
|
|
@ -3,15 +3,15 @@
|
||||||
FastAPI Backend Platform for Acupedia Learning Content, Subscriptions, Pricing, and Payments.
|
FastAPI Backend Platform for Acupedia Learning Content, Subscriptions, Pricing, and Payments.
|
||||||
|
|
||||||
<!-- START_TEST_STATUS -->
|
<!-- START_TEST_STATUS -->
|
||||||
[](#test-status--coverage) [](#test-status--coverage)
|
[](#test-status--coverage) [](#test-status--coverage)
|
||||||
|
|
||||||
| Metric | Status |
|
| Metric | Status |
|
||||||
| :--- | :--- |
|
| :--- | :--- |
|
||||||
| **Test Suite** | `PASSED` |
|
| **Test Suite** | `FAILED` |
|
||||||
| **Tests Passing** | `93` |
|
| **Tests Passing** | `92` |
|
||||||
| **Tests Failing** | `0` |
|
| **Tests Failing** | `6` |
|
||||||
| **Core Coverage** | `100%` |
|
| **Core Coverage** | `73%` |
|
||||||
| **Last Updated** | `2026-10-19 06:13:19 UTC` |
|
| **Last Updated** | `2026-10-22 06:02:56 UTC` |
|
||||||
<!-- END_TEST_STATUS -->
|
<!-- END_TEST_STATUS -->
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import secrets
|
import secrets
|
||||||
|
import string
|
||||||
import time
|
import time
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
@ -56,7 +57,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(c in string.punctuation for c in password):
|
||||||
raise WeakPasswordError(
|
raise WeakPasswordError(
|
||||||
"Password must contain at least one special character."
|
"Password must contain at least one special character."
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,11 @@ class TestPasswordValidation(unittest.TestCase):
|
||||||
validate_password_strength("NoSpecial123")
|
validate_password_strength("NoSpecial123")
|
||||||
self.assertIn("special character", str(ctx.exception))
|
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):
|
def test_valid_passwords_pass(self):
|
||||||
# Must not raise any exceptions
|
# Must not raise any exceptions
|
||||||
validate_password_strength("Siraj@12345")
|
validate_password_strength("Siraj@12345")
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,10 @@ class TestPasswordValidationAndHashing:
|
||||||
with pytest.raises(WeakPasswordError, match="special character"):
|
with pytest.raises(WeakPasswordError, match="special character"):
|
||||||
validate_password_strength("Password 12345")
|
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:
|
def test_hash_and_verify_password_lifecycle(self) -> None:
|
||||||
raw_pw = "SuperSecure#2026"
|
raw_pw = "SuperSecure#2026"
|
||||||
hashed = hash_password(raw_pw)
|
hashed = hash_password(raw_pw)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue