12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034 |
- <?php
- /**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
- namespace Tests\Settings\Controller;
- use OC\Settings\Controller\CheckSetupController;
- use OCP\AppFramework\Http;
- use OCP\AppFramework\Http\DataDisplayResponse;
- use OCP\AppFramework\Http\DataResponse;
- use OCP\AppFramework\Http\RedirectResponse;
- use OCP\Http\Client\IClientService;
- use OCP\IConfig;
- use OCP\IL10N;
- use OCP\ILogger;
- use OCP\IRequest;
- use OCP\IURLGenerator;
- use OC_Util;
- use Test\TestCase;
- use OC\IntegrityCheck\Checker;
- /**
- * Class CheckSetupControllerTest
- *
- * @package Tests\Settings\Controller
- */
- class CheckSetupControllerTest extends TestCase {
- /** @var CheckSetupController | \PHPUnit_Framework_MockObject_MockObject */
- private $checkSetupController;
- /** @var IRequest | \PHPUnit_Framework_MockObject_MockObject */
- private $request;
- /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
- private $config;
- /** @var IClientService | \PHPUnit_Framework_MockObject_MockObject*/
- private $clientService;
- /** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject */
- private $urlGenerator;
- /** @var OC_Util */
- private $util;
- /** @var IL10N | \PHPUnit_Framework_MockObject_MockObject */
- private $l10n;
- /** @var ILogger */
- private $logger;
- /** @var Checker | \PHPUnit_Framework_MockObject_MockObject */
- private $checker;
- public function setUp() {
- parent::setUp();
- $this->request = $this->getMockBuilder('\OCP\IRequest')
- ->disableOriginalConstructor()->getMock();
- $this->config = $this->getMockBuilder('\OCP\IConfig')
- ->disableOriginalConstructor()->getMock();
- $this->config = $this->getMockBuilder('\OCP\IConfig')
- ->disableOriginalConstructor()->getMock();
- $this->clientService = $this->getMockBuilder('\OCP\Http\Client\IClientService')
- ->disableOriginalConstructor()->getMock();
- $this->util = $this->getMockBuilder('\OC_Util')
- ->disableOriginalConstructor()->getMock();
- $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
- ->disableOriginalConstructor()->getMock();
- $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->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
- ->disableOriginalConstructor()->getMock();
- $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
- $this->checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
- ->setConstructorArgs([
- 'settings',
- $this->request,
- $this->config,
- $this->clientService,
- $this->urlGenerator,
- $this->util,
- $this->l10n,
- $this->checker,
- $this->logger
- ])
- ->setMethods(['getCurlVersion', 'isPhpOutdated'])->getMock();
- }
- public function testIsInternetConnectionWorkingDisabledViaConfig() {
- $this->config->expects($this->once())
- ->method('getSystemValue')
- ->with('has_internet_connection', true)
- ->will($this->returnValue(false));
- $this->assertFalse(
- self::invokePrivate(
- $this->checkSetupController,
- 'isInternetConnectionWorking'
- )
- );
- }
- public function testIsInternetConnectionWorkingCorrectly() {
- $this->config->expects($this->once())
- ->method('getSystemValue')
- ->with('has_internet_connection', true)
- ->will($this->returnValue(true));
- $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
- ->disableOriginalConstructor()->getMock();
- $client->expects($this->any())
- ->method('get');
- $this->clientService->expects($this->once())
- ->method('newClient')
- ->will($this->returnValue($client));
- $this->assertTrue(
- self::invokePrivate(
- $this->checkSetupController,
- 'isInternetConnectionWorking'
- )
- );
- }
- public function testIsInternetConnectionFail() {
- $this->config->expects($this->once())
- ->method('getSystemValue')
- ->with('has_internet_connection', true)
- ->will($this->returnValue(true));
- $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
- ->disableOriginalConstructor()->getMock();
- $client->expects($this->any())
- ->method('get')
- ->will($this->throwException(new \Exception()));
- $this->clientService->expects($this->exactly(3))
- ->method('newClient')
- ->will($this->returnValue($client));
- $this->assertFalse(
- self::invokePrivate(
- $this->checkSetupController,
- 'isInternetConnectionWorking'
- )
- );
- }
- public function testIsMemcacheConfiguredFalse() {
- $this->config->expects($this->once())
- ->method('getSystemValue')
- ->with('memcache.local', null)
- ->will($this->returnValue(null));
- $this->assertFalse(
- self::invokePrivate(
- $this->checkSetupController,
- 'isMemcacheConfigured'
- )
- );
- }
- public function testIsMemcacheConfiguredTrue() {
- $this->config->expects($this->once())
- ->method('getSystemValue')
- ->with('memcache.local', null)
- ->will($this->returnValue('SomeProvider'));
- $this->assertTrue(
- self::invokePrivate(
- $this->checkSetupController,
- 'isMemcacheConfigured'
- )
- );
- }
- public function testIsPhpSupportedFalse() {
- $this->checkSetupController
- ->expects($this->once())
- ->method('isPhpOutdated')
- ->willReturn(true);
- $this->assertEquals(
- ['eol' => true, 'version' => PHP_VERSION],
- self::invokePrivate($this->checkSetupController, 'isPhpSupported')
- );
- }
- public function testIsPhpSupportedTrue() {
- $this->checkSetupController
- ->expects($this->exactly(2))
- ->method('isPhpOutdated')
- ->willReturn(false);
- $this->assertEquals(
- ['eol' => false, 'version' => PHP_VERSION],
- self::invokePrivate($this->checkSetupController, 'isPhpSupported')
- );
- $this->assertEquals(
- ['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() {
- $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('memcache.local', null)
- ->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']);
- $this->request->expects($this->once())
- ->method('getRemoteAddress')
- ->willReturn('4.3.2.1');
- $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
- ->disableOriginalConstructor()->getMock();
- $client->expects($this->at(0))
- ->method('get')
- ->with('http://www.nextcloud.com/', [])
- ->will($this->throwException(new \Exception()));
- $client->expects($this->at(1))
- ->method('get')
- ->with('http://www.google.com/', [])
- ->will($this->throwException(new \Exception()));
- $client->expects($this->at(2))
- ->method('get')
- ->with('http://www.github.com/', [])
- ->will($this->throwException(new \Exception()));
- $this->clientService->expects($this->exactly(3))
- ->method('newClient')
- ->will($this->returnValue($client));
- $this->urlGenerator->expects($this->at(0))
- ->method('linkToDocs')
- ->with('admin-performance')
- ->willReturn('http://doc.owncloud.org/server/go.php?to=admin-performance');
- $this->urlGenerator->expects($this->at(1))
- ->method('linkToDocs')
- ->with('admin-security')
- ->willReturn('https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html');
- $this->checkSetupController
- ->expects($this->once())
- ->method('isPhpOutdated')
- ->willReturn(true);
- $this->urlGenerator->expects($this->at(2))
- ->method('linkToDocs')
- ->with('admin-reverse-proxy')
- ->willReturn('reverse-proxy-doc-link');
- $this->urlGenerator->expects($this->at(3))
- ->method('linkToDocs')
- ->with('admin-code-integrity')
- ->willReturn('http://doc.owncloud.org/server/go.php?to=admin-code-integrity');
- $this->urlGenerator->expects($this->at(4))
- ->method('linkToDocs')
- ->with('admin-php-opcache')
- ->willReturn('http://doc.owncloud.org/server/go.php?to=admin-php-opcache');
- $expected = new DataResponse(
- [
- 'serverHasInternetConnection' => false,
- 'isMemcacheConfigured' => true,
- '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' => '',
- 'phpSupported' => [
- 'eol' => true,
- 'version' => PHP_VERSION
- ],
- 'forwardedForHeadersWorking' => true,
- 'reverseProxyDocs' => 'reverse-proxy-doc-link',
- 'isCorrectMemcachedPHPModuleInstalled' => true,
- 'hasPassedCodeIntegrityCheck' => null,
- 'codeIntegrityCheckerDocumentation' => 'http://doc.owncloud.org/server/go.php?to=admin-code-integrity',
- 'isOpcacheProperlySetup' => false,
- 'phpOpcacheDocumentation' => 'http://doc.owncloud.org/server/go.php?to=admin-php-opcache',
- 'isSettimelimitAvailable' => true,
- ]
- );
- $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,
- $this->checker,
- $this->logger
- ])
- ->setMethods(null)->getMock();
- $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')
- ->will($this->returnValue(['ssl_version' => 'SSLlib']));
- $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
- }
- public function testIsUsedTlsLibOutdatedWithMisbehavingCurl() {
- $this->config->expects($this->any())
- ->method('getSystemValue')
- ->will($this->returnValue(true));
- $this->checkSetupController
- ->expects($this->once())
- ->method('getCurlVersion')
- ->will($this->returnValue([]));
- $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
- }
- public function testIsUsedTlsLibOutdatedWithOlderOpenSsl() {
- $this->config->expects($this->any())
- ->method('getSystemValue')
- ->will($this->returnValue(true));
- $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 testIsUsedTlsLibOutdatedWithOlderOpenSslAndWithoutAppstore() {
- $this->config
- ->expects($this->at(0))
- ->method('getSystemValue')
- ->with('has_internet_connection', true)
- ->will($this->returnValue(true));
- $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 Federated Cloud Sharing will not work reliably.', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
- }
- public function testIsUsedTlsLibOutdatedWithOlderOpenSsl1() {
- $this->config->expects($this->any())
- ->method('getSystemValue')
- ->will($this->returnValue(true));
- $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->config->expects($this->any())
- ->method('getSystemValue')
- ->will($this->returnValue(true));
- $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->config->expects($this->any())
- ->method('getSystemValue')
- ->will($this->returnValue(true));
- $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->config->expects($this->any())
- ->method('getSystemValue')
- ->will($this->returnValue(true));
- $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->config->expects($this->any())
- ->method('getSystemValue')
- ->will($this->returnValue(true));
- $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'));
- }
- 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() {
- $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', true)
- ->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() {
- $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', true)
- ->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'));
- }
- public function testRescanFailedIntegrityCheck() {
- $this->checker
- ->expects($this->once())
- ->method('runInstanceVerification');
- $this->urlGenerator
- ->expects($this->once())
- ->method('linkToRoute')
- ->with('settings.AdminSettings.index')
- ->will($this->returnValue('/admin'));
- $expected = new RedirectResponse('/admin');
- $this->assertEquals($expected, $this->checkSetupController->rescanFailedIntegrityCheck());
- }
- public function testGetFailedIntegrityCheckDisabled() {
- $this->checker
- ->expects($this->once())
- ->method('isCodeCheckEnforced')
- ->willReturn(false);
- $expected = new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
- $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
- }
- public function testGetFailedIntegrityCheckFilesWithNoErrorsFound() {
- $this->checker
- ->expects($this->once())
- ->method('isCodeCheckEnforced')
- ->willReturn(true);
- $this->checker
- ->expects($this->once())
- ->method('getResults')
- ->will($this->returnValue([]));
- $expected = new DataDisplayResponse(
- 'No errors have been found.',
- Http::STATUS_OK,
- [
- 'Content-Type' => 'text/plain',
- ]
- );
- $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
- }
- public function testGetFailedIntegrityCheckFilesWithSomeErrorsFound() {
- $this->checker
- ->expects($this->once())
- ->method('isCodeCheckEnforced')
- ->willReturn(true);
- $this->checker
- ->expects($this->once())
- ->method('getResults')
- ->will($this->returnValue(array ( 'core' => array ( 'EXTRA_FILE' => array('/testfile' => array()), 'INVALID_HASH' => array ( '/.idea/workspace.xml' => array ( 'expected' => 'f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216', 'current' => 'ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094', ), '/lib/private/integritycheck/checker.php' => array ( 'expected' => 'c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea', 'current' => '88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585', ), '/settings/controller/checksetupcontroller.php' => array ( 'expected' => '3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4', 'current' => '09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a', ), ), ), 'bookmarks' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'dav' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'encryption' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'external' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'federation' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_antivirus' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_drop' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_external' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_pdfviewer' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_sharing' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_trashbin' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_versions' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'files_videoviewer' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'firstrunwizard' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'gitsmart' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'logreader' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature could not get verified.', ), ), 'password_policy' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'provisioning_api' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'sketch' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'threatblock' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'two_factor_auth' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'user_ldap' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), 'user_shibboleth' => array ( 'EXCEPTION' => array ( 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ), ), )));
- $expected = new DataDisplayResponse(
- 'Technical information
- =====================
- The following list covers which files have failed the integrity check. Please read
- the previous linked documentation to learn more about the errors and how to fix
- them.
- Results
- =======
- - core
- - EXTRA_FILE
- - /testfile
- - INVALID_HASH
- - /.idea/workspace.xml
- - /lib/private/integritycheck/checker.php
- - /settings/controller/checksetupcontroller.php
- - bookmarks
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - dav
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - encryption
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - external
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - federation
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - files
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - files_antivirus
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - files_drop
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - files_external
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - files_pdfviewer
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - files_sharing
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - files_trashbin
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - files_versions
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - files_videoviewer
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - firstrunwizard
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - gitsmart
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - logreader
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature could not get verified.
- - password_policy
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - provisioning_api
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - sketch
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - threatblock
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - two_factor_auth
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - user_ldap
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- - user_shibboleth
- - EXCEPTION
- - OC\IntegrityCheck\Exceptions\InvalidSignatureException
- - Signature data not found.
- Raw output
- ==========
- Array
- (
- [core] => Array
- (
- [EXTRA_FILE] => Array
- (
- [/testfile] => Array
- (
- )
- )
- [INVALID_HASH] => Array
- (
- [/.idea/workspace.xml] => Array
- (
- [expected] => f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216
- [current] => ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094
- )
- [/lib/private/integritycheck/checker.php] => Array
- (
- [expected] => c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea
- [current] => 88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585
- )
- [/settings/controller/checksetupcontroller.php] => Array
- (
- [expected] => 3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4
- [current] => 09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a
- )
- )
- )
- [bookmarks] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [dav] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [encryption] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [external] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [federation] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [files] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [files_antivirus] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [files_drop] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [files_external] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [files_pdfviewer] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [files_sharing] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [files_trashbin] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [files_versions] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [files_videoviewer] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [firstrunwizard] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [gitsmart] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [logreader] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature could not get verified.
- )
- )
- [password_policy] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [provisioning_api] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [sketch] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [threatblock] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [two_factor_auth] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [user_ldap] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- [user_shibboleth] => Array
- (
- [EXCEPTION] => Array
- (
- [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
- [message] => Signature data not found.
- )
- )
- )
- ',
- Http::STATUS_OK,
- [
- 'Content-Type' => 'text/plain',
- ]
- );
- $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
- }
- }
|