You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "justinmclean (via GitHub)" <gi...@apache.org> on 2025/08/20 06:13:47 UTC

Re: [PR] [Improvement] Support multiple Accept header values in VersioningFilter [gravitino]

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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org