@@ -613,6 +613,7 @@ public function testGetIPAddressThruProxy()
613
613
$ config ->proxyIPs = '10.0.1.200,192.168.5.0/24 ' ;
614
614
$ _SERVER ['HTTP_X_FORWARDED_FOR ' ] = $ expected ;
615
615
$ this ->request = new Request ($ config );
616
+ $ this ->request ->populateHeaders ();
616
617
617
618
// we should see the original forwarded address
618
619
$ this ->assertSame ($ expected , $ this ->request ->getIPAddress ());
@@ -626,6 +627,7 @@ public function testGetIPAddressThruProxyInvalid()
626
627
$ config ->proxyIPs = '10.0.1.200,192.168.5.0/24 ' ;
627
628
$ _SERVER ['HTTP_X_FORWARDED_FOR ' ] = $ expected ;
628
629
$ this ->request = new Request ($ config );
630
+ $ this ->request ->populateHeaders ();
629
631
630
632
// spoofed address invalid
631
633
$ this ->assertSame ('10.0.1.200 ' , $ this ->request ->getIPAddress ());
@@ -639,6 +641,7 @@ public function testGetIPAddressThruProxyNotWhitelisted()
639
641
$ config ->proxyIPs = '10.0.1.200,192.168.5.0/24 ' ;
640
642
$ _SERVER ['HTTP_X_FORWARDED_FOR ' ] = $ expected ;
641
643
$ this ->request = new Request ($ config );
644
+ $ this ->request ->populateHeaders ();
642
645
643
646
// spoofed address invalid
644
647
$ this ->assertSame ('10.10.1.200 ' , $ this ->request ->getIPAddress ());
@@ -652,6 +655,7 @@ public function testGetIPAddressThruProxySubnet()
652
655
$ config ->proxyIPs = ['192.168.5.0/24 ' ];
653
656
$ _SERVER ['HTTP_X_FORWARDED_FOR ' ] = $ expected ;
654
657
$ this ->request = new Request ($ config );
658
+ $ this ->request ->populateHeaders ();
655
659
656
660
// we should see the original forwarded address
657
661
$ this ->assertSame ($ expected , $ this ->request ->getIPAddress ());
@@ -665,6 +669,7 @@ public function testGetIPAddressThruProxyOutofSubnet()
665
669
$ config ->proxyIPs = ['192.168.5.0/28 ' ];
666
670
$ _SERVER ['HTTP_X_FORWARDED_FOR ' ] = $ expected ;
667
671
$ this ->request = new Request ($ config );
672
+ $ this ->request ->populateHeaders ();
668
673
669
674
// we should see the original forwarded address
670
675
$ this ->assertSame ('192.168.5.21 ' , $ this ->request ->getIPAddress ());
0 commit comments