public interface MockMvcAuthenticationSpecification
| Modifier and Type | Method and Description |
|---|---|
MockMvcRequestSpecification |
authentication(Object authentication)
Authenticate using the given authentication instance.
|
MockMvcRequestSpecification |
none()
Explicitly state that you don't which to use any authentication in this request.
|
MockMvcRequestSpecification |
principal(Object principal)
Authenticate using the given principal.
|
MockMvcRequestSpecification |
principal(Principal principal)
Authenticate using the given principal.
|
MockMvcRequestSpecification |
principalWithCredentials(Object principal,
Object credentials,
String... authorities)
Authenticate using the given principal and credentials.
|
MockMvcRequestSpecification principal(Principal principal)
MockHttpServletRequestBuilder.principal(java.security.Principal).principal - The principal to use.MockHttpServletRequestBuilder.principal(java.security.Principal)MockMvcRequestSpecification principal(Object principal)
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken(principal, ""));
Note that this method require Spring Security to be on the classpath. Also note that if you use this method Rest Assured will NOT be thread-safe.
principal - The principal to use.MockMvcRequestSpecification principalWithCredentials(Object principal, Object credentials, String... authorities)
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken(principal, credentials, authorities));
Note that this method require Spring Security to be on the classpath. Also note that if you use this method Rest Assured will NOT be thread-safe.
principal - The principal to use.credentials - The credentials to useauthorities - Optional list of authoritiesMockMvcRequestSpecification authentication(Object authentication)
SecurityContextHolder.getContext().setAuthentication(authentication);This means that the supplied object must be an instance of
org.springframework.security.core.Authentication.
Note that this method require Spring Security to be on the classpath. Also note that if you use this method Rest Assured will NOT be thread-safe.
authentication - the spring security authentication to use.MockMvcRequestSpecification none()
Copyright © 2010–2014. All rights reserved.