11
11
12
12
namespace CodeIgniter \HTTP ;
13
13
14
+ use CodeIgniter \Config \Factories ;
14
15
use CodeIgniter \Exceptions \ConfigException ;
15
16
use CodeIgniter \HTTP \Exceptions \HTTPException ;
16
17
use CodeIgniter \HTTP \Files \UploadedFile ;
@@ -973,7 +974,8 @@ public function testGetIPAddressThruProxy()
973
974
'10.0.1.200 ' => 'X-Forwarded-For ' ,
974
975
'192.168.5.0/24 ' => 'X-Forwarded-For ' ,
975
976
];
976
- $ this ->request = new Request ($ config );
977
+ Factories::injectMock ('config ' , App::class, $ config );
978
+ $ this ->request = new Request ();
977
979
$ this ->request ->populateHeaders ();
978
980
979
981
// we should see the original forwarded address
@@ -990,7 +992,8 @@ public function testGetIPAddressThruProxyIPv6()
990
992
$ config ->proxyIPs = [
991
993
'2001:db8::2:1 ' => 'X-Forwarded-For ' ,
992
994
];
993
- $ this ->request = new Request ($ config );
995
+ Factories::injectMock ('config ' , App::class, $ config );
996
+ $ this ->request = new Request ();
994
997
$ this ->request ->populateHeaders ();
995
998
996
999
// we should see the original forwarded address
@@ -1075,7 +1078,8 @@ public function testGetIPAddressThruProxySubnet()
1075
1078
1076
1079
$ config = new App ();
1077
1080
$ config ->proxyIPs = ['192.168.5.0/24 ' => 'X-Forwarded-For ' ];
1078
- $ this ->request = new Request ($ config );
1081
+ Factories::injectMock ('config ' , App::class, $ config );
1082
+ $ this ->request = new Request ();
1079
1083
$ this ->request ->populateHeaders ();
1080
1084
1081
1085
// we should see the original forwarded address
@@ -1090,7 +1094,8 @@ public function testGetIPAddressThruProxySubnetIPv6()
1090
1094
1091
1095
$ config = new App ();
1092
1096
$ config ->proxyIPs = ['2001:db8:1234::/48 ' => 'X-Forwarded-For ' ];
1093
- $ this ->request = new Request ($ config );
1097
+ Factories::injectMock ('config ' , App::class, $ config );
1098
+ $ this ->request = new Request ();
1094
1099
$ this ->request ->populateHeaders ();
1095
1100
1096
1101
// we should see the original forwarded address
@@ -1166,7 +1171,8 @@ public function testGetIPAddressThruProxyInvalidConfigArray()
1166
1171
1167
1172
$ config = new App ();
1168
1173
$ config ->proxyIPs = ['192.168.5.0/28 ' ];
1169
- $ this ->request = new Request ($ config );
1174
+ Factories::injectMock ('config ' , App::class, $ config );
1175
+ $ this ->request = new Request ();
1170
1176
$ this ->request ->populateHeaders ();
1171
1177
1172
1178
$ this ->request ->getIPAddress ();
0 commit comments