FrameWork_ETC/Spring
스프링 시큐리티 @CreatedBy 테스트
아라한사
2017. 6. 9. 18:51
엔티티중에
@CreatedBy 가 붙은 엔티티가 있는데 set으로 직접 설정하고 저장하려고 해도 널로 들어가게 되는데 이런 경우
직접 하는 방법은
UserDetail detail = new UserDetail();
UserDetail.setEmail("arahansa@naver.com");
userDetailRepository.save(admin);
Authentication newAuth = new UsernamePasswordAuthenticationToken(detail, null, null);
SecurityContextHolder.getContext().setAuthentication(newAuth);
뭐 이런 식으로 처리하거나.. (내가 그냥 급하게 메서드 처리한건 위에거)
이렇게 하면 된다고 한다.
근데 스프링 시큐리티 @MockUser 쪽은 잘 안되는 경우가 있더라고..흠 뭔가 설정을 더 해야 하나 ? ;