Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016VBGFXB9AbJBwXP19z75Qq
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""Z01 마스터 데이터 라우터 등록 — `main.py` 에 붙었고 시스템 관리자만 통과하는지.
|
|
|
|
(2026-09-15 브레인 Z01)
|
|
① 경로 둘(`/api/master-data/tree` · `/rows`)이 앱에 붙어 있음
|
|
② 보호 = 로그인 + 시스템 관리자 — 회사·프로젝트 보호는 안 붙음
|
|
(시스템 관리자는 회사가 없을 수 있음)
|
|
서버를 띄우지 않고 경로의 의존성만 훑음(`test_app_imports` 와 같은 방식).
|
|
"""
|
|
|
|
import importlib
|
|
|
|
from fastapi.routing import APIRoute
|
|
|
|
from common_util.common_util_auth import require_company, require_system_admin, verify_session
|
|
|
|
|
|
def _calls(dependant) -> set:
|
|
found = set()
|
|
for sub in dependant.dependencies:
|
|
found.add(sub.call)
|
|
found |= _calls(sub)
|
|
return found
|
|
|
|
|
|
def test_마스터_데이터_경로는_시스템_관리자만() -> None:
|
|
app = importlib.import_module("main").app
|
|
routes = {r.path: r for r in app.routes if isinstance(r, APIRoute)}
|
|
for path in ("/api/master-data/tree", "/api/master-data/rows"):
|
|
assert path in routes, f"라우터 경로가 없습니다: {path}"
|
|
calls = _calls(routes[path].dependant)
|
|
assert {verify_session, require_system_admin} <= calls
|
|
assert require_company not in calls
|