/** * Establish a {@link SecurityContext} that uses an * {@link AnonymousAuthenticationToken}. This is useful when a user wants to run a * majority of tests as a specific user and wishes to override a few methods to be * anonymous. For example: * * <pre> * <code> * public class SecurityTests { * @Before * public void setup() { * mockMvc = MockMvcBuilders * .webAppContextSetup(context) * .defaultRequest(get("/").with(user("user"))) * .build(); * } * * @Test * public void anonymous() { * mockMvc.perform(get("anonymous").with(anonymous())); * } * // ... lots of tests ran with a default user ... * } * </code> </pre> * * @return the {@link RequestPostProcessor} to use */ public static RequestPostProcessor anonymous() { return new AnonymousRequestPostProcessor(); }
/** * Establish a {@link SecurityContext} that uses an * {@link AnonymousAuthenticationToken}. This is useful when a user wants to run a * majority of tests as a specific user and wishes to override a few methods to be * anonymous. For example: * * <pre> * <code> * public class SecurityTests { * @Before * public void setup() { * mockMvc = MockMvcBuilders * .webAppContextSetup(context) * .defaultRequest(get("/").with(user("user"))) * .build(); * } * * @Test * public void anonymous() { * mockMvc.perform(get("anonymous").with(anonymous())); * } * // ... lots of tests ran with a default user ... * } * </code> </pre> * * @return the {@link RequestPostProcessor} to use */ public static RequestPostProcessor anonymous() { return new AnonymousRequestPostProcessor(); }