package org.springframework.security.web.authentication.logout;

import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;

import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.security.core.Authentication;

/**
 *
 * @author Luke Taylor
 */
public class SimpleUrlLogoutSuccessHandlerTests {

    @Test
    public void doesntRedirectIfResponseIsCommitted() throws Exception {
        SimpleUrlLogoutSuccessHandler lsh = new SimpleUrlLogoutSuccessHandler();
        lsh.setDefaultTargetUrl("/target");
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        response.setCommitted(true);
        lsh.onLogoutSuccess(request, response, mock(Authentication.class));
        assertNull(request.getSession(false));
        assertNull(response.getRedirectedUrl());
        assertNull(response.getForwardedUrl());
    }
}

@@ -1036,10 +1036,520 @@
 ;%0A    %7D%0A
+%0A    @Test%0A    public void absoluteUrlIsSupported() throws Exception %7B%0A        SimpleUrlLogoutSuccessHandler lsh = new SimpleUrlLogoutSuccessHandler();%0A        lsh.setDefaultTargetUrl(%22http://someurl.com/%22);%0A        MockHttpServletRequest request = new MockHttpServletRequest();%0A        MockHttpServletResponse response = new MockHttpServletResponse();%0A        lsh.onLogoutSuccess(request, response, mock(Authentication.class));%0A        assertEquals(%22http://someurl.com/%22, response.getRedirectedUrl());%0A    %7D%0A%0A
 %7D%0A

Test to check that absolute URLs work in SimpleUrlLogoutSuccessHandler.