O'Reilly logo
  • Tokuhiro Matsuno thinks this is interesting:

But how can we perform an authenticated request? Spring Security offers two annotations that can help:

  • @WithMockUser—Loads the security context with a UserDetails using the given username, password, and authorization
  • @WithUserDetails—Loads the security context by looking up a UserDetails object for the given username

In both cases, S...


Cover of Spring Boot in Action


spring-security can manage user object. And we can override it in test cases by @WithMockUser and @WithUserDetails.