diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-08 21:09:30 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-08 21:09:30 +0200 |
commit | ef4278cfa9570b3910b35cc82313d6391aec3c22 (patch) | |
tree | 5cf2c8713dbae36383148c60dde2fcc1b0611916 | |
parent | 49d140444da7773652fe8428717da381cab0b5ff (diff) | |
parent | 12181aa6def2a20962ea536ace0ba472dbc1c26e (diff) | |
download | nextcloud-server-ef4278cfa9570b3910b35cc82313d6391aec3c22.tar.gz nextcloud-server-ef4278cfa9570b3910b35cc82313d6391aec3c22.zip |
Merge pull request #19664 from owncloud/check-only-if-s2s-or-appstore-is-enabled
Don't perform checks for outdated TLS libs when no internet connection
-rw-r--r-- | settings/controller/checksetupcontroller.php | 26 | ||||
-rw-r--r-- | tests/settings/controller/CheckSetupControllerTest.php | 118 |
2 files changed, 127 insertions, 17 deletions
diff --git a/settings/controller/checksetupcontroller.php b/settings/controller/checksetupcontroller.php index 4aef2d3ade6..2ff55fc72c9 100644 --- a/settings/controller/checksetupcontroller.php +++ b/settings/controller/checksetupcontroller.php @@ -123,7 +123,7 @@ class CheckSetupController extends Controller { * * @return array */ - public function getCurlVersion() { + protected function getCurlVersion() { return curl_version(); } @@ -137,6 +137,24 @@ class CheckSetupController extends Controller { * @return string */ private function isUsedTlsLibOutdated() { + // Appstore is disabled by default in EE + $appStoreDefault = false; + if (\OC_Util::getEditionString() === '') { + $appStoreDefault = true; + } + + // Don't run check when: + // 1. Server has `has_internet_connection` set to false + // 2. AppStore AND S2S is disabled + if(!$this->config->getSystemValue('has_internet_connection', true)) { + return ''; + } + if(!$this->config->getSystemValue('appstoreenabled', $appStoreDefault) + && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' + && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { + return ''; + } + $versionString = $this->getCurlVersion(); if(isset($versionString['ssl_version'])) { $versionString = $versionString['ssl_version']; @@ -145,7 +163,7 @@ class CheckSetupController extends Controller { } $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); - if(!$this->config->getSystemValue('appstoreenabled', true)) { + if(!$this->config->getSystemValue('appstoreenabled', $appStoreDefault)) { $features = (string)$this->l10n->t('Federated Cloud Sharing'); } @@ -178,7 +196,7 @@ class CheckSetupController extends Controller { return ''; } - /* + /** * Whether the php version is still supported (at time of release) * according to: https://secure.php.net/supported-versions.php * @@ -195,7 +213,7 @@ class CheckSetupController extends Controller { return ['eol' => $eol, 'version' => PHP_VERSION]; } - /* + /** * Check if the reverse proxy configuration is working as expected * * @return bool 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')); + } } |