mirror of
https://github.com/azaion/detections.git
synced 2026-04-22 22:26:33 +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
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
import re
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.slow
|
|
@pytest.mark.timeout(120)
|
|
def test_nft_res_lim_03_max_detections_per_frame(
|
|
warm_engine, http_client, image_dense, auth_headers
|
|
):
|
|
r = http_client.post(
|
|
"/detect/image",
|
|
files={"file": ("img.jpg", image_dense, "image/jpeg")},
|
|
headers=auth_headers,
|
|
timeout=120,
|
|
)
|
|
assert r.status_code == 200
|
|
body = r.json()
|
|
assert isinstance(body, list)
|
|
assert len(body) <= 300
|
|
|
|
|
|
@pytest.mark.slow
|
|
def test_nft_res_lim_04_log_file_rotation(warm_engine, http_client, image_small, auth_headers):
|
|
http_client.post(
|
|
"/detect/image",
|
|
files={"file": ("img.jpg", image_small, "image/jpeg")},
|
|
headers=auth_headers,
|
|
timeout=60,
|
|
)
|
|
candidates = [
|
|
Path(__file__).resolve().parent.parent / "logs",
|
|
Path("/app/Logs"),
|
|
]
|
|
log_dir = next((p for p in candidates if p.is_dir()), None)
|
|
if log_dir is None:
|
|
pytest.skip("Log directory not accessible from e2e-runner container")
|
|
today = datetime.now().strftime("%Y%m%d")
|
|
expected = f"log_inference_{today}.txt"
|
|
names = {p.name for p in log_dir.iterdir() if p.is_file()}
|
|
if expected not in names:
|
|
pat = re.compile(r"^log_inference_\d{8}\.txt$")
|
|
assert any(pat.match(n) for n in names), names
|