o2o-plagiarism-ai/tests/test_api.py
hbyang 4913bf3ecc API Key 인증 완전 제거
사내 운영 전제로 X-API-Key 인증을 전면 제거.
- app/core/auth.py 삭제
- routes.py에서 Depends(require_api_key) 모두 제거
- config.Settings에서 api_keys / api_key_set 제거
- .env / .env.example에서 API_KEYS 제거
- docker-compose.yml에서 API_KEYS 환경변수 제거 (KOSIMCSE_MODEL 추가)
- UI(index.html)에서 DEFAULT_API_KEY 상수 + X-API-Key 헤더 모두 제거
- scripts/sample_curl.sh, sample_python.py에서 키 헤더 제거
- tests: test_detect_requires_api_key → test_detect_no_auth_required로 갱신
- README: 인증 컬럼 제거, curl 예시에서 헤더 제거
2026-05-14 08:58:28 +09:00

59 lines
1.7 KiB
Python

"""스모크 테스트. `pip install fastapi httpx pytest` 후 실행."""
from __future__ import annotations
from fastapi.testclient import TestClient
from app.main import app
def test_health():
with TestClient(app) as client:
resp = client.get("/v1/health")
assert resp.status_code == 200
body = resp.json()
assert body["status"] == "ok"
assert body["corpus_size"] >= 0
def test_detect_no_auth_required():
"""인증 제거 - 키 없이도 200 응답."""
with TestClient(app) as client:
resp = client.post(
"/v1/plagiarism/detect",
json={"doc_id": "x", "text": "테스트 본문"},
)
assert resp.status_code == 200
def test_detect_returns_schema():
with TestClient(app) as client:
resp = client.post(
"/v1/plagiarism/detect",
json={
"doc_id": "t-1",
"text": "어린왕자는 작은 별에서 온 소년이다. 그는 여우를 만나 길들임을 배운다.",
},
)
assert resp.status_code == 200
body = resp.json()
assert body["doc_id"] == "t-1"
assert "matches" in body
assert "extracted_elements" in body
assert "engine_version" in body
def test_batch_flow():
with TestClient(app) as client:
resp = client.post(
"/v1/plagiarism/batch",
json={
"items": [
{"doc_id": "b-1", "text": "앤 셜리는 초록 지붕 집에 입양된 소녀다."},
]
},
)
assert resp.status_code == 202
job_id = resp.json()["job_id"]
status = client.get(f"/v1/plagiarism/batch/{job_id}")
assert status.status_code == 200