mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 18:28:10 +01:00
refactoring: use constants for header names
This commit is contained in:
@@ -14,13 +14,13 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
class ForwardedIpUtilTest {
|
||||
class HeaderUtilsTest {
|
||||
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
@ParameterizedTest
|
||||
@MethodSource("argumentsForGetMostRecentProxy")
|
||||
void getMostRecentProxy(final String forwardedFor, final Optional<String> expectedMostRecentProxy) {
|
||||
assertEquals(expectedMostRecentProxy, ForwardedIpUtil.getMostRecentProxy(forwardedFor));
|
||||
assertEquals(expectedMostRecentProxy, HeaderUtils.getMostRecentProxy(forwardedFor));
|
||||
}
|
||||
|
||||
private static Stream<Arguments> argumentsForGetMostRecentProxy() {
|
||||
@@ -16,6 +16,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.net.HttpHeaders;
|
||||
import io.dropwizard.jersey.DropwizardResourceConfig;
|
||||
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider;
|
||||
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
|
||||
@@ -83,7 +84,7 @@ class LoggingUnhandledExceptionMapperTest {
|
||||
resources.getJerseyTest()
|
||||
.target(targetPath)
|
||||
.request()
|
||||
.header("User-Agent", userAgentHeader)
|
||||
.header(HttpHeaders.USER_AGENT, userAgentHeader)
|
||||
.get();
|
||||
|
||||
if (expectException) {
|
||||
@@ -140,8 +141,8 @@ class LoggingUnhandledExceptionMapperTest {
|
||||
|
||||
when(session.getUpgradeRequest()).thenReturn(request);
|
||||
when(session.getRemote()).thenReturn(remoteEndpoint);
|
||||
when(request.getHeader("User-Agent")).thenReturn(userAgentHeader);
|
||||
when(request.getHeaders()).thenReturn(Map.of("User-Agent", List.of(userAgentHeader)));
|
||||
when(request.getHeader(HttpHeaders.USER_AGENT)).thenReturn(userAgentHeader);
|
||||
when(request.getHeaders()).thenReturn(Map.of(HttpHeaders.USER_AGENT, List.of(userAgentHeader)));
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user