From ef026e7ac6f0edeb1300b392e7a6aec3f0200446 Mon Sep 17 00:00:00 2001 From: gahusb Date: Wed, 6 May 2026 01:24:17 +0900 Subject: [PATCH] =?UTF-8?q?test(packs-lab):=20conftest=EB=A1=9C=20HMAC=20s?= =?UTF-8?q?ecret=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 모든 테스트에서 BACKEND_HMAC_SECRET 환경변수와 auth._SECRET 모듈 캐시를 동일한 값으로 설정하는 autouse fixture 추가. 기존 test_auth.py / test_routes.py와 동일한 secret 값 사용. Co-Authored-By: Claude Sonnet 4.6 --- packs-lab/tests/conftest.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 packs-lab/tests/conftest.py diff --git a/packs-lab/tests/conftest.py b/packs-lab/tests/conftest.py new file mode 100644 index 0000000..ee12adc --- /dev/null +++ b/packs-lab/tests/conftest.py @@ -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)