Skip to content

Commit 285c062

Browse files
kenjisMGatner
authored andcommitted
test: add test cases
1 parent caeb549 commit 285c062

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

tests/system/HTTP/IncomingRequestTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace CodeIgniter\HTTP;
1313

14+
use CodeIgniter\Exceptions\ConfigException;
1415
use CodeIgniter\HTTP\Exceptions\HTTPException;
1516
use CodeIgniter\HTTP\Files\UploadedFile;
1617
use CodeIgniter\Test\CIUnitTestCase;
@@ -793,5 +794,35 @@ public function testGetIPAddressThruProxyOutofSubnet()
793794
$this->assertSame($expected, $this->request->getIPAddress());
794795
}
795796

797+
public function testGetIPAddressThruProxyInvalidConfigString()
798+
{
799+
$this->expectException(ConfigException::class);
800+
$this->expectExceptionMessage(
801+
'You must set an array with Proxy IP address key and HTTP header name value in Config\App::$proxyIPs.'
802+
);
803+
804+
$config = new App();
805+
$config->proxyIPs = '192.168.5.0/28';
806+
$this->request = new Request($config);
807+
$this->request->populateHeaders();
808+
809+
$this->request->getIPAddress();
810+
}
811+
812+
public function testGetIPAddressThruProxyInvalidConfigArray()
813+
{
814+
$this->expectException(ConfigException::class);
815+
$this->expectExceptionMessage(
816+
'You must set an array with Proxy IP address key and HTTP header name value in Config\App::$proxyIPs.'
817+
);
818+
819+
$config = new App();
820+
$config->proxyIPs = ['192.168.5.0/28'];
821+
$this->request = new Request($config);
822+
$this->request->populateHeaders();
823+
824+
$this->request->getIPAddress();
825+
}
826+
796827
// @TODO getIPAddress should have more testing, to 100% code coverage
797828
}

0 commit comments

Comments
 (0)