@Test public void shouldNotWhiteListRequestNotMatchingUri() { FilterDirector myDirector = new FilterDirectorImpl(); when(request.getRequestURI()).thenReturn(requestUri2); when(request.getMethod()).thenReturn("DELETE"); myDirector = handler.handleRequest(request, null); assertTrue(myDirector.requestHeaderManager().headersToRemove().isEmpty()); }
/** Test of handleRequest method, of class HeaderNormalizationHandler. */ @Test public void shouldWhiteListRequestsMatchingUriAndMethod() { FilterDirector myDirector = new FilterDirectorImpl(); when(request.getRequestURI()).thenReturn(requestUri1); when(request.getMethod()).thenReturn("GET"); myDirector = handler.handleRequest(request, null); assertFalse(myDirector.requestHeaderManager().headersToRemove().isEmpty()); assertFalse(myDirector.requestHeaderManager().headersToRemove().contains("X-Group-Header")); assertEquals( "Filter Director should be set to remove 2 headers", myDirector.requestHeaderManager().headersToRemove().size(), 2); }
/** Test of handleRequest method, of class HeaderNormalizationHandler. */ @Test public void shouldWhiteListRequestsWithCatchAllUri() { FilterDirector myDirector = new FilterDirectorImpl(); when(request.getRequestURI()).thenReturn(requestUri1); when(request.getMethod()).thenReturn("GET"); myDirector = handler.handleRequest(request, null); assertFalse( "Filter Director should be set to remove headers", myDirector.requestHeaderManager().headersToRemove().isEmpty()); assertTrue( "Filter Director should be set to remove the 'X-Auth-Token'", myDirector.requestHeaderManager().headersToRemove().contains("x-auth-token")); assertEquals( "Filter Director should be set to remove 4 headers", myDirector.requestHeaderManager().headersToRemove().size(), 4); }