diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-07-02 12:01:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-02 12:01:24 +0200 |
commit | 0ac3a65f627fab0e5010af4c496410441e47aed4 (patch) | |
tree | bffd04a96e36321dd9e1ef6b8b9ff35317447f20 /tests | |
parent | 47a21fad8cb4aecf24521ba6e46ad104378b277d (diff) | |
parent | 74a9cadc501791eaa42b43a7e66eb23a31b2135f (diff) | |
download | nextcloud-server-0ac3a65f627fab0e5010af4c496410441e47aed4.tar.gz nextcloud-server-0ac3a65f627fab0e5010af4c496410441e47aed4.zip |
Merge pull request #21653 from nextcloud/bugfix/noid/fix-ipv6-remote-addresses-from-x-forwarded-for-header
Fix IPv6 remote addresses from X_FORWARDED_FOR headers before validating
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/AppFramework/Http/RequestTest.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index a8e2f2248c6..7260b31b27e 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -632,6 +632,34 @@ class RequestTest extends \Test\TestCase { $this->assertSame('192.168.3.99', $request->getRemoteAddress()); } + public function testGetRemoteAddressWithXForwardedForIPv6() { + $this->config + ->expects($this->at(0)) + ->method('getSystemValue') + ->with('trusted_proxies') + ->willReturn(['192.168.2.0/24']); + $this->config + ->expects($this->at(1)) + ->method('getSystemValue') + ->with('forwarded_for_headers') + ->willReturn(['HTTP_X_FORWARDED_FOR']); + + $request = new Request( + [ + 'server' => [ + 'REMOTE_ADDR' => '192.168.2.99', + 'HTTP_X_FORWARDED_FOR' => '[2001:db8:85a3:8d3:1319:8a2e:370:7348]', + ], + ], + $this->secureRandom, + $this->config, + $this->csrfTokenManager, + $this->stream + ); + + $this->assertSame('2001:db8:85a3:8d3:1319:8a2e:370:7348', $request->getRemoteAddress()); + } + /** * @return array */ |