This repository was archived by the owner on Mar 15, 2025. It is now read-only.
테스트 코드 작성 시 SecurityContextHolder에서 유저 정보 가져오는 법 #301
sangwonsheep
started this conversation in
메모장
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
SecurityContextHolder에 직접 유저 정보 넣기
이렇게 직접
SecurityContextHolder
에 수동으로 넣어주면, 시큐리티에 있는 유저 정보를 사용할 수 있게 됩니다.시큐리티 유저 정보 Mocking
이 부분으로 해결할 수도 있다고 알고 있지만, 2시간 정도 헤맨 이후에 결국엔 해결하지 못하여 이런 방법이 있다는 것만 공유드립니다.
모킹한 유저를 사용하려고 할 때, userId에 계속해서 null이 들어가는 문제가 있었습니다.
다만, 해결은 못했기에 추후 이 방법이 더 좋다고 생각이 드시면 사용해보는 것도 좋을 것 같습니다.
Beta Was this translation helpful? Give feedback.
All reactions