|
|
@@ -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')); |
|
|
|
} |
|
|
|
} |