Search in sources :

Example 6 with ProxyFilterChain

use of org.codice.ddf.security.handler.cas.filter.ProxyFilterChain in project ddf by codice.

the class CasHandlerTest method testNoPrincipalResolve.

/**
     * Tests that the handler properly returns a REDIRECTED result if the assertion is not in the
     * session and resolve is true.
     *
     * @throws ServletException
     * @throws IOException
     */
@Test
public void testNoPrincipalResolve() throws ServletException, IOException {
    CasHandler handler = createHandler();
    Filter testFilter = mock(Filter.class);
    handler.setProxyFilter(new ProxyFilter(Arrays.asList(testFilter)));
    HandlerResult result = handler.getNormalizedToken(createServletRequest(false), mock(HttpServletResponse.class), new ProxyFilterChain(null), true);
    assertEquals(HandlerResult.Status.REDIRECTED, result.getStatus());
    // verify that the filter was called once
    verify(testFilter).doFilter(any(ServletRequest.class), any(ServletResponse.class), any(FilterChain.class));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletResponse(javax.servlet.ServletResponse) ProxyFilter(org.codice.ddf.security.handler.cas.filter.ProxyFilter) AbstractCasFilter(org.jasig.cas.client.util.AbstractCasFilter) Filter(javax.servlet.Filter) ProxyFilter(org.codice.ddf.security.handler.cas.filter.ProxyFilter) FilterChain(javax.servlet.FilterChain) ProxyFilterChain(org.codice.ddf.security.handler.cas.filter.ProxyFilterChain) HttpServletResponse(javax.servlet.http.HttpServletResponse) HandlerResult(org.codice.ddf.security.handler.api.HandlerResult) ProxyFilterChain(org.codice.ddf.security.handler.cas.filter.ProxyFilterChain) Test(org.junit.Test)

Aggregations

HandlerResult (org.codice.ddf.security.handler.api.HandlerResult)6 ProxyFilterChain (org.codice.ddf.security.handler.cas.filter.ProxyFilterChain)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 Test (org.junit.Test)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 IOException (java.io.IOException)1 Filter (javax.servlet.Filter)1 FilterChain (javax.servlet.FilterChain)1 ServletException (javax.servlet.ServletException)1 ServletRequest (javax.servlet.ServletRequest)1 ServletResponse (javax.servlet.ServletResponse)1 HttpSession (javax.servlet.http.HttpSession)1 ProxyFilter (org.codice.ddf.security.handler.cas.filter.ProxyFilter)1 AbstractCasFilter (org.jasig.cas.client.util.AbstractCasFilter)1 Assertion (org.jasig.cas.client.validation.Assertion)1