Annotation Type WithUserDetails
-
@Target({METHOD,TYPE}) @Retention(RUNTIME) @Inherited @Documented @WithSecurityContext(factory=org.springframework.security.test.context.support.WithUserDetailsSecurityContextFactory.class) public @interface WithUserDetailsWhen used withWithSecurityContextTestExecutionListenerthis annotation can be added to a test method to emulate running with aUserDetailsreturned from theUserDetailsService. In order to work withMockMvcTheSecurityContextthat is used will have the following properties:- The
SecurityContextcreated with be that ofSecurityContextHolder.createEmptyContext() - It will be populated with an
UsernamePasswordAuthenticationTokenthat uses the username ofvalue().
- Since:
- 4.0
- See Also:
WithMockUser
- The
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description TestExecutionEventsetupBeforeDetermines when theSecurityContextis setup.java.lang.StringuserDetailsServiceBeanNameThe bean name for theUserDetailsServiceto use.java.lang.StringvalueThe username to look up in theUserDetailsService
-
-
-
-
userDetailsServiceBeanName
java.lang.String userDetailsServiceBeanName
The bean name for theUserDetailsServiceto use. If this is not provided, then the lookup is done by type and expects only a singleUserDetailsServicebean to be exposed.- Returns:
- the bean name for the
UserDetailsServiceto use. - Since:
- 4.1
- Default:
- ""
-
-
-
setupBefore
@AliasFor(annotation=WithSecurityContext.class) TestExecutionEvent setupBefore
Determines when theSecurityContextis setup. The default is beforeTestExecutionEvent.TEST_METHODwhich occurs duringTestExecutionListener.beforeTestMethod(TestContext)- Returns:
- the
TestExecutionEventto initialize before - Since:
- 5.1
- Default:
- org.springframework.security.test.context.support.TestExecutionEvent.TEST_METHOD
-
-