Skip to content

Commit

Permalink
Test for X-Forwarded-For
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Apr 24, 2015
1 parent 154b7e6 commit 976f84e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/Cubex/Http/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,19 @@ public function testReferrer()
$request->initialize([], [], [], [], [], $server);
$this->assertEquals('http://www.cubex.io', $request->referrer());
}

public function testXForwardedFor()
{
//http://en.wikipedia.org/wiki/X-Forwarded-For#Format
$request = new Request();
//8.8.8.8 = client IP
//4.4.4.4 = proxy1
$server = [
'HTTP_X_FORWARDED_FOR' => '8.8.8.8, 4.4.4.4',
'REMOTE_ADDR' => '8.8.4.4',
];
$request->initialize([], [], [], [], [], $server);
$request->setTrustedProxies(['8.8.4.4']);
$this->assertEquals('8.8.8.8', $request->getClientIp());
}
}

0 comments on commit 976f84e

Please sign in to comment.