feat: migrate to Pydantic V2 and implement rate limiting middleware
- Migrate settings.py to Pydantic V2 (SettingsConfigDict, validation_alias) - Update config models to use @field_validator with @classmethod - Replace deprecated datetime.utcnow() with datetime.now(timezone.utc) - Migrate FastAPI app from @app.on_event to lifespan context manager - Implement comprehensive rate limiting middleware with: * Endpoint-specific rate limits (login: 5/min, register: 3/min) * IP-based and user-based tracking * Authenticated user multiplier (2x limits) * Bypass paths for health, docs, static, websocket endpoints * Rate limit headers in responses - Add 13 comprehensive tests for rate limiting (all passing) - Update instructions.md to mark completed tasks - Fix asyncio.create_task usage in anime_service.py All 714 tests passing. No deprecation warnings.
This commit is contained in:
@@ -220,7 +220,7 @@ class TestWebSocketDownloadIntegration:
|
||||
download_service.set_broadcast_callback(mock_broadcast)
|
||||
|
||||
# Manually add a completed item to test
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from src.server.models.download import DownloadItem
|
||||
|
||||
@@ -231,7 +231,7 @@ class TestWebSocketDownloadIntegration:
|
||||
episode=EpisodeIdentifier(season=1, episode=1),
|
||||
status=DownloadStatus.COMPLETED,
|
||||
priority=DownloadPriority.NORMAL,
|
||||
added_at=datetime.utcnow(),
|
||||
added_at=datetime.now(timezone.utc),
|
||||
)
|
||||
download_service._completed_items.append(completed_item)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user