Annotation Type WithMockTenantUser
@Target({METHOD,TYPE})
@Retention(RUNTIME)
@Inherited
@Documented
@WithSecurityContext(factory=WithMockTenantUserSecurityContextFactory.class)
public @interface WithMockTenantUser
When used with
WithSecurityContextTestExecutionListener this annotation can be added to a test method to emulate
running with a SecurityPrincipal. In order to work with MockMvc The SecurityContext that is used will
have the following properties:
-
Optional Element Summary
Optional Elements
-
Element Details
-
tenant
String tenantThe tenant identifier to be used. The default is "public".- Returns:
- the tenant identifier value.
- Default:
- "public"
-
value
String valueConvenience mechanism for specifying the username. The default is "user". Ifusername()is specified it will be used instead ofvalue().- Returns:
- the username value.
- Default:
- "user"
-
username
String usernameThe username to be used. Note thatvalue()is a synonym forusername(), but ifusername()is specified it will take precedence.- Returns:
- the username value.
- Default:
- ""
-
roles
String[] rolesThe roles to use. The default is "USER". A
GrantedAuthoritywill be created for each value within roles. Each value in roles will automatically be prefixed with "ROLE_". For example, the default will result in "ROLE_USER" being used.If
authorities()is specified this property cannot be changed from the default.- Returns:
- the array of roles.
- Default:
- {"USER"}
-
authorities
String[] authoritiesThe authorities to use. A
GrantedAuthoritywill be created for each value.If this property is specified then
roles()is not used. This differs fromroles()in that it does not prefix the values passed in automatically.- Returns:
- the array of authorities.
- Default:
- {}
-
setupBefore
@AliasFor(annotation=org.springframework.security.test.context.support.WithSecurityContext.class) org.springframework.security.test.context.support.TestExecutionEvent setupBefore- See Also:
-
WithSecurityContext.setupBefore()
- Default:
- TEST_METHOD
-