feat(realestate): 내부 인증 + naver 워커 targets 엔드포인트 + nginx internal 블록

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqCYBhvTcdeCTUDX3RhWx9
This commit is contained in:
2026-07-10 00:27:23 +09:00
parent 008111eff8
commit f931c496d8
5 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import os
from fastapi.testclient import TestClient
def _client(monkeypatch):
monkeypatch.setenv("INTERNAL_API_KEY", "SECRET")
import importlib
from app import auth as _a
importlib.reload(_a) # env 반영
from app.main import app
return TestClient(app)
def test_targets_requires_key(monkeypatch):
c = _client(monkeypatch)
# 헤더 없음 — FastAPI Header(...)는 dependency 실행 전 자체 검증하므로 422.
# image-lab/tests/test_internal_router.py의 동일 패턴과 일치(sibling 서비스 선례).
assert c.get("/api/internal/realestate/targets").status_code in (401, 422)
assert c.get("/api/internal/realestate/targets",
headers={"X-Internal-Key": "WRONG"}).status_code == 401
def test_targets_returns_dongs_with_cortar(monkeypatch):
c = _client(monkeypatch)
r = c.get("/api/internal/realestate/targets", headers={"X-Internal-Key": "SECRET"})
assert r.status_code == 200
body = r.json()
dongs = {d["dong"]: d["cortar_no"] for d in body["dongs"]}
assert dongs.get("신대방동") == "1159010100" # criteria seed 6동 + cortar join
assert "전세" in body["deal_types"]
assert isinstance(body["page_limit"], int)