diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-10-08 18:23:20 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-10-08 18:26:03 +0200 |
commit | 12181aa6def2a20962ea536ace0ba472dbc1c26e (patch) | |
tree | 3a9399419e2db69c0cc7b39f1e91baa5e5fcd556 /tests/settings | |
parent | 9b220d0576d2639740c60a72343ece99dbc39a9c (diff) | |
download | nextcloud-server-12181aa6def2a20962ea536ace0ba472dbc1c26e.tar.gz nextcloud-server-12181aa6def2a20962ea536ace0ba472dbc1c26e.zip |
Don't perform checks for outdated TLS libs when no internet connection
This change makes the check return a positive result when:
- The instance has been configured to not use the internet
AND/OR
- S2S AND the appstore is disabled
Diffstat (limited to 'tests/settings')
-rw-r--r-- | tests/settings/controller/CheckSetupControllerTest.php | 118 |
1 files changed, 105 insertions, 13 deletions
diff --git a/tests/settings/controller/CheckSetupControllerTest.php b/tests/settings/controller/CheckSetupControllerTest.php index c453822464f..ebba18de5fd 100644 --- a/tests/settings/controller/CheckSetupControllerTest.php +++ b/tests/settings/controller/CheckSetupControllerTest.php @@ -293,6 +293,10 @@ class CheckSetupControllerTest extends TestCase { ->will($this->returnValue('SomeProvider')); $this->config->expects($this->at(2)) ->method('getSystemValue') + ->with('has_internet_connection', true) + ->will($this->returnValue(false)); + $this->config->expects($this->at(3)) + ->method('getSystemValue') ->with('trusted_proxies', []) ->willReturn(['1.2.3.4']); @@ -365,10 +369,13 @@ class CheckSetupControllerTest extends TestCase { ]) ->setMethods(null)->getMock(); - $this->assertArrayHasKey('ssl_version', $checkSetupController->getCurlVersion()); + $this->assertArrayHasKey('ssl_version', $this->invokePrivate($checkSetupController, 'getCurlVersion')); } public function testIsUsedTlsLibOutdatedWithAnotherLibrary() { + $this->config->expects($this->any()) + ->method('getSystemValue') + ->will($this->returnValue(true)); $this->checkSetupController ->expects($this->once()) ->method('getCurlVersion') @@ -377,6 +384,9 @@ class CheckSetupControllerTest extends TestCase { } public function testIsUsedTlsLibOutdatedWithMisbehavingCurl() { + $this->config->expects($this->any()) + ->method('getSystemValue') + ->will($this->returnValue(true)); $this->checkSetupController ->expects($this->once()) ->method('getCurlVersion') @@ -385,10 +395,8 @@ class CheckSetupControllerTest extends TestCase { } public function testIsUsedTlsLibOutdatedWithOlderOpenSsl() { - $this->config - ->expects($this->once()) + $this->config->expects($this->any()) ->method('getSystemValue') - ->with('appstoreenabled', true) ->will($this->returnValue(true)); $this->checkSetupController ->expects($this->once()) @@ -399,10 +407,10 @@ class CheckSetupControllerTest extends TestCase { public function testIsUsedTlsLibOutdatedWithOlderOpenSslAndWithoutAppstore() { $this->config - ->expects($this->once()) + ->expects($this->at(0)) ->method('getSystemValue') - ->with('appstoreenabled', true) - ->will($this->returnValue(false)); + ->with('has_internet_connection', true) + ->will($this->returnValue(true)); $this->checkSetupController ->expects($this->once()) ->method('getCurlVersion') @@ -411,10 +419,8 @@ class CheckSetupControllerTest extends TestCase { } public function testIsUsedTlsLibOutdatedWithOlderOpenSsl1() { - $this->config - ->expects($this->once()) + $this->config->expects($this->any()) ->method('getSystemValue') - ->with('appstoreenabled', true) ->will($this->returnValue(true)); $this->checkSetupController ->expects($this->once()) @@ -424,6 +430,9 @@ class CheckSetupControllerTest extends TestCase { } public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion() { + $this->config->expects($this->any()) + ->method('getSystemValue') + ->will($this->returnValue(true)); $this->checkSetupController ->expects($this->once()) ->method('getCurlVersion') @@ -432,6 +441,9 @@ class CheckSetupControllerTest extends TestCase { } public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion1() { + $this->config->expects($this->any()) + ->method('getSystemValue') + ->will($this->returnValue(true)); $this->checkSetupController ->expects($this->once()) ->method('getCurlVersion') @@ -440,10 +452,8 @@ class CheckSetupControllerTest extends TestCase { } public function testIsBuggyNss400() { - $this->config - ->expects($this->once()) + $this->config->expects($this->any()) ->method('getSystemValue') - ->with('appstoreenabled', true) ->will($this->returnValue(true)); $this->checkSetupController ->expects($this->once()) @@ -476,6 +486,9 @@ class CheckSetupControllerTest extends TestCase { public function testIsBuggyNss200() { + $this->config->expects($this->any()) + ->method('getSystemValue') + ->will($this->returnValue(true)); $this->checkSetupController ->expects($this->once()) ->method('getCurlVersion') @@ -504,4 +517,83 @@ class CheckSetupControllerTest extends TestCase { $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated')); } + + public function testIsUsedTlsLibOutdatedWithInternetDisabled() { + $this->config + ->expects($this->at(0)) + ->method('getSystemValue') + ->with('has_internet_connection', true) + ->will($this->returnValue(false)); + $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated')); + } + + public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingEnabled() { + // Appstore is disabled by default in EE + $appStoreDefault = false; + if (\OC_Util::getEditionString() === '') { + $appStoreDefault = true; + } + + $this->config + ->expects($this->at(0)) + ->method('getSystemValue') + ->with('has_internet_connection', true) + ->will($this->returnValue(true)); + $this->config + ->expects($this->at(1)) + ->method('getSystemValue') + ->with('appstoreenabled', $appStoreDefault) + ->will($this->returnValue(false)); + $this->config + ->expects($this->at(2)) + ->method('getAppValue') + ->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes') + ->will($this->returnValue('no')); + $this->config + ->expects($this->at(3)) + ->method('getAppValue') + ->with('files_sharing', 'incoming_server2server_share_enabled', 'yes') + ->will($this->returnValue('yes')); + + $this->checkSetupController + ->expects($this->once()) + ->method('getCurlVersion') + ->will($this->returnValue([])); + $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated')); + } + + public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingDisabled() { + // Appstore is disabled by default in EE + $appStoreDefault = false; + if (\OC_Util::getEditionString() === '') { + $appStoreDefault = true; + } + + $this->config + ->expects($this->at(0)) + ->method('getSystemValue') + ->with('has_internet_connection', true) + ->will($this->returnValue(true)); + $this->config + ->expects($this->at(1)) + ->method('getSystemValue') + ->with('appstoreenabled', $appStoreDefault) + ->will($this->returnValue(false)); + $this->config + ->expects($this->at(2)) + ->method('getAppValue') + ->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes') + ->will($this->returnValue('no')); + $this->config + ->expects($this->at(3)) + ->method('getAppValue') + ->with('files_sharing', 'incoming_server2server_share_enabled', 'yes') + ->will($this->returnValue('no')); + + $this->checkSetupController + ->expects($this->never()) + ->method('getCurlVersion') + ->will($this->returnValue([])); + $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated')); + } } |