@WithMockUser( 공식문서 )
- The user with the username "user" does not have to exist since we are mocking the user
- The
Authentication
that is populated in theSecurityContext
is of typeUsernamePasswordAuthenticationToken
- The principal on the
Authentication
is Spring Security’sUser
object
- The
User
will have the username of "user", the password "password", and a singleGrantedAuthority
named "ROLE_USER" is used.
@WithSecurityContext
- WithMockCustomUserSecurityContextFactory에서 WithMockCustomUser를 받아서 Authentication을 생성하고 SecurityContext에 설정하는 것 까지 진행해줌 → 완전한 Customizing이 가능함