Annotation Interface WithSecurityContext
@Target(ANNOTATION_TYPE)
@Retention(RUNTIME)
@Inherited
@Documented
public @interface WithSecurityContext
An annotation to determine what SecurityContext
to use. The factory()
attribute must be provided with an instance of
WithUserDetailsSecurityContextFactory
.
Typically this annotation will be used as an meta-annotation as done with
WithMockUser
and WithUserDetails
.
If you would like to create your own implementation of
WithSecurityContextFactory
you can do so by implementing the interface. You can
also use Autowired
and other Spring semantics on the
WithSecurityContextFactory
implementation.
- Since:
- 4.0
-
Required Element Summary
Modifier and TypeRequired ElementDescriptionClass<? extends WithSecurityContextFactory<? extends Annotation>>
TheWithUserDetailsSecurityContextFactory
to use to create theSecurityContext
. -
Optional Element Summary
-
Element Details
-
factory
Class<? extends WithSecurityContextFactory<? extends Annotation>> factoryTheWithUserDetailsSecurityContextFactory
to use to create theSecurityContext
. It can containAutowired
and other Spring annotations.- Returns:
-
-
-
setupBefore
TestExecutionEvent setupBeforeDetermines when theSecurityContext
is setup. The default is beforeTestExecutionEvent.TEST_METHOD
which occurs duringTestExecutionListener.beforeTestMethod(TestContext)
- Returns:
- the
TestExecutionEvent
to initialize before - Since:
- 5.1
- Default:
- TEST_METHOD
-