@Test public void requestWhenCustomSessionAuthenticationStrategyProvidedThenCalled() throws Exception { this.spring.register(CustomSessionAuthenticationStrategyConfig.class).autowire(); this.mvc.perform(formLogin().user("user").password("password")); verify(CustomSessionAuthenticationStrategyConfig.customSessionAuthenticationStrategy) .onAuthentication(any(Authentication.class), any(HttpServletRequest.class), any(HttpServletResponse.class)); }
@Test public void authenticationManagerWhenMultipleProvidersThenWorks() throws Exception { this.spring.register(MultiAuthenticationProvidersConfig.class).autowire(); this.mockMvc.perform(formLogin()) .andExpect(authenticated().withUsername("user").withRoles("USER")); this.mockMvc.perform(formLogin().user("admin")) .andExpect(authenticated().withUsername("admin").withRoles("USER", "ADMIN")); }
public void buildWhenUserFromProperties() throws Exception { this.spring.register(UserFromPropertiesConfig.class).autowire(); this.mockMvc.perform(formLogin().user("joe", "joespassword")) .andExpect(authenticated().withUsername("joe").withRoles("USER")); }