Annotation Type WithSecurityContext
-
@Target(ANNOTATION_TYPE) @Retention(RUNTIME) @Inherited @Documented public @interface WithSecurityContextAn annotation to determine what
SecurityContextto use. Thefactory()attribute must be provided with an instance ofWithUserDetailsSecurityContextFactory.Typically this annotation will be used as an meta-annotation as done with
WithMockUserandWithUserDetails.If you would like to create your own implementation of
WithSecurityContextFactoryyou can do so by implementing the interface. You can also useAutowiredand other Spring semantics on theWithSecurityContextFactoryimplementation.- Since:
- 4.0
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.Class<? extends WithSecurityContextFactory<? extends java.lang.annotation.Annotation>>factoryTheWithUserDetailsSecurityContextFactoryto use to create theSecurityContext.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description TestExecutionEventsetupBeforeDetermines when theSecurityContextis setup.
-
-
-
Element Detail
-
factory
java.lang.Class<? extends WithSecurityContextFactory<? extends java.lang.annotation.Annotation>> factory
TheWithUserDetailsSecurityContextFactoryto use to create theSecurityContext. It can containAutowiredand other Spring annotations.- Returns:
-
-
-
setupBefore
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
-
-