diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/headers/HTTPHeaderFiltersTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/headers/HTTPHeaderFiltersTest.java index 4f5bd157e4..b4fd0747fd 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/headers/HTTPHeaderFiltersTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/headers/HTTPHeaderFiltersTest.java @@ -18,6 +18,7 @@ package org.apache.nifi.web.security.headers; import org.apache.nifi.web.security.headers.ContentSecurityPolicyFilter; import org.eclipse.jetty.servlet.FilterHolder; +import org.eclipse.jetty.servlet.ServletHandler; import org.junit.Test; import org.mockito.Mockito; import org.springframework.mock.web.MockHttpServletResponse; @@ -35,7 +36,7 @@ public class HTTPHeaderFiltersTest { public void testCSPHeaderApplied() throws ServletException, IOException, Exception { // Arrange - FilterHolder originFilter = new FilterHolder(new ContentSecurityPolicyFilter()); + FilterHolder cspFilter = new FilterHolder(new ContentSecurityPolicyFilter()); // Set up request HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class); @@ -43,9 +44,10 @@ public class HTTPHeaderFiltersTest { FilterChain mockFilterChain = Mockito.mock(FilterChain.class); // Action - originFilter.start(); - originFilter.initialize(); - originFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); + cspFilter.setServletHandler(new ServletHandler()); + cspFilter.start(); + cspFilter.initialize(); + cspFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); // Verify assertEquals("frame-ancestors 'self'", mockResponse.getHeader("Content-Security-Policy")); @@ -55,7 +57,7 @@ public class HTTPHeaderFiltersTest { public void testCSPHeaderAppliedOnlyOnce() throws ServletException, IOException, Exception { // Arrange - FilterHolder originFilter = new FilterHolder(new ContentSecurityPolicyFilter()); + FilterHolder cspFilter = new FilterHolder(new ContentSecurityPolicyFilter()); // Set up request HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class); @@ -63,10 +65,11 @@ public class HTTPHeaderFiltersTest { FilterChain mockFilterChain = Mockito.mock(FilterChain.class); // Action - originFilter.start(); - originFilter.initialize(); - originFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); - originFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); + cspFilter.setServletHandler(new ServletHandler()); + cspFilter.start(); + cspFilter.initialize(); + cspFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); + cspFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); // Verify assertEquals("frame-ancestors 'self'", mockResponse.getHeader("Content-Security-Policy")); @@ -85,6 +88,7 @@ public class HTTPHeaderFiltersTest { FilterChain mockFilterChain = Mockito.mock(FilterChain.class); // Action + xfoFilter.setServletHandler(new ServletHandler()); xfoFilter.start(); xfoFilter.initialize(); xfoFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); @@ -105,6 +109,7 @@ public class HTTPHeaderFiltersTest { FilterChain mockFilterChain = Mockito.mock(FilterChain.class); // Action + hstsFilter.setServletHandler(new ServletHandler()); hstsFilter.start(); hstsFilter.initialize(); hstsFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); @@ -125,6 +130,7 @@ public class HTTPHeaderFiltersTest { FilterChain mockFilterChain = Mockito.mock(FilterChain.class); // Action + xssFilter.setServletHandler(new ServletHandler()); xssFilter.start(); xssFilter.initialize(); xssFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); @@ -136,16 +142,17 @@ public class HTTPHeaderFiltersTest { @Test public void testXContentTypeOptionsHeaderApplied() throws Exception { // Arrange - FilterHolder xssFilter = new FilterHolder(new XContentTypeOptionsFilter()); + FilterHolder xContentTypeFilter = new FilterHolder(new XContentTypeOptionsFilter()); HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class); MockHttpServletResponse mockResponse = new MockHttpServletResponse(); FilterChain mockFilterChain = Mockito.mock(FilterChain.class); // Action - xssFilter.start(); - xssFilter.initialize(); - xssFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); + xContentTypeFilter.setServletHandler(new ServletHandler()); + xContentTypeFilter.start(); + xContentTypeFilter.initialize(); + xContentTypeFilter.getFilter().doFilter(mockRequest, mockResponse, mockFilterChain); // Verify assertEquals("nosniff", mockResponse.getHeader("X-Content-Type-Options")); diff --git a/pom.xml b/pom.xml index e9983bc64c..516f0ec27e 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ 2014 1.7.30 2.1.0 - 9.4.26.v20200117 + 9.4.34.v20201102 2.9.10 2.9.10.5 0.8.0