aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/HttpUtils/GetIpAdressFromProxyTest.php
diff options
context:
space:
mode:
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}