diff options
author | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2015-07-25 19:18:32 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-10 23:28:16 +0100 |
commit | 2579999373e628c1d6d4d08d1d89412f1fd68fe3 (patch) | |
tree | 3baf6873ad32a70ebd572862eb890be5d3fb65d3 /tests | |
parent | 8944af57cbd1fd2962b6adeaed76c6cd41712453 (diff) | |
download | nextcloud-server-2579999373e628c1d6d4d08d1d89412f1fd68fe3.tar.gz nextcloud-server-2579999373e628c1d6d4d08d1d89412f1fd68fe3.zip |
Add setup check for reverse proxy header configuration
Diffstat (limited to 'tests')
-rw-r--r-- | tests/settings/controller/CheckSetupControllerTest.php | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/tests/settings/controller/CheckSetupControllerTest.php b/tests/settings/controller/CheckSetupControllerTest.php index 62fedd6dd6d..414b1b91e17 100644 --- a/tests/settings/controller/CheckSetupControllerTest.php +++ b/tests/settings/controller/CheckSetupControllerTest.php @@ -246,7 +246,40 @@ class CheckSetupControllerTest extends TestCase { ['eol' => false, 'version' => PHP_VERSION], self::invokePrivate($this->checkSetupController, 'isPhpSupported') ); + } + + public function testForwardedForHeadersWorkingFalse() { + $this->config->expects($this->once()) + ->method('getSystemValue') + ->with('trusted_proxies', []) + ->willReturn(['1.2.3.4']); + $this->request->expects($this->once()) + ->method('getRemoteAddress') + ->willReturn('1.2.3.4'); + + $this->assertFalse( + self::invokePrivate( + $this->checkSetupController, + 'forwardedForHeadersWorking' + ) + ); + } + public function testForwardedForHeadersWorkingTrue() { + $this->config->expects($this->once()) + ->method('getSystemValue') + ->with('trusted_proxies', []) + ->willReturn(['1.2.3.4']); + $this->request->expects($this->once()) + ->method('getRemoteAddress') + ->willReturn('4.3.2.1'); + + $this->assertTrue( + self::invokePrivate( + $this->checkSetupController, + 'forwardedForHeadersWorking' + ) + ); } public function testCheck() { @@ -258,6 +291,14 @@ class CheckSetupControllerTest extends TestCase { ->method('getSystemValue') ->with('memcache.local', null) ->will($this->returnValue('SomeProvider')); + $this->config->expects($this->at(2)) + ->method('getSystemValue') + ->with('trusted_proxies', []) + ->willReturn(['1.2.3.4']); + + $this->request->expects($this->once()) + ->method('getRemoteAddress') + ->willReturn('4.3.2.1'); $client = $this->getMockBuilder('\OCP\Http\Client\IClient') ->disableOriginalConstructor()->getMock(); @@ -285,6 +326,10 @@ class CheckSetupControllerTest extends TestCase { ->with('admin-security') ->willReturn('https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html'); self::$version_compare = -1; + $this->urlGenerator->expects($this->at(2)) + ->method('linkToDocs') + ->with('admin-reverse-proxy') + ->willReturn('reverse-proxy-doc-link'); $expected = new DataResponse( [ @@ -298,7 +343,9 @@ class CheckSetupControllerTest extends TestCase { 'phpSupported' => [ 'eol' => true, 'version' => PHP_VERSION - ] + ], + 'forwardedForHeadersWorking' => true, + 'reverseProxyDocs' => 'reverse-proxy-doc-link', ] ); $this->assertEquals($expected, $this->checkSetupController->check()); |