aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar/helper/ServletHelperTest.java
diff options
context:
space:
mode:
authorYuriy Piskarev <yuriy.piskarev@gmail.com>2023-08-24 14:16:17 +0300
committerGitHub <noreply@github.com>2023-08-24 14:16:17 +0300
commitae406c7b49a72de24d81fd74386d9638342c90ee (patch)
tree6fbcf557375b98e926c78af9c757e62c79d72a1b /src/test/java/org/traccar/helper/ServletHelperTest.java
parent56ff656c908b19feb2fa3dcffa48cc3bcdfe9b3b (diff)
parent9aeedc90da24848ff97227d6f281eb4d1e1506ef (diff)
downloadtrackermap-server-ae406c7b49a72de24d81fd74386d9638342c90ee.tar.gz
trackermap-server-ae406c7b49a72de24d81fd74386d9638342c90ee.tar.bz2
trackermap-server-ae406c7b49a72de24d81fd74386d9638342c90ee.zip
Merge branch 'traccar:master' into master
Diffstat (limited to 'src/test/java/org/traccar/helper/ServletHelperTest.java')
-rw-r--r--src/test/java/org/traccar/helper/ServletHelperTest.java65
1 files changed, 0 insertions, 65 deletions
diff --git a/src/test/java/org/traccar/helper/ServletHelperTest.java b/src/test/java/org/traccar/helper/ServletHelperTest.java
deleted file mode 100644
index e419b6491..000000000
--- a/src/test/java/org/traccar/helper/ServletHelperTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.traccar.helper;
-
-import org.apache.struts.mock.MockHttpServletRequest;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-
-public class ServletHelperTest {
-
- @Test
- 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");
-
- assertEquals("231.23.45.65", ServletHelper.retrieveRemoteAddress(request));
- }
-
- @Test
- 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");
-
- assertEquals("231.23.45.65", ServletHelper.retrieveRemoteAddress(request));
- }
-
- private final static class MockRequest extends MockHttpServletRequest {
-
- private String remoteAddress;
-
- private Map<String, String> headers = new HashMap<>();
-
- public void setRemoteAddress(String remoteAddress) {
- this.remoteAddress = remoteAddress;
- }
-
- public void addHeader(String name, String value) {
- headers.put(name, value);
- }
-
- @Override
- public String getHeader(String name) {
- return headers.get(name);
- }
-
- @Override
- public String getRemoteAddr() {
- return remoteAddress;
- }
-
- }
-
-}