From 1117d4abe4fe3545f9169b05269363c9655061b1 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 23 Jan 2020 08:49:30 -0800 Subject: Fix logging issue (fix #4473) --- src/test/java/org/traccar/helper/ServletHelperTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/test/java/org/traccar') diff --git a/src/test/java/org/traccar/helper/ServletHelperTest.java b/src/test/java/org/traccar/helper/ServletHelperTest.java index 7359bf3dd..e419b6491 100644 --- a/src/test/java/org/traccar/helper/ServletHelperTest.java +++ b/src/test/java/org/traccar/helper/ServletHelperTest.java @@ -11,7 +11,7 @@ import static org.junit.Assert.assertEquals; public class ServletHelperTest { @Test - public void testIpBehindReverseProxy() { + public void testRetrieveRemoteAddressProxyMultiple() { MockRequest request = new MockRequest(); request.setRemoteAddress("147.120.1.5"); request.addHeader("X-FORWARDED-FOR", "231.23.45.65, 10.20.10.33, 10.20.20.34"); @@ -20,7 +20,16 @@ public class ServletHelperTest { } @Test - public void testNormalIp() { + public void testRetrieveRemoteAddressProxySingle() { + MockRequest request = new MockRequest(); + request.setRemoteAddress("147.120.1.5"); + request.addHeader("X-FORWARDED-FOR", "231.23.45.65"); + + assertEquals("231.23.45.65", ServletHelper.retrieveRemoteAddress(request)); + } + + @Test + public void testRetrieveRemoteAddressNoProxy() { MockRequest request = new MockRequest(); request.setRemoteAddress("231.23.45.65"); -- cgit v1.2.3