Skip to content

Commit

Permalink
test: update test code
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jun 26, 2023
1 parent e9783eb commit 93c507f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
16 changes: 11 additions & 5 deletions tests/system/HTTP/IncomingRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace CodeIgniter\HTTP;

use CodeIgniter\Config\Factories;
use CodeIgniter\Exceptions\ConfigException;
use CodeIgniter\HTTP\Exceptions\HTTPException;
use CodeIgniter\HTTP\Files\UploadedFile;
Expand Down Expand Up @@ -973,7 +974,8 @@ public function testGetIPAddressThruProxy()
'10.0.1.200' => 'X-Forwarded-For',
'192.168.5.0/24' => 'X-Forwarded-For',
];
$this->request = new Request($config);
Factories::injectMock('config', App::class, $config);
$this->request = new Request();
$this->request->populateHeaders();

// we should see the original forwarded address
Expand All @@ -990,7 +992,8 @@ public function testGetIPAddressThruProxyIPv6()
$config->proxyIPs = [
'2001:db8::2:1' => 'X-Forwarded-For',
];
$this->request = new Request($config);
Factories::injectMock('config', App::class, $config);
$this->request = new Request();
$this->request->populateHeaders();

// we should see the original forwarded address
Expand Down Expand Up @@ -1075,7 +1078,8 @@ public function testGetIPAddressThruProxySubnet()

$config = new App();
$config->proxyIPs = ['192.168.5.0/24' => 'X-Forwarded-For'];
$this->request = new Request($config);
Factories::injectMock('config', App::class, $config);
$this->request = new Request();
$this->request->populateHeaders();

// we should see the original forwarded address
Expand All @@ -1090,7 +1094,8 @@ public function testGetIPAddressThruProxySubnetIPv6()

$config = new App();
$config->proxyIPs = ['2001:db8:1234::/48' => 'X-Forwarded-For'];
$this->request = new Request($config);
Factories::injectMock('config', App::class, $config);
$this->request = new Request();
$this->request->populateHeaders();

// we should see the original forwarded address
Expand Down Expand Up @@ -1166,7 +1171,8 @@ public function testGetIPAddressThruProxyInvalidConfigArray()

$config = new App();
$config->proxyIPs = ['192.168.5.0/28'];
$this->request = new Request($config);
Factories::injectMock('config', App::class, $config);
$this->request = new Request();
$this->request->populateHeaders();

$this->request->getIPAddress();
Expand Down
7 changes: 5 additions & 2 deletions tests/system/HTTP/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace CodeIgniter\HTTP;

use CodeIgniter\Config\Factories;
use CodeIgniter\Test\CIUnitTestCase;
use Config\App;

Expand Down Expand Up @@ -616,7 +617,8 @@ public function testGetIPAddressThruProxy()
'10.0.1.200' => 'X-Forwarded-For',
'192.168.5.0/24' => 'X-Forwarded-For',
];
$this->request = new Request($config);
Factories::injectMock('config', App::class, $config);
$this->request = new Request();
$this->request->populateHeaders();

// we should see the original forwarded address
Expand Down Expand Up @@ -667,7 +669,8 @@ public function testGetIPAddressThruProxySubnet()

$config = new App();
$config->proxyIPs = ['192.168.5.0/24' => 'X-Forwarded-For'];
$this->request = new Request($config);
Factories::injectMock('config', App::class, $config);
$this->request = new Request();
$this->request->populateHeaders();

// we should see the original forwarded address
Expand Down

0 comments on commit 93c507f

Please sign in to comment.