diff options
author | ArthurHoaro <arthur@hoa.ro> | 2019-07-27 12:30:33 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2019-07-27 12:30:33 +0200 |
commit | 1b8ed48a0d3964186f4d66d443783f4d250e7147 (patch) | |
tree | 23597f312507ba0c1b461755b9aa086106374a4d /tests/http/HttpUtils/ClientIpIdTest.php | |
parent | 1aa24ed8d2974cda98733f74b36844b02942cc11 (diff) | |
parent | ed3365325d231e044dedc32608fde87b1b39fa34 (diff) | |
download | Shaarli-1b8ed48a0d3964186f4d66d443783f4d250e7147.tar.gz Shaarli-1b8ed48a0d3964186f4d66d443783f4d250e7147.tar.zst Shaarli-1b8ed48a0d3964186f4d66d443783f4d250e7147.zip |
Merge tag 'v0.11.0' into latest
Release v0.11.0
Diffstat (limited to 'tests/http/HttpUtils/ClientIpIdTest.php')
-rw-r--r-- | tests/http/HttpUtils/ClientIpIdTest.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/http/HttpUtils/ClientIpIdTest.php b/tests/http/HttpUtils/ClientIpIdTest.php new file mode 100644 index 00000000..982e57e0 --- /dev/null +++ b/tests/http/HttpUtils/ClientIpIdTest.php | |||
@@ -0,0 +1,54 @@ | |||
1 | <?php | ||
2 | /** | ||
3 | * HttpUtils' tests | ||
4 | */ | ||
5 | |||
6 | namespace Shaarli\Http; | ||
7 | |||
8 | require_once 'application/http/HttpUtils.php'; | ||
9 | |||
10 | /** | ||
11 | * Unitary tests for client_ip_id() | ||
12 | */ | ||
13 | class ClientIpIdTest extends \PHPUnit\Framework\TestCase | ||
14 | { | ||
15 | /** | ||
16 | * Get a remote client ID based on its IP | ||
17 | */ | ||
18 | public function testClientIpIdRemote() | ||
19 | { | ||
20 | $this->assertEquals( | ||
21 | '10.1.167.42', | ||
22 | client_ip_id(['REMOTE_ADDR' => '10.1.167.42']) | ||
23 | ); | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * Get a remote client ID based on its IP and proxy information (1) | ||
28 | */ | ||
29 | public function testClientIpIdRemoteForwarded() | ||
30 | { | ||
31 | $this->assertEquals( | ||
32 | '10.1.167.42_127.0.1.47', | ||
33 | client_ip_id([ | ||
34 | 'REMOTE_ADDR' => '10.1.167.42', | ||
35 | 'HTTP_X_FORWARDED_FOR' => '127.0.1.47' | ||
36 | ]) | ||
37 | ); | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * Get a remote client ID based on its IP and proxy information (2) | ||
42 | */ | ||
43 | public function testClientIpIdRemoteForwardedClient() | ||
44 | { | ||
45 | $this->assertEquals( | ||
46 | '10.1.167.42_10.1.167.56_127.0.1.47', | ||
47 | client_ip_id([ | ||
48 | 'REMOTE_ADDR' => '10.1.167.42', | ||
49 | 'HTTP_X_FORWARDED_FOR' => '10.1.167.56', | ||
50 | 'HTTP_CLIENT_IP' => '127.0.1.47' | ||
51 | ]) | ||
52 | ); | ||
53 | } | ||
54 | } | ||