Search in sources :

Example 36 with FilterConfig

use of javax.servlet.FilterConfig in project sonarqube by SonarSource.

the class MasterServletFilterTest method filters_should_be_optional.

@Test
public void filters_should_be_optional() throws Exception {
    FilterConfig config = mock(FilterConfig.class);
    MasterServletFilter filters = new MasterServletFilter();
    filters.init(config, Collections.emptyList());
    ServletRequest request = mock(HttpServletRequest.class);
    ServletResponse response = mock(HttpServletResponse.class);
    FilterChain chain = mock(FilterChain.class);
    filters.doFilter(request, response, chain);
    verify(chain).doFilter(request, response);
}
Also used : ServletRequest(javax.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletResponse(javax.servlet.ServletResponse) FilterChain(javax.servlet.FilterChain) FilterConfig(javax.servlet.FilterConfig) Test(org.junit.Test)

Example 37 with FilterConfig

use of javax.servlet.FilterConfig in project sonarqube by SonarSource.

the class RootFilterTest method initialize.

@Before
public void initialize() throws Exception {
    FilterConfig filterConfig = mock(FilterConfig.class);
    ServletContext context = mock(ServletContext.class);
    when(context.getContextPath()).thenReturn("/context");
    when(filterConfig.getServletContext()).thenReturn(context);
    chain = mock(FilterChain.class);
    filter = new RootFilter();
    filter.init(filterConfig);
}
Also used : FilterChain(javax.servlet.FilterChain) ServletContext(javax.servlet.ServletContext) FilterConfig(javax.servlet.FilterConfig) Before(org.junit.Before)

Example 38 with FilterConfig

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

the class XUIFilterTest method setUp.

@BeforeMethod
public void setUp() {
    XUIState xuiState = mock(XUIState.class);
    when(xuiState.isXUIEnabled()).thenReturn(true);
    filter = new XUIFilter(xuiState);
    FilterConfig filterConfig = mock(FilterConfig.class);
    ServletContext servletContext = mock(ServletContext.class);
    when(filterConfig.getServletContext()).thenReturn(servletContext);
    when(servletContext.getContextPath()).thenReturn(CONTEXT);
    filter.init(filterConfig);
}
Also used : ServletContext(javax.servlet.ServletContext) FilterConfig(javax.servlet.FilterConfig) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 39 with FilterConfig

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

the class CORSFilterTest method shouldThrowExceptionWhenMaxAgeIsNaN.

@Test(expectedExceptions = ServletException.class)
public void shouldThrowExceptionWhenMaxAgeIsNaN() throws ServletException {
    //given
    FilterConfig config = mock(FilterConfig.class);
    given(config.getInitParameter(CORSConstants.ORIGINS_KEY)).willReturn("www.google.com");
    given(config.getInitParameter(CORSConstants.METHODS_KEY)).willReturn("GET,POST");
    given(config.getInitParameter(CORSConstants.MAX_AGE_KEY)).willReturn("words");
    //when
    testFilter.init(config);
//then
}
Also used : FilterConfig(javax.servlet.FilterConfig) Test(org.testng.annotations.Test)

Example 40 with FilterConfig

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

the class AMSetupFilterTest method initShouldNotSetEncryptionPasswordIfConfigured.

@Test
public void initShouldNotSetEncryptionPasswordIfConfigured() throws Exception {
    //Given
    FilterConfig config = mock(FilterConfig.class);
    ServletContext context = mock(ServletContext.class);
    given(config.getServletContext()).willReturn(context);
    systemIsConfigured();
    //When
    setupFilter.init(config);
    //Then
    verifyZeroInteractions(context);
}
Also used : ServletContext(javax.servlet.ServletContext) FilterConfig(javax.servlet.FilterConfig) Test(org.testng.annotations.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