Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[고도화] 민감 정보의 환경변수 치환 후 테스트 실패 현상 수정 #103

Merged
merged 1 commit into from
May 27, 2023

Conversation

GGHDMS
Copy link
Owner

@GGHDMS GGHDMS commented May 27, 2023

환경변수를 이용해 application.yaml 안에 있던 민감 정보를 치환하여 보안성을 높였으나
일부 스프링 부트 테스트가 실패한다.

@SpringBootTest는 초기 테스트 환경을 구성하면서 프로퍼티 파일의 설정을 참고하기 때문에
환경변수가 주입되지 않은 테스트 환경에서 의도하지 않은 동작을 보이며 실패할 수 있다.
이를 수정하여 테스트가 실패하지 않도록 하자.

Reference

DB 접근 정보가 환경변수 문법으로 치환되었는데
`@SpringBootTest`가 이를 그대로 읽으면서
올바른 jdbc url 포맷이 아니므로 실패를 유발함

이에 적당히 인메모리 테스트 db인 h2 경로를
새로 만든 테스트 전용 `test` 프로파일에 지정해주고,
테스트 실행 시 이 프로파일을 바라보게 하여
문제 해결
@GGHDMS GGHDMS added bug Something isn't working enhancement New feature or request labels May 27, 2023
@GGHDMS GGHDMS added this to the 게시판 서비스 만들기 milestone May 27, 2023
@GGHDMS GGHDMS self-assigned this May 27, 2023
@GGHDMS GGHDMS removed the enhancement New feature or request label May 27, 2023
@GGHDMS GGHDMS merged commit 4b89dc1 into main May 27, 2023
@GGHDMS GGHDMS deleted the feature/#101-fix-test branch May 27, 2023 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[고도화] 민감 정보의 환경변수 치환 후 테스트 실패 현상 수정
1 participant