Add non-lowercased auth header to include list (#3078)

This commit is contained in:
Karl Hesselgren
2026-02-27 09:19:04 -07:00
committed by GitHub
parent 0609c0dd28
commit a37cc1d8a3
2 changed files with 21 additions and 0 deletions
@@ -39,6 +39,7 @@ public class KoboServerProxy {
private static final Set<String> HEADERS_OUT_INCLUDE = Set.of(
HttpHeaders.AUTHORIZATION.toLowerCase(),
HttpHeaders.AUTHORIZATION,
HttpHeaders.USER_AGENT,
HttpHeaders.ACCEPT,
HttpHeaders.ACCEPT_LANGUAGE
@@ -7,6 +7,9 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
@@ -86,6 +89,23 @@ class KoboServerProxyTest {
.thenReturn(httpResponse);
}
@ParameterizedTest
@ValueSource(strings = { "Authorization", "authorization" })
void proxyCurrentRequest_withSquareBracketsInQueryParams_shouldIncludeAuthHeaders(String authHeader) throws Exception {
mockRequest.setQueryString("Filter=ALL");
mockRequest.addHeader("User-Agent", "Kobo/1.0");
mockRequest.addHeader(authHeader, "jwt.looking.token");
setupSuccessfulProxyResponse();
ResponseEntity<JsonNode> response = koboServerProxy.proxyCurrentRequest(null, false);
assertThat(response).isNotNull();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
ArgumentCaptor<HttpRequest> captor = ArgumentCaptor.forClass(HttpRequest.class);
verify(httpClient).<String>send(captor.capture(), any());
assertThat(captor.getValue().headers().map().get(authHeader)).isNotNull();
}
@Test
void proxyCurrentRequest_withSquareBracketsInQueryParams_shouldHandleSuccessfully() throws Exception {
// Validates fix for: IllegalArgumentException: Invalid character '[' for QUERY_PARAM