Fix SSRF access (#943)

This commit is contained in:
Alex
2026-05-03 10:47:06 +01:00
committed by GitHub
parent 4881adc19f
commit 7a2de1ccdd
4 changed files with 153 additions and 23 deletions
+28
View File
@@ -0,0 +1,28 @@
"""Cover proxy API security tests."""
from __future__ import annotations
import importlib
from unittest.mock import patch
import pytest
@pytest.fixture(scope="module")
def main_module():
"""Import `shelfmark.main` with background startup disabled."""
with patch("shelfmark.download.orchestrator.start"):
import shelfmark.main as main
importlib.reload(main)
return main
def test_cover_proxy_requires_authentication(main_module) -> None:
client = main_module.app.test_client()
with patch.object(main_module, "get_auth_mode", return_value="builtin"):
response = client.get("/api/covers/test-id")
assert response.status_code == 401
assert response.get_json() == {"error": "Unauthorized"}