@@ -701,6 +701,8 @@ public function testGetIPAddressNormal()
701701 $ expected = '123.123.123.123 ' ;
702702 $ _SERVER ['REMOTE_ADDR ' ] = $ expected ;
703703 $ this ->request = new Request (new App ());
704+ $ this ->request ->populateHeaders ();
705+
704706 $ this ->assertSame ($ expected , $ this ->request ->getIPAddress ());
705707 // call a second time to exercise the initial conditional block in getIPAddress()
706708 $ this ->assertSame ($ expected , $ this ->request ->getIPAddress ());
@@ -714,6 +716,7 @@ public function testGetIPAddressThruProxy()
714716 $ config ->proxyIPs = '10.0.1.200,192.168.5.0/24 ' ;
715717 $ _SERVER ['HTTP_X_FORWARDED_FOR ' ] = $ expected ;
716718 $ this ->request = new Request ($ config );
719+ $ this ->request ->populateHeaders ();
717720
718721 // we should see the original forwarded address
719722 $ this ->assertSame ($ expected , $ this ->request ->getIPAddress ());
@@ -727,6 +730,7 @@ public function testGetIPAddressThruProxyInvalid()
727730 $ config ->proxyIPs = '10.0.1.200,192.168.5.0/24 ' ;
728731 $ _SERVER ['HTTP_X_FORWARDED_FOR ' ] = $ expected ;
729732 $ this ->request = new Request ($ config );
733+ $ this ->request ->populateHeaders ();
730734
731735 // spoofed address invalid
732736 $ this ->assertSame ('10.0.1.200 ' , $ this ->request ->getIPAddress ());
@@ -740,6 +744,7 @@ public function testGetIPAddressThruProxyNotWhitelisted()
740744 $ config ->proxyIPs = '10.0.1.200,192.168.5.0/24 ' ;
741745 $ _SERVER ['HTTP_X_FORWARDED_FOR ' ] = $ expected ;
742746 $ this ->request = new Request ($ config );
747+ $ this ->request ->populateHeaders ();
743748
744749 // spoofed address invalid
745750 $ this ->assertSame ('10.10.1.200 ' , $ this ->request ->getIPAddress ());
@@ -753,6 +758,7 @@ public function testGetIPAddressThruProxySubnet()
753758 $ config ->proxyIPs = ['192.168.5.0/24 ' ];
754759 $ _SERVER ['HTTP_X_FORWARDED_FOR ' ] = $ expected ;
755760 $ this ->request = new Request ($ config );
761+ $ this ->request ->populateHeaders ();
756762
757763 // we should see the original forwarded address
758764 $ this ->assertSame ($ expected , $ this ->request ->getIPAddress ());
@@ -766,6 +772,7 @@ public function testGetIPAddressThruProxyOutofSubnet()
766772 $ config ->proxyIPs = ['192.168.5.0/28 ' ];
767773 $ _SERVER ['HTTP_X_FORWARDED_FOR ' ] = $ expected ;
768774 $ this ->request = new Request ($ config );
775+ $ this ->request ->populateHeaders ();
769776
770777 // we should see the original forwarded address
771778 $ this ->assertSame ('192.168.5.21 ' , $ this ->request ->getIPAddress ());
0 commit comments