Search in sources :

Example 86 with FilterConfig

use of javax.servlet.FilterConfig in project OpenAM by OpenRock.

the class AMSetupFilterTest method initializeFilter.

private void initializeFilter() throws ServletException {
    FilterConfig config = mock(FilterConfig.class);
    ServletContext context = mock(ServletContext.class);
    given(config.getServletContext()).willReturn(context);
    setupFilter.init(config);
}
Also used : ServletContext(javax.servlet.ServletContext) FilterConfig(javax.servlet.FilterConfig)

Example 87 with FilterConfig

use of javax.servlet.FilterConfig in project OpenAM by OpenRock.

the class AMSetupFilterTest method initShouldSetEncryptionPasswordIfNotConfigured.

@Test
public void initShouldSetEncryptionPasswordIfNotConfigured() throws Exception {
    //Given
    FilterConfig config = mock(FilterConfig.class);
    ServletContext context = mock(ServletContext.class);
    given(config.getServletContext()).willReturn(context);
    systemIsNotConfigured();
    //When
    setupFilter.init(config);
    //Then
    verify(context).setAttribute(eq("am.enc.pwd"), anyString());
}
Also used : ServletContext(javax.servlet.ServletContext) FilterConfig(javax.servlet.FilterConfig) Test(org.testng.annotations.Test)

Example 88 with FilterConfig

use of javax.servlet.FilterConfig in project gerrit by GerritCodeReview.

the class AllRequestFilterFilterProxyTest method noFilters.

@Test
public void noFilters() throws Exception {
    EasyMockSupport ems = new EasyMockSupport();
    FilterConfig config = ems.createMock(FilterConfig.class);
    HttpServletRequest req = new FakeHttpServletRequest();
    HttpServletResponse res = new FakeHttpServletResponse();
    FilterChain chain = ems.createMock(FilterChain.class);
    chain.doFilter(req, res);
    ems.replayAll();
    AllRequestFilter.FilterProxy filterProxy = getFilterProxy();
    filterProxy.init(config);
    filterProxy.doFilter(req, res, chain);
    filterProxy.destroy();
    ems.verifyAll();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) FakeHttpServletRequest(com.google.gerrit.util.http.testutil.FakeHttpServletRequest) EasyMockSupport(org.easymock.EasyMockSupport) FakeHttpServletRequest(com.google.gerrit.util.http.testutil.FakeHttpServletRequest) FakeHttpServletResponse(com.google.gerrit.util.http.testutil.FakeHttpServletResponse) FilterChain(javax.servlet.FilterChain) FakeHttpServletResponse(com.google.gerrit.util.http.testutil.FakeHttpServletResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) FilterConfig(javax.servlet.FilterConfig) Test(org.junit.Test)

Example 89 with FilterConfig

use of javax.servlet.FilterConfig in project gerrit by GerritCodeReview.

the class AllRequestFilterFilterProxyTest method twoFiltersNoBubbling.

@Test
public void twoFiltersNoBubbling() throws Exception {
    EasyMockSupport ems = new EasyMockSupport();
    FilterConfig config = ems.createMock(FilterConfig.class);
    HttpServletRequest req = new FakeHttpServletRequest();
    HttpServletResponse res = new FakeHttpServletResponse();
    IMocksControl mockControl = ems.createStrictControl();
    FilterChain chain = mockControl.createMock(FilterChain.class);
    AllRequestFilter filterA = mockControl.createMock(AllRequestFilter.class);
    AllRequestFilter filterB = mockControl.createMock(AllRequestFilter.class);
    filterA.init(config);
    filterB.init(config);
    filterA.doFilter(eq(req), eq(res), anyObject(FilterChain.class));
    filterA.destroy();
    filterB.destroy();
    ems.replayAll();
    AllRequestFilter.FilterProxy filterProxy = getFilterProxy();
    addFilter(filterA);
    addFilter(filterB);
    filterProxy.init(config);
    filterProxy.doFilter(req, res, chain);
    filterProxy.destroy();
    ems.verifyAll();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) FakeHttpServletRequest(com.google.gerrit.util.http.testutil.FakeHttpServletRequest) IMocksControl(org.easymock.IMocksControl) EasyMockSupport(org.easymock.EasyMockSupport) FakeHttpServletRequest(com.google.gerrit.util.http.testutil.FakeHttpServletRequest) FakeHttpServletResponse(com.google.gerrit.util.http.testutil.FakeHttpServletResponse) FilterChain(javax.servlet.FilterChain) FakeHttpServletResponse(com.google.gerrit.util.http.testutil.FakeHttpServletResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) FilterConfig(javax.servlet.FilterConfig) Test(org.junit.Test)

Example 90 with FilterConfig

use of javax.servlet.FilterConfig in project gerrit by GerritCodeReview.

the class AllRequestFilterFilterProxyTest method singleFilterNoBubbling.

@Test
public void singleFilterNoBubbling() throws Exception {
    EasyMockSupport ems = new EasyMockSupport();
    FilterConfig config = ems.createMock("config", FilterConfig.class);
    HttpServletRequest req = new FakeHttpServletRequest();
    HttpServletResponse res = new FakeHttpServletResponse();
    FilterChain chain = ems.createMock("chain", FilterChain.class);
    AllRequestFilter filter = ems.createStrictMock("filter", AllRequestFilter.class);
    filter.init(config);
    filter.doFilter(eq(req), eq(res), anyObject(FilterChain.class));
    filter.destroy();
    ems.replayAll();
    AllRequestFilter.FilterProxy filterProxy = getFilterProxy();
    addFilter(filter);
    filterProxy.init(config);
    filterProxy.doFilter(req, res, chain);
    filterProxy.destroy();
    ems.verifyAll();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) FakeHttpServletRequest(com.google.gerrit.util.http.testutil.FakeHttpServletRequest) EasyMockSupport(org.easymock.EasyMockSupport) FakeHttpServletRequest(com.google.gerrit.util.http.testutil.FakeHttpServletRequest) FakeHttpServletResponse(com.google.gerrit.util.http.testutil.FakeHttpServletResponse) FilterChain(javax.servlet.FilterChain) FakeHttpServletResponse(com.google.gerrit.util.http.testutil.FakeHttpServletResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) FilterConfig(javax.servlet.FilterConfig) Test(org.junit.Test)

Aggregations

FilterConfig (javax.servlet.FilterConfig)118 Test (org.junit.Test)70 HttpServletRequest (javax.servlet.http.HttpServletRequest)64 FilterChain (javax.servlet.FilterChain)63 HttpServletResponse (javax.servlet.http.HttpServletResponse)50 ServletContext (javax.servlet.ServletContext)28 HashMap (java.util.HashMap)21 ServletException (javax.servlet.ServletException)21 Vector (java.util.Vector)17 Properties (java.util.Properties)15 Filter (javax.servlet.Filter)14 ServletResponse (javax.servlet.ServletResponse)14 ServletRequest (javax.servlet.ServletRequest)12 IOException (java.io.IOException)10 SignerSecretProvider (org.apache.hadoop.security.authentication.util.SignerSecretProvider)10 HttpCookie (java.net.HttpCookie)9 Cookie (javax.servlet.http.Cookie)9 Signer (org.apache.hadoop.security.authentication.util.Signer)9 Enumeration (java.util.Enumeration)8 CrossOriginFilter (org.apache.hadoop.security.http.CrossOriginFilter)8