summaryrefslogtreecommitdiffstats
path: root/tests/settings
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@owncloud.com>2015-07-28 21:26:44 +0100
committerRobin McCorkell <rmccorkell@owncloud.com>2015-07-28 21:26:44 +0100
commit6d54d2fad71a57d08cfd5a5a2d76948ac0983ff6 (patch)
tree1cb1415dd7d52a44b3ce43d5196aeb8af9f73677 /tests/settings
parent6f72c3746403cdba5dbaae9a21870f0db0e5226e (diff)
parent0d515de13e0832447ed341c0b8377e01d350e48c (diff)
downloadnextcloud-server-6d54d2fad71a57d08cfd5a5a2d76948ac0983ff6.tar.gz
nextcloud-server-6d54d2fad71a57d08cfd5a5a2d76948ac0983ff6.zip
Merge pull request #17912 from owncloud/detect-old-openssl-versions
Detect old NSS and OpenSSL versions
Diffstat (limited to 'tests/settings')
-rw-r--r--tests/settings/controller/CheckSetupControllerTest.php156
1 files changed, 147 insertions, 9 deletions
diff --git a/tests/settings/controller/CheckSetupControllerTest.php b/tests/settings/controller/CheckSetupControllerTest.php
index b39d13ac26b..6096aae8652 100644
--- a/tests/settings/controller/CheckSetupControllerTest.php
+++ b/tests/settings/controller/CheckSetupControllerTest.php
@@ -24,6 +24,7 @@ namespace OC\Settings\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
use OC_Util;
@@ -47,6 +48,8 @@ class CheckSetupControllerTest extends TestCase {
private $urlGenerator;
/** @var OC_Util */
private $util;
+ /** @var IL10N */
+ private $l10n;
public function setUp() {
parent::setUp();
@@ -63,15 +66,24 @@ class CheckSetupControllerTest extends TestCase {
->disableOriginalConstructor()->getMock();
$this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
->disableOriginalConstructor()->getMock();
-
- $this->checkSetupController = new CheckSetupController(
- 'settings',
- $this->request,
- $this->config,
- $this->clientService,
- $this->urlGenerator,
- $this->util
- );
+ $this->l10n = $this->getMockBuilder('\OCP\IL10N')
+ ->disableOriginalConstructor()->getMock();
+ $this->l10n->expects($this->any())
+ ->method('t')
+ ->will($this->returnCallback(function($message, array $replace) {
+ return vsprintf($message, $replace);
+ }));
+ $this->checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
+ ->setConstructorArgs([
+ 'settings',
+ $this->request,
+ $this->config,
+ $this->clientService,
+ $this->urlGenerator,
+ $this->util,
+ $this->l10n,
+ ])
+ ->setMethods(['getCurlVersion'])->getMock();
}
public function testIsInternetConnectionWorkingDisabledViaConfig() {
@@ -241,8 +253,134 @@ class CheckSetupControllerTest extends TestCase {
'memcacheDocs' => 'http://doc.owncloud.org/server/go.php?to=admin-performance',
'isUrandomAvailable' => self::invokePrivate($this->checkSetupController, 'isUrandomAvailable'),
'securityDocs' => 'https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html',
+ 'isUsedTlsLibOutdated' => '',
]
);
$this->assertEquals($expected, $this->checkSetupController->check());
}
+
+ public function testGetCurlVersion() {
+ $checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
+ ->setConstructorArgs([
+ 'settings',
+ $this->request,
+ $this->config,
+ $this->clientService,
+ $this->urlGenerator,
+ $this->util,
+ $this->l10n,
+ ])
+ ->setMethods(null)->getMock();
+
+ $this->assertArrayHasKey('ssl_version', $checkSetupController->getCurlVersion());
+ }
+
+ public function testIsUsedTlsLibOutdatedWithAnotherLibrary() {
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('getCurlVersion')
+ ->will($this->returnValue(['ssl_version' => 'SSLlib']));
+ $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
+ }
+
+ public function testIsUsedTlsLibOutdatedWithMisbehavingCurl() {
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('getCurlVersion')
+ ->will($this->returnValue([]));
+ $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
+ }
+
+ public function testIsUsedTlsLibOutdatedWithOlderOpenSsl() {
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('getCurlVersion')
+ ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1c']));
+ $this->assertSame('cURL is using an outdated OpenSSL version (OpenSSL/1.0.1c). Please update your operating system or features such as installing and updating apps via the app store or Federated Cloud Sharing will not work reliably.', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
+ }
+
+ public function testIsUsedTlsLibOutdatedWithOlderOpenSsl1() {
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('getCurlVersion')
+ ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.2a']));
+ $this->assertSame('cURL is using an outdated OpenSSL version (OpenSSL/1.0.2a). Please update your operating system or features such as installing and updating apps via the app store or Federated Cloud Sharing will not work reliably.', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
+ }
+
+ public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion() {
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('getCurlVersion')
+ ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1d']));
+ $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
+ }
+
+ public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion1() {
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('getCurlVersion')
+ ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.2b']));
+ $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
+ }
+
+ public function testIsBuggyNss400() {
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('getCurlVersion')
+ ->will($this->returnValue(['ssl_version' => 'NSS/1.0.2b']));
+ $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
+ ->disableOriginalConstructor()->getMock();
+ $exception = $this->getMockBuilder('\GuzzleHttp\Exception\ClientException')
+ ->disableOriginalConstructor()->getMock();
+ $response = $this->getMockBuilder('\GuzzleHttp\Message\ResponseInterface')
+ ->disableOriginalConstructor()->getMock();
+ $response->expects($this->once())
+ ->method('getStatusCode')
+ ->will($this->returnValue(400));
+ $exception->expects($this->once())
+ ->method('getResponse')
+ ->will($this->returnValue($response));
+
+ $client->expects($this->at(0))
+ ->method('get')
+ ->with('https://www.owncloud.org/', [])
+ ->will($this->throwException($exception));
+
+ $this->clientService->expects($this->once())
+ ->method('newClient')
+ ->will($this->returnValue($client));
+
+ $this->assertSame('cURL is using an outdated NSS version (NSS/1.0.2b). Please update your operating system or features such as installing and updating apps via the app store or Federated Cloud Sharing will not work reliably.', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
+ }
+
+
+ public function testIsBuggyNss200() {
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('getCurlVersion')
+ ->will($this->returnValue(['ssl_version' => 'NSS/1.0.2b']));
+ $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
+ ->disableOriginalConstructor()->getMock();
+ $exception = $this->getMockBuilder('\GuzzleHttp\Exception\ClientException')
+ ->disableOriginalConstructor()->getMock();
+ $response = $this->getMockBuilder('\GuzzleHttp\Message\ResponseInterface')
+ ->disableOriginalConstructor()->getMock();
+ $response->expects($this->once())
+ ->method('getStatusCode')
+ ->will($this->returnValue(200));
+ $exception->expects($this->once())
+ ->method('getResponse')
+ ->will($this->returnValue($response));
+
+ $client->expects($this->at(0))
+ ->method('get')
+ ->with('https://www.owncloud.org/', [])
+ ->will($this->throwException($exception));
+
+ $this->clientService->expects($this->once())
+ ->method('newClient')
+ ->will($this->returnValue($client));
+
+ $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
+ }
}