/** * Establish the specified {@link SecurityContext} to be used. * * <p> * This works by associating the user to the {@link HttpServletRequest}. To associate * the request to the {@link SecurityContextHolder} you need to ensure that the * {@link SecurityContextPersistenceFilter} (i.e. Spring Security's FilterChainProxy * will typically do this) is associated with the {@link MockMvc} instance. * </p> */ public static RequestPostProcessor securityContext(SecurityContext securityContext) { return new SecurityContextRequestPostProcessor(securityContext); }
@Override public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { save(this.securityContext, request); return request; } }
/** * Establish the specified {@link SecurityContext} to be used. * * <p> * This works by associating the user to the {@link HttpServletRequest}. To associate * the request to the {@link SecurityContextHolder} you need to ensure that the * {@link SecurityContextPersistenceFilter} (i.e. Spring Security's FilterChainProxy * will typically do this) is associated with the {@link MockMvc} instance. * </p> */ public static RequestPostProcessor securityContext(SecurityContext securityContext) { return new SecurityContextRequestPostProcessor(securityContext); }
@Override public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { save(this.securityContext, request); return request; } }