test isses fixes
This commit is contained in:
@@ -21,8 +21,8 @@ router = APIRouter(prefix="/api/queue", tags=["download"])
|
||||
|
||||
@router.get("/status", response_model=QueueStatusResponse)
|
||||
async def get_queue_status(
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Get current download queue status and statistics.
|
||||
|
||||
@@ -60,8 +60,8 @@ async def get_queue_status(
|
||||
)
|
||||
async def add_to_queue(
|
||||
request: DownloadRequest,
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Add episodes to the download queue.
|
||||
|
||||
@@ -121,8 +121,8 @@ async def add_to_queue(
|
||||
|
||||
@router.delete("/completed", status_code=status.HTTP_200_OK)
|
||||
async def clear_completed(
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Clear completed downloads from history.
|
||||
|
||||
@@ -156,8 +156,8 @@ async def clear_completed(
|
||||
@router.delete("/{item_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def remove_from_queue(
|
||||
item_id: str = Path(..., description="Download item ID to remove"),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Remove a specific item from the download queue.
|
||||
|
||||
@@ -200,8 +200,8 @@ async def remove_from_queue(
|
||||
@router.delete("/", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def remove_multiple_from_queue(
|
||||
request: QueueOperationRequest,
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Remove multiple items from the download queue.
|
||||
|
||||
@@ -246,8 +246,8 @@ async def remove_multiple_from_queue(
|
||||
|
||||
@router.post("/start", status_code=status.HTTP_200_OK)
|
||||
async def start_queue(
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Start the download queue processor.
|
||||
|
||||
@@ -280,8 +280,8 @@ async def start_queue(
|
||||
|
||||
@router.post("/stop", status_code=status.HTTP_200_OK)
|
||||
async def stop_queue(
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Stop the download queue processor.
|
||||
|
||||
@@ -314,8 +314,8 @@ async def stop_queue(
|
||||
|
||||
@router.post("/pause", status_code=status.HTTP_200_OK)
|
||||
async def pause_queue(
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Pause the download queue processor.
|
||||
|
||||
@@ -347,8 +347,8 @@ async def pause_queue(
|
||||
|
||||
@router.post("/resume", status_code=status.HTTP_200_OK)
|
||||
async def resume_queue(
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Resume the download queue processor.
|
||||
|
||||
@@ -381,8 +381,8 @@ async def resume_queue(
|
||||
@router.post("/reorder", status_code=status.HTTP_200_OK)
|
||||
async def reorder_queue(
|
||||
request: QueueReorderRequest,
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Reorder an item in the pending queue.
|
||||
|
||||
@@ -436,8 +436,8 @@ async def reorder_queue(
|
||||
@router.post("/retry", status_code=status.HTTP_200_OK)
|
||||
async def retry_failed(
|
||||
request: QueueOperationRequest,
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Retry failed downloads.
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ a proper token revocation store.
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from typing import Callable, Dict, Optional
|
||||
from typing import Callable, Dict
|
||||
|
||||
from fastapi import HTTPException, Request, status
|
||||
from fastapi import Request, status
|
||||
from fastapi.responses import JSONResponse
|
||||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
from starlette.types import ASGIApp
|
||||
@@ -76,7 +76,17 @@ class AuthMiddleware(BaseHTTPMiddleware):
|
||||
# For public/auth endpoints let the dependency system handle
|
||||
# optional auth and return None.
|
||||
if path.startswith("/api/") and not path.startswith("/api/auth"):
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
content={"detail": "Invalid token"}
|
||||
)
|
||||
else:
|
||||
# No authorization header: check if this is a protected endpoint
|
||||
if path.startswith("/api/") and not path.startswith("/api/auth"):
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
content={"detail": "Missing authorization credentials"}
|
||||
)
|
||||
|
||||
return await call_next(request)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user