@@ -445,7 +445,33 @@ public function testGetRemoteAddressWithSingleTrustedRemote() {
445445 $ this ->stream
446446 );
447447
448- $ this ->assertSame ('10.4.0.5 ' , $ request ->getRemoteAddress ());
448+ $ this ->assertSame ('10.4.0.4 ' , $ request ->getRemoteAddress ());
449+ }
450+
451+ public function testGetRemoteAddressWithMultipleTrustedRemotes () {
452+ $ this ->config
453+ ->expects ($ this ->exactly (2 ))
454+ ->method ('getSystemValue ' )
455+ ->willReturnMap ([
456+ ['trusted_proxies ' , [], ['10.0.0.2 ' , '::1 ' ]],
457+ ['forwarded_for_headers ' , ['HTTP_X_FORWARDED_FOR ' ], ['HTTP_X_FORWARDED ' ]],
458+ ]);
459+
460+ $ request = new Request (
461+ [
462+ 'server ' => [
463+ 'REMOTE_ADDR ' => '10.0.0.2 ' ,
464+ 'HTTP_X_FORWARDED ' => '10.4.0.5, 10.4.0.4, ::1 ' ,
465+ 'HTTP_X_FORWARDED_FOR ' => '192.168.0.233 '
466+ ],
467+ ],
468+ $ this ->requestId ,
469+ $ this ->config ,
470+ $ this ->csrfTokenManager ,
471+ $ this ->stream
472+ );
473+
474+ $ this ->assertSame ('10.4.0.4 ' , $ request ->getRemoteAddress ());
449475 }
450476
451477 public function testGetRemoteAddressIPv6WithSingleTrustedRemote () {
@@ -474,7 +500,7 @@ public function testGetRemoteAddressIPv6WithSingleTrustedRemote() {
474500 $ this ->stream
475501 );
476502
477- $ this ->assertSame ('10.4.0.5 ' , $ request ->getRemoteAddress ());
503+ $ this ->assertSame ('10.4.0.4 ' , $ request ->getRemoteAddress ());
478504 }
479505
480506 public function testGetRemoteAddressVerifyPriorityHeader () {
@@ -487,9 +513,9 @@ public function testGetRemoteAddressVerifyPriorityHeader() {
487513 )-> willReturnOnConsecutiveCalls (
488514 ['10.0.0.2 ' ],
489515 [
490- 'HTTP_CLIENT_IP ' ,
491- 'HTTP_X_FORWARDED_FOR ' ,
492516 'HTTP_X_FORWARDED ' ,
517+ 'HTTP_X_FORWARDED_FOR ' ,
518+ 'HTTP_CLIENT_IP ' ,
493519 ],
494520 );
495521
@@ -520,9 +546,9 @@ public function testGetRemoteAddressIPv6VerifyPriorityHeader() {
520546 )-> willReturnOnConsecutiveCalls (
521547 ['2001:db8:85a3:8d3:1319:8a2e:370:7348 ' ],
522548 [
523- 'HTTP_CLIENT_IP ' ,
549+ 'HTTP_X_FORWARDED ' ,
524550 'HTTP_X_FORWARDED_FOR ' ,
525- 'HTTP_X_FORWARDED '
551+ 'HTTP_CLIENT_IP ' ,
526552 ],
527553 );
528554
0 commit comments