Package net.petrikainulainen.spring.testmvc.security.authentication

Source Code of net.petrikainulainen.spring.testmvc.security.authentication.RestAuthenticationSuccessHandlerTest

package net.petrikainulainen.spring.testmvc.security.authentication;

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

import javax.servlet.ServletException;
import java.io.IOException;

import static junit.framework.Assert.assertEquals;

/**
* @author Petri Kainulainen
*/
public class RestAuthenticationSuccessHandlerTest {

    private RestAuthenticationSuccessHandler successHandler;

    @Before
    public void setUp() {
        successHandler = new RestAuthenticationSuccessHandler();
    }

    @Test
    public void onAuthenticationSuccess() throws ServletException, IOException {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        Authentication authentication = new UsernamePasswordAuthenticationToken(null, null);

        successHandler.onAuthenticationSuccess(request, response, authentication);

        assertEquals(MockHttpServletResponse.SC_OK, response.getStatus());
    }
}
TOP

Related Classes of net.petrikainulainen.spring.testmvc.security.authentication.RestAuthenticationSuccessHandlerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.