Skip to content

Commit 374486a

Browse files
kenjisMGatner
authored andcommitted
test: add test
1 parent 511b283 commit 374486a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/system/HTTP/IncomingRequestTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,24 @@ public function testGetIPAddressThruProxyOutOfSubnetIPv6()
875875
$this->assertSame($expected, $this->request->getIPAddress());
876876
}
877877

878+
public function testGetIPAddressThruProxyBothIPv4AndIPv6()
879+
{
880+
$expected = '2001:db8:1235:ffff:ffff:ffff:ffff:ffff';
881+
$_SERVER['REMOTE_ADDR'] = $expected;
882+
$_SERVER['HTTP_X_FORWARDED_FOR'] = '123.123.123.123';
883+
884+
$config = new App();
885+
$config->proxyIPs = [
886+
'192.168.5.0/28' => 'X-Forwarded-For',
887+
'2001:db8:1234::/48' => 'X-Forwarded-For',
888+
];
889+
$this->request = new Request($config);
890+
$this->request->populateHeaders();
891+
892+
// we should see the original forwarded address
893+
$this->assertSame($expected, $this->request->getIPAddress());
894+
}
895+
878896
public function testGetIPAddressThruProxyInvalidConfigString()
879897
{
880898
$this->expectException(ConfigException::class);

0 commit comments

Comments
 (0)