Search in sources :

Example 1 with IntegrationCoffeeNetSecurityConfiguration

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");
}
Also used : IntegrationCoffeeNetSecurityConfiguration(rocks.coffeenet.autoconfigure.security.config.CoffeeNetSecurityAutoConfiguration.IntegrationCoffeeNetSecurityConfiguration) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DefaultRedirectStrategy(org.springframework.security.web.DefaultRedirectStrategy) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AuthenticationServiceException(org.springframework.security.authentication.AuthenticationServiceException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 AuthenticationServiceException (org.springframework.security.authentication.AuthenticationServiceException)1 DefaultRedirectStrategy (org.springframework.security.web.DefaultRedirectStrategy)1 IntegrationCoffeeNetSecurityConfiguration (rocks.coffeenet.autoconfigure.security.config.CoffeeNetSecurityAutoConfiguration.IntegrationCoffeeNetSecurityConfiguration)1