Skip to content
Snippets Groups Projects
Commit 4cc2db72 authored by Alok Joshi's avatar Alok Joshi
Browse files

fix condition

parent c7eb338e
No related branches found
No related tags found
2 merge requests!744Upgraded packages to mitigated vulns in netty, guava, snakeyaml,!626Bypass info and swagger apis in collaboration filter
Pipeline #167459 passed with warnings
......@@ -61,7 +61,7 @@ public class CollaborationFilter implements Filter {
private boolean isExcludedPath(HttpServletRequest request) {
String path = request.getRequestURI().substring(request.getContextPath().length() + 1);
return excludedPaths.contains(path);
return excludedPaths.stream().anyMatch(path::contains);
}
}
......@@ -71,26 +71,34 @@ public class CollaborationFilterTest {
}
@Test
public void shouldSkipFilter_ifUrlContainsHealthEndpoint() {
public void shouldSkipFilter_ifUrlContainsHealthEndpoint() throws IOException, ServletException {
when(httpServletRequest.getRequestURI()).thenReturn("https://my-service-url/api/storage/v2/health");
when(httpServletRequest.getContextPath()).thenReturn("/api/storage/v2/");
collaborationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
verify(iCollaborationFeatureFlag, never()).isFeatureEnabled(FEATURE_NAME);
}
@Test
public void shouldSkipFilter_ifUrlContainsInfoEndpoint() {
public void shouldSkipFilter_ifUrlContainsInfoEndpoint() throws IOException, ServletException {
when(httpServletRequest.getRequestURI()).thenReturn("https://my-service-url/api/storage/v2/info");
when(httpServletRequest.getContextPath()).thenReturn("/api/storage/v2/");
collaborationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
verify(iCollaborationFeatureFlag, never()).isFeatureEnabled(FEATURE_NAME);
}
@Test
public void shouldSkipFilter_ifUrlContainsSwaggerEndpoint() {
public void shouldSkipFilter_ifUrlContainsSwaggerEndpoint() throws IOException, ServletException {
when(httpServletRequest.getRequestURI()).thenReturn("https://my-service-url/api/storage/v2/swagger-ui/index.html");
when(httpServletRequest.getContextPath()).thenReturn("/api/storage/v2/");
collaborationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
verify(iCollaborationFeatureFlag, never()).isFeatureEnabled(FEATURE_NAME);
}
@Test
public void shouldSkipFilter_ifUrlContainsApiDocsEndpoint() {
public void shouldSkipFilter_ifUrlContainsApiDocsEndpoint() throws IOException, ServletException {
when(httpServletRequest.getRequestURI()).thenReturn("https://my-service-url/api/storage/v2/v3/api-docs");
when(httpServletRequest.getContextPath()).thenReturn("/api/storage/v2/");
collaborationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
verify(iCollaborationFeatureFlag, never()).isFeatureEnabled(FEATURE_NAME);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment