mirror of
https://github.com/azaion/detections.git
synced 2026-04-23 03:56:31 +00:00
097811a67b
- Pin all deps; h11==0.16.0 (CVE-2025-43859), python-multipart>=1.3.1 (CVE-2026-28356), PyJWT==2.12.1
- Add HMAC JWT verification (require_auth FastAPI dependency, JWT_SECRET-gated)
- Fix TokenManager._refresh() to use ADMIN_API_URL instead of ANNOTATIONS_URL
- Rename POST /detect → POST /detect/image (image-only, rejects video files)
- Replace global SSE stream with per-job SSE: GET /detect/{media_id} with event replay buffer
- Apply require_auth to all 4 protected endpoints
- Fix on_annotation/on_status closure to use mutable current_id for correct post-upload event routing
- Add non-root appuser to Dockerfile and Dockerfile.gpu
- Add JWT_SECRET to e2e/docker-compose.test.yml and run-tests.sh
- Update all e2e tests and unit tests for new endpoints and HMAC token signing
- 64/64 tests pass
Made-with: Cursor
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import pytest
|
|
import requests
|
|
|
|
_DETECT_TIMEOUT = 60
|
|
|
|
|
|
def test_nft_res_01_loader_outage_after_init(
|
|
warm_engine, http_client, mock_loader_url, image_small, auth_headers
|
|
):
|
|
requests.post(
|
|
f"{mock_loader_url}/mock/config", json={"mode": "error"}, timeout=10
|
|
).raise_for_status()
|
|
files = {"file": ("r1.jpg", image_small, "image/jpeg")}
|
|
r = http_client.post("/detect/image", files=files, headers=auth_headers, timeout=_DETECT_TIMEOUT)
|
|
assert r.status_code == 200
|
|
assert isinstance(r.json(), list)
|
|
h = http_client.get("/health")
|
|
assert h.status_code == 200
|
|
hd = h.json()
|
|
assert hd["status"] == "healthy"
|
|
assert hd.get("errorMessage") is None
|
|
|
|
|
|
def test_nft_res_03_transient_loader_first_fail(
|
|
mock_loader_url, http_client, image_small, auth_headers
|
|
):
|
|
requests.post(
|
|
f"{mock_loader_url}/mock/config", json={"mode": "first_fail"}, timeout=10
|
|
).raise_for_status()
|
|
files = {"file": ("r3a.jpg", image_small, "image/jpeg")}
|
|
r1 = http_client.post("/detect/image", files=files, headers=auth_headers, timeout=_DETECT_TIMEOUT)
|
|
files2 = {"file": ("r3b.jpg", image_small, "image/jpeg")}
|
|
r2 = http_client.post("/detect/image", files=files2, headers=auth_headers, timeout=_DETECT_TIMEOUT)
|
|
assert r2.status_code == 200
|
|
if r1.status_code != 200:
|
|
assert r1.status_code != 500
|