test(packs-lab): conftest로 HMAC secret 통일
모든 테스트에서 BACKEND_HMAC_SECRET 환경변수와 auth._SECRET 모듈 캐시를 동일한 값으로 설정하는 autouse fixture 추가. 기존 test_auth.py / test_routes.py와 동일한 secret 값 사용. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
16
packs-lab/tests/conftest.py
Normal file
16
packs-lab/tests/conftest.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""packs-lab 테스트 공통 fixture."""
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _hmac_secret(monkeypatch):
|
||||
"""모든 테스트에서 동일한 HMAC secret 사용. auth._SECRET 모듈 캐시까지 갱신.
|
||||
|
||||
test_auth.py / test_routes.py 모두 모듈 레벨에서 동일한 값을 os.environ에
|
||||
직접 세팅하므로 여기서도 같은 값을 사용해 충돌 없이 일관성을 보장한다.
|
||||
"""
|
||||
secret = "test-secret-32-bytes-XXXXXXXXXXXX"
|
||||
monkeypatch.setenv("BACKEND_HMAC_SECRET", secret)
|
||||
# auth.py 모듈은 import 시점에 _SECRET을 캐시하므로 monkeypatch로 함께 갱신
|
||||
from app import auth
|
||||
monkeypatch.setattr(auth, "_SECRET", secret)
|
||||
Reference in New Issue
Block a user