use of rocks.coffeenet.autoconfigure.security.config.CoffeeNetSecurityAutoConfiguration.IntegrationCoffeeNetSecurityConfiguration in project coffeenet-starter by coffeenet.
the class IntegrationCoffeeNetSecurityConfigurationTest method configureCorrectDefaultLoginFailureUrl.
@Test
public void configureCorrectDefaultLoginFailureUrl() throws IOException, ServletException {
CoffeeNetSecurityProperties coffeeNetSecurityProperties = new CoffeeNetSecurityProperties();
coffeeNetSecurityProperties.setDefaultLoginFailureUrl("/this-is-a-test-url");
IntegrationCoffeeNetSecurityConfiguration sut = new IntegrationCoffeeNetSecurityConfiguration(new CoffeeNetSecurityClientProperties(), new CoffeeNetSecurityResourceProperties(), coffeeNetSecurityProperties);
CoffeeNetSimpleUrlAuthenticationFailureHandler authenticationFailureHandler = (CoffeeNetSimpleUrlAuthenticationFailureHandler) sut.defaultAuthenticationFailureHandler();
DefaultRedirectStrategy redirectStrategyMock = mock(DefaultRedirectStrategy.class);
authenticationFailureHandler.setRedirectStrategy(redirectStrategyMock);
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
AuthenticationServiceException test = new AuthenticationServiceException("test");
authenticationFailureHandler.onAuthenticationFailure(request, response, test);
verify(redirectStrategyMock).sendRedirect(request, response, "/this-is-a-test-url");
}
Aggregations