justinmclean commented on code in PR #8133:
URL: https://github.com/apache/gravitino/pull/8133#discussion_r2287084371


##########
server/src/test/java/org/apache/gravitino/server/web/TestVersioningFilter.java:
##########
@@ -259,4 +259,18 @@ public void testGetHeaderNames() {
     assertTrue(actualHeaderNames.contains("Header2"));
     assertTrue(actualHeaderNames.contains("CustomHeader"));
   }
+
+  @Test
+  public void testDoFilterWithHeaderContainingValidVersionAsSubstring() throws 
Exception {
+    VersioningFilter filter = new VersioningFilter();
+    FilterChain mockChain = mock(FilterChain.class);
+    HttpServletRequest mockRequest = mock(HttpServletRequest.class);
+    HttpServletResponse mockResponse = mock(HttpServletResponse.class);
+    when(mockRequest.getHeaders("Accept"))
+        .thenReturn(new Vector<>(Collections.singletonList("foo 
application/vnd.gravitino.v1+json bar")).elements());
+
+    filter.doFilter(mockRequest, mockResponse, mockChain);
+    verify(mockChain).doFilter(any(), any());
+    verify(mockResponse).sendError(HttpServletResponse.SC_NOT_ACCEPTABLE, 
"Unsupported version");
+  }
 }

Review Comment:
   This test needs to be improved to verify that the accept header may contain 
multiple comma-separated values, including a valid version number.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to