Refactor authentication services to async password handling; optimize bulk operations and queries

- Updated `verify_password` and `get_password_hash` to their async counterparts to prevent event loop blocking.
- Replaced N+1 query patterns in `admin.py` and `session_async.py` with optimized bulk operations for improved performance.
- Enhanced `user_async.py` with bulk update and soft delete methods for efficient user management.
- Added eager loading support in CRUD operations to prevent N+1 query issues.
- Updated test cases with stronger password examples for better security representation.
This commit is contained in:
Felipe Cardoso
2025-11-01 03:53:22 +01:00
parent 819f3ba963
commit 3fe5d301f8
17 changed files with 397 additions and 163 deletions

View File

@@ -30,7 +30,7 @@ class TestRegisterEndpoint:
"/api/v1/auth/register",
json={
"email": "newuser@example.com",
"password": "SecurePassword123",
"password": "SecurePassword123!",
"first_name": "New",
"last_name": "User"
}
@@ -49,7 +49,7 @@ class TestRegisterEndpoint:
"/api/v1/auth/register",
json={
"email": async_test_user.email,
"password": "SecurePassword123",
"password": "SecurePassword123!",
"first_name": "Duplicate",
"last_name": "User"
}
@@ -103,7 +103,7 @@ class TestLoginEndpoint:
"/api/v1/auth/login",
json={
"email": async_test_user.email,
"password": "TestPassword123"
"password": "TestPassword123!"
}
)
@@ -133,7 +133,7 @@ class TestLoginEndpoint:
"/api/v1/auth/login",
json={
"email": "nonexistent@example.com",
"password": "Password123"
"password": "Password123!"
}
)
@@ -154,7 +154,7 @@ class TestLoginEndpoint:
"/api/v1/auth/login",
json={
"email": async_test_user.email,
"password": "TestPassword123"
"password": "TestPassword123!"
}
)
@@ -170,7 +170,7 @@ class TestLoginEndpoint:
"/api/v1/auth/login",
json={
"email": async_test_user.email,
"password": "TestPassword123"
"password": "TestPassword123!"
}
)
@@ -187,7 +187,7 @@ class TestOAuthLoginEndpoint:
"/api/v1/auth/login/oauth",
data={
"username": async_test_user.email,
"password": "TestPassword123"
"password": "TestPassword123!"
}
)
@@ -224,7 +224,7 @@ class TestOAuthLoginEndpoint:
"/api/v1/auth/login/oauth",
data={
"username": async_test_user.email,
"password": "TestPassword123"
"password": "TestPassword123!"
}
)
@@ -240,7 +240,7 @@ class TestOAuthLoginEndpoint:
"/api/v1/auth/login/oauth",
data={
"username": async_test_user.email,
"password": "TestPassword123"
"password": "TestPassword123!"
}
)
@@ -258,7 +258,7 @@ class TestRefreshTokenEndpoint:
"/api/v1/auth/login",
json={
"email": async_test_user.email,
"password": "TestPassword123"
"password": "TestPassword123!"
}
)
refresh_token = login_response.json()["refresh_token"]
@@ -307,7 +307,7 @@ class TestRefreshTokenEndpoint:
"/api/v1/auth/login",
json={
"email": async_test_user.email,
"password": "TestPassword123"
"password": "TestPassword123!"
}
)
refresh_token = login_response.json()["refresh_token"]
@@ -334,7 +334,7 @@ class TestGetCurrentUserEndpoint:
"/api/v1/auth/login",
json={
"email": async_test_user.email,
"password": "TestPassword123"
"password": "TestPassword123!"
}
)
access_token = login_response.json()["access_token"]