@Target(value=ANNOTATION_TYPE)
@Retention(value=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.
Modifier and Type | Required Element and Description |
---|---|
java.lang.Class<? extends WithSecurityContextFactory<? extends java.lang.annotation.Annotation>> |
factory
The
WithUserDetailsSecurityContextFactory to use to create the
SecurityContext . |
Modifier and Type | Optional Element and Description |
---|---|
TestExecutionEvent |
setupBefore
Determines when the
SecurityContext is setup. |
public abstract java.lang.Class<? extends WithSecurityContextFactory<? extends java.lang.annotation.Annotation>> factory
WithUserDetailsSecurityContextFactory
to use to create the
SecurityContext
. It can contain Autowired
and other Spring
annotations.public abstract TestExecutionEvent setupBefore
SecurityContext
is setup. The default is before
TestExecutionEvent.TEST_METHOD
which occurs during
TestExecutionListener.beforeTestMethod(TestContext)
TestExecutionEvent
to initialize before