Annotation Type WithUserDetails
-
@Target({METHOD,TYPE}) @Retention(RUNTIME) @Inherited @Documented @WithSecurityContext(factory=org.springframework.security.test.context.support.WithUserDetailsSecurityContextFactory.class) public @interface WithUserDetails
When used withWithSecurityContextTestExecutionListener
this annotation can be added to a test method to emulate running with aUserDetails
returned from theUserDetailsService
. In order to work withMockMvc
TheSecurityContext
that is used will have the following properties:- The
SecurityContext
created with be that ofSecurityContextHolder.createEmptyContext()
- It will be populated with an
UsernamePasswordAuthenticationToken
that uses the username ofvalue()
.
- Since:
- 4.0
- Author:
- Rob Winch
- See Also:
WithMockUser
- The
-
-
Element Detail
-
value
String value
The username to look up in theUserDetailsService
- Returns:
- Default:
- "user"
-
-