Add non-lowercased auth header to include list (#3078)
This commit is contained in:
@@ -39,6 +39,7 @@ public class KoboServerProxy {
|
|||||||
|
|
||||||
private static final Set<String> HEADERS_OUT_INCLUDE = Set.of(
|
private static final Set<String> HEADERS_OUT_INCLUDE = Set.of(
|
||||||
HttpHeaders.AUTHORIZATION.toLowerCase(),
|
HttpHeaders.AUTHORIZATION.toLowerCase(),
|
||||||
|
HttpHeaders.AUTHORIZATION,
|
||||||
HttpHeaders.USER_AGENT,
|
HttpHeaders.USER_AGENT,
|
||||||
HttpHeaders.ACCEPT,
|
HttpHeaders.ACCEPT,
|
||||||
HttpHeaders.ACCEPT_LANGUAGE
|
HttpHeaders.ACCEPT_LANGUAGE
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import org.junit.jupiter.api.AfterEach;
|
|||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
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.InjectMocks;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
@@ -86,6 +89,23 @@ class KoboServerProxyTest {
|
|||||||
.thenReturn(httpResponse);
|
.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
|
@Test
|
||||||
void proxyCurrentRequest_withSquareBracketsInQueryParams_shouldHandleSuccessfully() throws Exception {
|
void proxyCurrentRequest_withSquareBracketsInQueryParams_shouldHandleSuccessfully() throws Exception {
|
||||||
// Validates fix for: IllegalArgumentException: Invalid character '[' for QUERY_PARAM
|
// Validates fix for: IllegalArgumentException: Invalid character '[' for QUERY_PARAM
|
||||||
|
|||||||
Reference in New Issue
Block a user