Skip to content

Commit

Permalink
refactor: #5236 test code
Browse files Browse the repository at this point in the history
  • Loading branch information
larry4xie committed Oct 6, 2024
1 parent acad9b7 commit ff75da3
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ public void testAuthorizedSuccessfully() throws Exception {

clientAuthenticationFilter.doFilter(request, response, filterChain);

verify(response, never()).sendError(HttpServletResponse.SC_BAD_REQUEST, "InvalidAppId");
verify(response, never()).sendError(HttpServletResponse.SC_UNAUTHORIZED, "RequestTimeTooSkewed");
verify(response, never()).sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
verify(filterChain, times(1)).doFilter(request, response);
verifySuccessAndDoFilter();
}

@Test
Expand All @@ -168,10 +165,7 @@ public void testPreCheckInvalid() throws Exception {

clientAuthenticationFilter.doFilter(request, response, filterChain);

verify(response, never()).sendError(HttpServletResponse.SC_BAD_REQUEST, "InvalidAppId");
verify(response, never()).sendError(HttpServletResponse.SC_UNAUTHORIZED, "RequestTimeTooSkewed");
verify(response, never()).sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
verify(filterChain, times(1)).doFilter(request, response);
verifySuccessAndDoFilter();
verify(clientAuthenticationFilter, times(2)).preCheckInvalidLogging(anyString());
}

Expand All @@ -193,10 +187,14 @@ public void testPreCheckSuccessfully() throws Exception {

clientAuthenticationFilter.doFilter(request, response, filterChain);

verifySuccessAndDoFilter();
verify(clientAuthenticationFilter, never()).preCheckInvalidLogging(anyString());
}

private void verifySuccessAndDoFilter() throws Exception {
verify(response, never()).sendError(HttpServletResponse.SC_BAD_REQUEST, "InvalidAppId");
verify(response, never()).sendError(HttpServletResponse.SC_UNAUTHORIZED, "RequestTimeTooSkewed");
verify(response, never()).sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
verify(filterChain, times(1)).doFilter(request, response);
verify(clientAuthenticationFilter, never()).preCheckInvalidLogging(anyString());
}
}

0 comments on commit ff75da3

Please sign in to comment.