fix tests

This commit is contained in:
2025-10-19 20:49:42 +02:00
parent 4db53c93df
commit e578623999
6 changed files with 434 additions and 54 deletions

View File

@@ -20,7 +20,8 @@ from src.core.SeriesApp import SeriesApp
from src.server.services.auth_service import AuthError, auth_service
# Security scheme for JWT authentication
security = HTTPBearer()
# Use auto_error=False to handle errors manually and return 401 instead of 403
security = HTTPBearer(auto_error=False)
# Global SeriesApp instance
@@ -99,7 +100,7 @@ async def get_database_session() -> AsyncGenerator:
def get_current_user(
credentials: HTTPAuthorizationCredentials = Depends(security)
credentials: Optional[HTTPAuthorizationCredentials] = Depends(security),
) -> dict:
"""
Dependency to get current authenticated user.
@@ -128,7 +129,7 @@ def get_current_user(
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=str(e),
)
) from e
def require_auth(