aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/HttpUtils/GetIpAdressFromProxyTest.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2018-12-03 00:34:53 +0100
committerVirtualTam <virtualtam@flibidi.net>2019-01-12 22:47:48 +0100
commit51753e403fa69c0ce124ede27d300477e3e799ca (patch)
tree0afe2a84598648b49cc53bb3e8640569ac370240 /tests/HttpUtils/GetIpAdressFromProxyTest.php
parentfb1b182fbf0ee5afed586f77eec84d7a906831ef (diff)
downloadShaarli-51753e403fa69c0ce124ede27d300477e3e799ca.tar.gz
Shaarli-51753e403fa69c0ce124ede27d300477e3e799ca.tar.zst
Shaarli-51753e403fa69c0ce124ede27d300477e3e799ca.zip
namespacing: move HTTP utilities along \Shaarli\Http\ classes
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'tests/HttpUtils/GetIpAdressFromProxyTest.php')
-rw-r--r--tests/HttpUtils/GetIpAdressFromProxyTest.php59
1 files changed, 0 insertions, 59 deletions
diff --git a/tests/HttpUtils/GetIpAdressFromProxyTest.php b/tests/HttpUtils/GetIpAdressFromProxyTest.php
deleted file mode 100644
index 7af5bd9d..00000000
--- a/tests/HttpUtils/GetIpAdressFromProxyTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
1<?php
2
3require_once 'application/HttpUtils.php';
4
5/**
6 * Unitary tests for getIpAddressFromProxy()
7 */
8class GetIpAdressFromProxyTest extends PHPUnit_Framework_TestCase
9{
10
11 /**
12 * Test without proxy
13 */
14 public function testWithoutProxy()
15 {
16 $this->assertFalse(getIpAddressFromProxy(array(), array()));
17 }
18
19 /**
20 * Test with a single IP in proxy header.
21 */
22 public function testWithOneForwardedIp()
23 {
24 $ip = '1.1.1.1';
25 $server = array('HTTP_X_FORWARDED_FOR' => $ip);
26 $this->assertEquals($ip, getIpAddressFromProxy($server, array()));
27 }
28
29 /**
30 * Test with a multiple IPs in proxy header.
31 */
32 public function testWithMultipleForwardedIp()
33 {
34 $ip = '1.1.1.1';
35 $ip2 = '2.2.2.2';
36
37 $server = array('HTTP_X_FORWARDED_FOR' => $ip .','. $ip2);
38 $this->assertEquals($ip2, getIpAddressFromProxy($server, array()));
39
40 $server = array('HTTP_X_FORWARDED_FOR' => $ip .' , '. $ip2);
41 $this->assertEquals($ip2, getIpAddressFromProxy($server, array()));
42 }
43
44 /**
45 * Test with a trusted IP address.
46 */
47 public function testWithTrustedIp()
48 {
49 $ip = '1.1.1.1';
50 $ip2 = '2.2.2.2';
51
52 $server = array('HTTP_X_FORWARDED_FOR' => $ip);
53 $this->assertFalse(getIpAddressFromProxy($server, array($ip)));
54
55 $server = array('HTTP_X_FORWARDED_FOR' => $ip .','. $ip2);
56 $this->assertEquals($ip2, getIpAddressFromProxy($server, array($ip)));
57 $this->assertFalse(getIpAddressFromProxy($server, array($ip, $ip2)));
58 }
59}