You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CheckSetupControllerTest.php 43KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  1. <?php
  2. /**
  3. * @author Lukas Reschke <lukas@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace Tests\Settings\Controller;
  22. use OC\DB\Connection;
  23. use OC\MemoryInfo;
  24. use OC\Settings\Controller\CheckSetupController;
  25. use OCP\AppFramework\Http;
  26. use OCP\AppFramework\Http\DataDisplayResponse;
  27. use OCP\AppFramework\Http\DataResponse;
  28. use OCP\AppFramework\Http\RedirectResponse;
  29. use OCP\Http\Client\IClientService;
  30. use OCP\IConfig;
  31. use OCP\IDateTimeFormatter;
  32. use OCP\IL10N;
  33. use OCP\ILogger;
  34. use OCP\IRequest;
  35. use OCP\IURLGenerator;
  36. use OC_Util;
  37. use OCP\Lock\ILockingProvider;
  38. use PHPUnit\Framework\MockObject\MockObject;
  39. use Psr\Http\Message\ResponseInterface;
  40. use Symfony\Component\EventDispatcher\EventDispatcher;
  41. use Test\TestCase;
  42. use OC\IntegrityCheck\Checker;
  43. /**
  44. * Class CheckSetupControllerTest
  45. *
  46. * @package Tests\Settings\Controller
  47. */
  48. class CheckSetupControllerTest extends TestCase {
  49. /** @var CheckSetupController | \PHPUnit_Framework_MockObject_MockObject */
  50. private $checkSetupController;
  51. /** @var IRequest | \PHPUnit_Framework_MockObject_MockObject */
  52. private $request;
  53. /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
  54. private $config;
  55. /** @var IClientService | \PHPUnit_Framework_MockObject_MockObject*/
  56. private $clientService;
  57. /** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject */
  58. private $urlGenerator;
  59. /** @var OC_Util */
  60. private $util;
  61. /** @var IL10N | \PHPUnit_Framework_MockObject_MockObject */
  62. private $l10n;
  63. /** @var ILogger */
  64. private $logger;
  65. /** @var Checker|\PHPUnit_Framework_MockObject_MockObject */
  66. private $checker;
  67. /** @var EventDispatcher|\PHPUnit_Framework_MockObject_MockObject */
  68. private $dispatcher;
  69. /** @var Connection|\PHPUnit_Framework_MockObject_MockObject */
  70. private $db;
  71. /** @var ILockingProvider|\PHPUnit_Framework_MockObject_MockObject */
  72. private $lockingProvider;
  73. /** @var IDateTimeFormatter|\PHPUnit_Framework_MockObject_MockObject */
  74. private $dateTimeFormatter;
  75. /** @var MemoryInfo|MockObject */
  76. private $memoryInfo;
  77. /**
  78. * Backup of the "memory_limit" ini value before tests.
  79. *
  80. * @var string
  81. */
  82. private $memoryLimitIniValueBeforeTest;
  83. public function setUp() {
  84. parent::setUp();
  85. $this->request = $this->getMockBuilder(IRequest::class)
  86. ->disableOriginalConstructor()->getMock();
  87. $this->config = $this->getMockBuilder(IConfig::class)
  88. ->disableOriginalConstructor()->getMock();
  89. $this->clientService = $this->getMockBuilder(IClientService::class)
  90. ->disableOriginalConstructor()->getMock();
  91. $this->util = $this->getMockBuilder('\OC_Util')
  92. ->disableOriginalConstructor()->getMock();
  93. $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)
  94. ->disableOriginalConstructor()->getMock();
  95. $this->l10n = $this->getMockBuilder(IL10N::class)
  96. ->disableOriginalConstructor()->getMock();
  97. $this->l10n->expects($this->any())
  98. ->method('t')
  99. ->will($this->returnCallback(function($message, array $replace) {
  100. return vsprintf($message, $replace);
  101. }));
  102. $this->dispatcher = $this->getMockBuilder(EventDispatcher::class)
  103. ->disableOriginalConstructor()->getMock();
  104. $this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
  105. ->disableOriginalConstructor()->getMock();
  106. $this->logger = $this->getMockBuilder(ILogger::class)->getMock();
  107. $this->db = $this->getMockBuilder(Connection::class)
  108. ->disableOriginalConstructor()->getMock();
  109. $this->lockingProvider = $this->getMockBuilder(ILockingProvider::class)->getMock();
  110. $this->dateTimeFormatter = $this->getMockBuilder(IDateTimeFormatter::class)->getMock();
  111. $this->memoryInfo = $this->getMockBuilder(MemoryInfo::class)
  112. ->setMethods(['getMemoryLimit',])
  113. ->getMock();
  114. $this->checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
  115. ->setConstructorArgs([
  116. 'settings',
  117. $this->request,
  118. $this->config,
  119. $this->clientService,
  120. $this->urlGenerator,
  121. $this->util,
  122. $this->l10n,
  123. $this->checker,
  124. $this->logger,
  125. $this->dispatcher,
  126. $this->db,
  127. $this->lockingProvider,
  128. $this->dateTimeFormatter,
  129. $this->memoryInfo,
  130. ])
  131. ->setMethods([
  132. 'isReadOnlyConfig',
  133. 'hasValidTransactionIsolationLevel',
  134. 'hasFileinfoInstalled',
  135. 'hasWorkingFileLocking',
  136. 'getLastCronInfo',
  137. 'getSuggestedOverwriteCliURL',
  138. 'getOutdatedCaches',
  139. 'getCurlVersion',
  140. 'isPhpOutdated',
  141. 'isOpcacheProperlySetup',
  142. 'hasFreeTypeSupport',
  143. 'hasMissingIndexes',
  144. 'isSqliteUsed',
  145. 'isPhpMailerUsed',
  146. 'hasOpcacheLoaded',
  147. ])->getMock();
  148. }
  149. public function testIsInternetConnectionWorkingDisabledViaConfig() {
  150. $this->config->expects($this->once())
  151. ->method('getSystemValue')
  152. ->with('has_internet_connection', true)
  153. ->will($this->returnValue(false));
  154. $this->assertFalse(
  155. self::invokePrivate(
  156. $this->checkSetupController,
  157. 'isInternetConnectionWorking'
  158. )
  159. );
  160. }
  161. public function testIsInternetConnectionWorkingCorrectly() {
  162. $this->config->expects($this->once())
  163. ->method('getSystemValue')
  164. ->with('has_internet_connection', true)
  165. ->will($this->returnValue(true));
  166. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  167. ->disableOriginalConstructor()->getMock();
  168. $client->expects($this->any())
  169. ->method('get');
  170. $this->clientService->expects($this->once())
  171. ->method('newClient')
  172. ->will($this->returnValue($client));
  173. $this->assertTrue(
  174. self::invokePrivate(
  175. $this->checkSetupController,
  176. 'isInternetConnectionWorking'
  177. )
  178. );
  179. }
  180. public function testIsInternetConnectionFail() {
  181. $this->config->expects($this->once())
  182. ->method('getSystemValue')
  183. ->with('has_internet_connection', true)
  184. ->will($this->returnValue(true));
  185. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  186. ->disableOriginalConstructor()->getMock();
  187. $client->expects($this->any())
  188. ->method('get')
  189. ->will($this->throwException(new \Exception()));
  190. $this->clientService->expects($this->exactly(4))
  191. ->method('newClient')
  192. ->will($this->returnValue($client));
  193. $this->assertFalse(
  194. self::invokePrivate(
  195. $this->checkSetupController,
  196. 'isInternetConnectionWorking'
  197. )
  198. );
  199. }
  200. public function testIsMemcacheConfiguredFalse() {
  201. $this->config->expects($this->once())
  202. ->method('getSystemValue')
  203. ->with('memcache.local', null)
  204. ->will($this->returnValue(null));
  205. $this->assertFalse(
  206. self::invokePrivate(
  207. $this->checkSetupController,
  208. 'isMemcacheConfigured'
  209. )
  210. );
  211. }
  212. public function testIsMemcacheConfiguredTrue() {
  213. $this->config->expects($this->once())
  214. ->method('getSystemValue')
  215. ->with('memcache.local', null)
  216. ->will($this->returnValue('SomeProvider'));
  217. $this->assertTrue(
  218. self::invokePrivate(
  219. $this->checkSetupController,
  220. 'isMemcacheConfigured'
  221. )
  222. );
  223. }
  224. public function testIsPhpSupportedFalse() {
  225. $this->checkSetupController
  226. ->expects($this->once())
  227. ->method('isPhpOutdated')
  228. ->willReturn(true);
  229. $this->assertEquals(
  230. ['eol' => true, 'version' => PHP_VERSION],
  231. self::invokePrivate($this->checkSetupController, 'isPhpSupported')
  232. );
  233. }
  234. public function testIsPhpSupportedTrue() {
  235. $this->checkSetupController
  236. ->expects($this->exactly(2))
  237. ->method('isPhpOutdated')
  238. ->willReturn(false);
  239. $this->assertEquals(
  240. ['eol' => false, 'version' => PHP_VERSION],
  241. self::invokePrivate($this->checkSetupController, 'isPhpSupported')
  242. );
  243. $this->assertEquals(
  244. ['eol' => false, 'version' => PHP_VERSION],
  245. self::invokePrivate($this->checkSetupController, 'isPhpSupported')
  246. );
  247. }
  248. public function testForwardedForHeadersWorkingFalse() {
  249. $this->config->expects($this->once())
  250. ->method('getSystemValue')
  251. ->with('trusted_proxies', [])
  252. ->willReturn(['1.2.3.4']);
  253. $this->request->expects($this->once())
  254. ->method('getRemoteAddress')
  255. ->willReturn('1.2.3.4');
  256. $this->assertFalse(
  257. self::invokePrivate(
  258. $this->checkSetupController,
  259. 'forwardedForHeadersWorking'
  260. )
  261. );
  262. }
  263. public function testForwardedForHeadersWorkingTrue() {
  264. $this->config->expects($this->once())
  265. ->method('getSystemValue')
  266. ->with('trusted_proxies', [])
  267. ->willReturn(['1.2.3.4']);
  268. $this->request->expects($this->once())
  269. ->method('getRemoteAddress')
  270. ->willReturn('4.3.2.1');
  271. $this->assertTrue(
  272. self::invokePrivate(
  273. $this->checkSetupController,
  274. 'forwardedForHeadersWorking'
  275. )
  276. );
  277. }
  278. public function testCheck() {
  279. $this->config->expects($this->at(0))
  280. ->method('getAppValue')
  281. ->with('core', 'cronErrors')
  282. ->willReturn('');
  283. $this->config->expects($this->at(2))
  284. ->method('getSystemValue')
  285. ->with('memcache.local', null)
  286. ->will($this->returnValue('SomeProvider'));
  287. $this->config->expects($this->at(3))
  288. ->method('getSystemValue')
  289. ->with('has_internet_connection', true)
  290. ->will($this->returnValue(true));
  291. $this->config->expects($this->at(4))
  292. ->method('getSystemValue')
  293. ->with('appstoreenabled', true)
  294. ->will($this->returnValue(false));
  295. $this->request->expects($this->once())
  296. ->method('getRemoteAddress')
  297. ->willReturn('4.3.2.1');
  298. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  299. ->disableOriginalConstructor()->getMock();
  300. $client->expects($this->at(0))
  301. ->method('get')
  302. ->with('http://www.nextcloud.com/', [])
  303. ->will($this->throwException(new \Exception()));
  304. $client->expects($this->at(1))
  305. ->method('get')
  306. ->with('http://www.startpage.com/', [])
  307. ->will($this->throwException(new \Exception()));
  308. $client->expects($this->at(2))
  309. ->method('get')
  310. ->with('http://www.eff.org/', [])
  311. ->will($this->throwException(new \Exception()));
  312. $client->expects($this->at(3))
  313. ->method('get')
  314. ->with('http://www.edri.org/', [])
  315. ->will($this->throwException(new \Exception()));
  316. $this->clientService->expects($this->exactly(4))
  317. ->method('newClient')
  318. ->will($this->returnValue($client));
  319. $this->urlGenerator->expects($this->at(0))
  320. ->method('linkToDocs')
  321. ->with('admin-performance')
  322. ->willReturn('http://docs.example.org/server/go.php?to=admin-performance');
  323. $this->urlGenerator->expects($this->at(1))
  324. ->method('linkToDocs')
  325. ->with('admin-security')
  326. ->willReturn('https://docs.example.org/server/8.1/admin_manual/configuration_server/hardening.html');
  327. $this->checkSetupController
  328. ->expects($this->once())
  329. ->method('isPhpOutdated')
  330. ->willReturn(true);
  331. $this->checkSetupController
  332. ->expects($this->once())
  333. ->method('isOpcacheProperlySetup')
  334. ->willReturn(false);
  335. $this->urlGenerator->expects($this->at(2))
  336. ->method('linkToDocs')
  337. ->with('admin-reverse-proxy')
  338. ->willReturn('reverse-proxy-doc-link');
  339. $this->urlGenerator->expects($this->at(3))
  340. ->method('linkToDocs')
  341. ->with('admin-code-integrity')
  342. ->willReturn('http://docs.example.org/server/go.php?to=admin-code-integrity');
  343. $this->urlGenerator->expects($this->at(4))
  344. ->method('linkToDocs')
  345. ->with('admin-php-opcache')
  346. ->willReturn('http://docs.example.org/server/go.php?to=admin-php-opcache');
  347. $this->urlGenerator->expects($this->at(5))
  348. ->method('linkToDocs')
  349. ->with('admin-db-conversion')
  350. ->willReturn('http://docs.example.org/server/go.php?to=admin-db-conversion');
  351. $this->urlGenerator->expects($this->at(6))
  352. ->method('getAbsoluteURL')
  353. ->with('index.php/settings/admin')
  354. ->willReturn('https://server/index.php/settings/admin');
  355. $this->checkSetupController
  356. ->method('hasFreeTypeSupport')
  357. ->willReturn(false);
  358. $this->checkSetupController
  359. ->method('hasMissingIndexes')
  360. ->willReturn([]);
  361. $this->checkSetupController
  362. ->method('getOutdatedCaches')
  363. ->willReturn([]);
  364. $this->checkSetupController
  365. ->method('isSqliteUsed')
  366. ->willReturn(false);
  367. $this->checkSetupController
  368. ->expects($this->once())
  369. ->method('isReadOnlyConfig')
  370. ->willReturn(false);
  371. $this->checkSetupController
  372. ->expects($this->once())
  373. ->method('hasValidTransactionIsolationLevel')
  374. ->willReturn(true);
  375. $this->checkSetupController
  376. ->expects($this->once())
  377. ->method('hasFileinfoInstalled')
  378. ->willReturn(true);
  379. $this->checkSetupController
  380. ->expects($this->once())
  381. ->method('hasOpcacheLoaded')
  382. ->willReturn(true);
  383. $this->checkSetupController
  384. ->expects($this->once())
  385. ->method('hasWorkingFileLocking')
  386. ->willReturn(true);
  387. $this->checkSetupController
  388. ->expects($this->once())
  389. ->method('getSuggestedOverwriteCliURL')
  390. ->willReturn('');
  391. $this->checkSetupController
  392. ->expects($this->once())
  393. ->method('getLastCronInfo')
  394. ->willReturn([
  395. 'diffInSeconds' => 123,
  396. 'relativeTime' => '2 hours ago',
  397. 'backgroundJobsUrl' => 'https://example.org',
  398. ]);
  399. $this->checkSetupController
  400. ->expects($this->once())
  401. ->method('isPhpMailerUsed')
  402. ->willReturn(false);
  403. $this->checker
  404. ->expects($this->once())
  405. ->method('hasPassedCheck')
  406. ->willReturn(true);
  407. $this->memoryInfo
  408. ->method('getMemoryLimit')
  409. ->willReturn(512 * 1024 * 1024);
  410. $expected = new DataResponse(
  411. [
  412. 'isGetenvServerWorking' => true,
  413. 'isReadOnlyConfig' => false,
  414. 'hasValidTransactionIsolationLevel' => true,
  415. 'outdatedCaches' => [],
  416. 'hasFileinfoInstalled' => true,
  417. 'hasWorkingFileLocking' => true,
  418. 'suggestedOverwriteCliURL' => '',
  419. 'cronInfo' => [
  420. 'diffInSeconds' => 123,
  421. 'relativeTime' => '2 hours ago',
  422. 'backgroundJobsUrl' => 'https://example.org',
  423. ],
  424. 'cronErrors' => [],
  425. 'serverHasInternetConnection' => false,
  426. 'isMemcacheConfigured' => true,
  427. 'memcacheDocs' => 'http://docs.example.org/server/go.php?to=admin-performance',
  428. 'isUrandomAvailable' => self::invokePrivate($this->checkSetupController, 'isUrandomAvailable'),
  429. 'securityDocs' => 'https://docs.example.org/server/8.1/admin_manual/configuration_server/hardening.html',
  430. 'isUsedTlsLibOutdated' => '',
  431. 'phpSupported' => [
  432. 'eol' => true,
  433. 'version' => PHP_VERSION
  434. ],
  435. 'forwardedForHeadersWorking' => true,
  436. 'reverseProxyDocs' => 'reverse-proxy-doc-link',
  437. 'isCorrectMemcachedPHPModuleInstalled' => true,
  438. 'hasPassedCodeIntegrityCheck' => true,
  439. 'codeIntegrityCheckerDocumentation' => 'http://docs.example.org/server/go.php?to=admin-code-integrity',
  440. 'isOpcacheProperlySetup' => false,
  441. 'hasOpcacheLoaded' => true,
  442. 'phpOpcacheDocumentation' => 'http://docs.example.org/server/go.php?to=admin-php-opcache',
  443. 'isSettimelimitAvailable' => true,
  444. 'hasFreeTypeSupport' => false,
  445. 'isSqliteUsed' => false,
  446. 'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion',
  447. 'missingIndexes' => [],
  448. 'isPhpMailerUsed' => false,
  449. 'mailSettingsDocumentation' => 'https://server/index.php/settings/admin',
  450. 'isTheMemoryLimitHighEnough' => true,
  451. ]
  452. );
  453. $this->assertEquals($expected, $this->checkSetupController->check());
  454. }
  455. public function testGetCurlVersion() {
  456. $checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
  457. ->setConstructorArgs([
  458. 'settings',
  459. $this->request,
  460. $this->config,
  461. $this->clientService,
  462. $this->urlGenerator,
  463. $this->util,
  464. $this->l10n,
  465. $this->checker,
  466. $this->logger,
  467. $this->dispatcher,
  468. $this->db,
  469. $this->lockingProvider,
  470. $this->dateTimeFormatter,
  471. $this->memoryInfo,
  472. ])
  473. ->setMethods(null)->getMock();
  474. $this->assertArrayHasKey('ssl_version', $this->invokePrivate($checkSetupController, 'getCurlVersion'));
  475. }
  476. public function testIsUsedTlsLibOutdatedWithAnotherLibrary() {
  477. $this->config->expects($this->any())
  478. ->method('getSystemValue')
  479. ->will($this->returnValue(true));
  480. $this->checkSetupController
  481. ->expects($this->once())
  482. ->method('getCurlVersion')
  483. ->will($this->returnValue(['ssl_version' => 'SSLlib']));
  484. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  485. }
  486. public function testIsUsedTlsLibOutdatedWithMisbehavingCurl() {
  487. $this->config->expects($this->any())
  488. ->method('getSystemValue')
  489. ->will($this->returnValue(true));
  490. $this->checkSetupController
  491. ->expects($this->once())
  492. ->method('getCurlVersion')
  493. ->will($this->returnValue([]));
  494. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  495. }
  496. public function testIsUsedTlsLibOutdatedWithOlderOpenSsl() {
  497. $this->config->expects($this->any())
  498. ->method('getSystemValue')
  499. ->will($this->returnValue(true));
  500. $this->checkSetupController
  501. ->expects($this->once())
  502. ->method('getCurlVersion')
  503. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1c']));
  504. $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'));
  505. }
  506. public function testIsUsedTlsLibOutdatedWithOlderOpenSslAndWithoutAppstore() {
  507. $this->config
  508. ->expects($this->at(0))
  509. ->method('getSystemValue')
  510. ->with('has_internet_connection', true)
  511. ->will($this->returnValue(true));
  512. $this->checkSetupController
  513. ->expects($this->once())
  514. ->method('getCurlVersion')
  515. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1c']));
  516. $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'));
  517. }
  518. public function testIsUsedTlsLibOutdatedWithOlderOpenSsl1() {
  519. $this->config->expects($this->any())
  520. ->method('getSystemValue')
  521. ->will($this->returnValue(true));
  522. $this->checkSetupController
  523. ->expects($this->once())
  524. ->method('getCurlVersion')
  525. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.2a']));
  526. $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'));
  527. }
  528. public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion() {
  529. $this->config->expects($this->any())
  530. ->method('getSystemValue')
  531. ->will($this->returnValue(true));
  532. $this->checkSetupController
  533. ->expects($this->once())
  534. ->method('getCurlVersion')
  535. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1d']));
  536. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  537. }
  538. public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion1() {
  539. $this->config->expects($this->any())
  540. ->method('getSystemValue')
  541. ->will($this->returnValue(true));
  542. $this->checkSetupController
  543. ->expects($this->once())
  544. ->method('getCurlVersion')
  545. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.2b']));
  546. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  547. }
  548. public function testIsBuggyNss400() {
  549. $this->config->expects($this->any())
  550. ->method('getSystemValue')
  551. ->will($this->returnValue(true));
  552. $this->checkSetupController
  553. ->expects($this->once())
  554. ->method('getCurlVersion')
  555. ->will($this->returnValue(['ssl_version' => 'NSS/1.0.2b']));
  556. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  557. ->disableOriginalConstructor()->getMock();
  558. $exception = $this->getMockBuilder('\GuzzleHttp\Exception\ClientException')
  559. ->disableOriginalConstructor()->getMock();
  560. $response = $this->getMockBuilder(ResponseInterface::class)
  561. ->disableOriginalConstructor()->getMock();
  562. $response->expects($this->once())
  563. ->method('getStatusCode')
  564. ->will($this->returnValue(400));
  565. $exception->expects($this->once())
  566. ->method('getResponse')
  567. ->will($this->returnValue($response));
  568. $client->expects($this->at(0))
  569. ->method('get')
  570. ->with('https://nextcloud.com/', [])
  571. ->will($this->throwException($exception));
  572. $this->clientService->expects($this->once())
  573. ->method('newClient')
  574. ->will($this->returnValue($client));
  575. $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'));
  576. }
  577. public function testIsBuggyNss200() {
  578. $this->config->expects($this->any())
  579. ->method('getSystemValue')
  580. ->will($this->returnValue(true));
  581. $this->checkSetupController
  582. ->expects($this->once())
  583. ->method('getCurlVersion')
  584. ->will($this->returnValue(['ssl_version' => 'NSS/1.0.2b']));
  585. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  586. ->disableOriginalConstructor()->getMock();
  587. $exception = $this->getMockBuilder('\GuzzleHttp\Exception\ClientException')
  588. ->disableOriginalConstructor()->getMock();
  589. $response = $this->getMockBuilder(ResponseInterface::class)
  590. ->disableOriginalConstructor()->getMock();
  591. $response->expects($this->once())
  592. ->method('getStatusCode')
  593. ->will($this->returnValue(200));
  594. $exception->expects($this->once())
  595. ->method('getResponse')
  596. ->will($this->returnValue($response));
  597. $client->expects($this->at(0))
  598. ->method('get')
  599. ->with('https://nextcloud.com/', [])
  600. ->will($this->throwException($exception));
  601. $this->clientService->expects($this->once())
  602. ->method('newClient')
  603. ->will($this->returnValue($client));
  604. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  605. }
  606. public function testIsUsedTlsLibOutdatedWithInternetDisabled() {
  607. $this->config
  608. ->expects($this->at(0))
  609. ->method('getSystemValue')
  610. ->with('has_internet_connection', true)
  611. ->will($this->returnValue(false));
  612. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  613. }
  614. public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingEnabled() {
  615. $this->config
  616. ->expects($this->at(0))
  617. ->method('getSystemValue')
  618. ->with('has_internet_connection', true)
  619. ->will($this->returnValue(true));
  620. $this->config
  621. ->expects($this->at(1))
  622. ->method('getSystemValue')
  623. ->with('appstoreenabled', true)
  624. ->will($this->returnValue(false));
  625. $this->config
  626. ->expects($this->at(2))
  627. ->method('getAppValue')
  628. ->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
  629. ->will($this->returnValue('no'));
  630. $this->config
  631. ->expects($this->at(3))
  632. ->method('getAppValue')
  633. ->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
  634. ->will($this->returnValue('yes'));
  635. $this->checkSetupController
  636. ->expects($this->once())
  637. ->method('getCurlVersion')
  638. ->will($this->returnValue([]));
  639. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  640. }
  641. public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingDisabled() {
  642. $this->config
  643. ->expects($this->at(0))
  644. ->method('getSystemValue')
  645. ->with('has_internet_connection', true)
  646. ->will($this->returnValue(true));
  647. $this->config
  648. ->expects($this->at(1))
  649. ->method('getSystemValue')
  650. ->with('appstoreenabled', true)
  651. ->will($this->returnValue(false));
  652. $this->config
  653. ->expects($this->at(2))
  654. ->method('getAppValue')
  655. ->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
  656. ->will($this->returnValue('no'));
  657. $this->config
  658. ->expects($this->at(3))
  659. ->method('getAppValue')
  660. ->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
  661. ->will($this->returnValue('no'));
  662. $this->checkSetupController
  663. ->expects($this->never())
  664. ->method('getCurlVersion')
  665. ->will($this->returnValue([]));
  666. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  667. }
  668. public function testRescanFailedIntegrityCheck() {
  669. $this->checker
  670. ->expects($this->once())
  671. ->method('runInstanceVerification');
  672. $this->urlGenerator
  673. ->expects($this->once())
  674. ->method('linkToRoute')
  675. ->with('settings.AdminSettings.index')
  676. ->will($this->returnValue('/admin'));
  677. $expected = new RedirectResponse('/admin');
  678. $this->assertEquals($expected, $this->checkSetupController->rescanFailedIntegrityCheck());
  679. }
  680. public function testGetFailedIntegrityCheckDisabled() {
  681. $this->checker
  682. ->expects($this->once())
  683. ->method('isCodeCheckEnforced')
  684. ->willReturn(false);
  685. $expected = new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
  686. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  687. }
  688. public function testGetFailedIntegrityCheckFilesWithNoErrorsFound() {
  689. $this->checker
  690. ->expects($this->once())
  691. ->method('isCodeCheckEnforced')
  692. ->willReturn(true);
  693. $this->checker
  694. ->expects($this->once())
  695. ->method('getResults')
  696. ->will($this->returnValue([]));
  697. $expected = new DataDisplayResponse(
  698. 'No errors have been found.',
  699. Http::STATUS_OK,
  700. [
  701. 'Content-Type' => 'text/plain',
  702. ]
  703. );
  704. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  705. }
  706. public function testGetFailedIntegrityCheckFilesWithSomeErrorsFound() {
  707. $this->checker
  708. ->expects($this->once())
  709. ->method('isCodeCheckEnforced')
  710. ->willReturn(true);
  711. $this->checker
  712. ->expects($this->once())
  713. ->method('getResults')
  714. ->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.', ), ), )));
  715. $expected = new DataDisplayResponse(
  716. 'Technical information
  717. =====================
  718. The following list covers which files have failed the integrity check. Please read
  719. the previous linked documentation to learn more about the errors and how to fix
  720. them.
  721. Results
  722. =======
  723. - core
  724. - EXTRA_FILE
  725. - /testfile
  726. - INVALID_HASH
  727. - /.idea/workspace.xml
  728. - /lib/private/integritycheck/checker.php
  729. - /settings/controller/checksetupcontroller.php
  730. - bookmarks
  731. - EXCEPTION
  732. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  733. - Signature data not found.
  734. - dav
  735. - EXCEPTION
  736. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  737. - Signature data not found.
  738. - encryption
  739. - EXCEPTION
  740. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  741. - Signature data not found.
  742. - external
  743. - EXCEPTION
  744. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  745. - Signature data not found.
  746. - federation
  747. - EXCEPTION
  748. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  749. - Signature data not found.
  750. - files
  751. - EXCEPTION
  752. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  753. - Signature data not found.
  754. - files_antivirus
  755. - EXCEPTION
  756. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  757. - Signature data not found.
  758. - files_drop
  759. - EXCEPTION
  760. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  761. - Signature data not found.
  762. - files_external
  763. - EXCEPTION
  764. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  765. - Signature data not found.
  766. - files_pdfviewer
  767. - EXCEPTION
  768. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  769. - Signature data not found.
  770. - files_sharing
  771. - EXCEPTION
  772. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  773. - Signature data not found.
  774. - files_trashbin
  775. - EXCEPTION
  776. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  777. - Signature data not found.
  778. - files_versions
  779. - EXCEPTION
  780. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  781. - Signature data not found.
  782. - files_videoviewer
  783. - EXCEPTION
  784. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  785. - Signature data not found.
  786. - firstrunwizard
  787. - EXCEPTION
  788. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  789. - Signature data not found.
  790. - gitsmart
  791. - EXCEPTION
  792. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  793. - Signature data not found.
  794. - logreader
  795. - EXCEPTION
  796. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  797. - Signature could not get verified.
  798. - password_policy
  799. - EXCEPTION
  800. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  801. - Signature data not found.
  802. - provisioning_api
  803. - EXCEPTION
  804. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  805. - Signature data not found.
  806. - sketch
  807. - EXCEPTION
  808. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  809. - Signature data not found.
  810. - threatblock
  811. - EXCEPTION
  812. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  813. - Signature data not found.
  814. - two_factor_auth
  815. - EXCEPTION
  816. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  817. - Signature data not found.
  818. - user_ldap
  819. - EXCEPTION
  820. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  821. - Signature data not found.
  822. - user_shibboleth
  823. - EXCEPTION
  824. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  825. - Signature data not found.
  826. Raw output
  827. ==========
  828. Array
  829. (
  830. [core] => Array
  831. (
  832. [EXTRA_FILE] => Array
  833. (
  834. [/testfile] => Array
  835. (
  836. )
  837. )
  838. [INVALID_HASH] => Array
  839. (
  840. [/.idea/workspace.xml] => Array
  841. (
  842. [expected] => f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216
  843. [current] => ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094
  844. )
  845. [/lib/private/integritycheck/checker.php] => Array
  846. (
  847. [expected] => c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea
  848. [current] => 88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585
  849. )
  850. [/settings/controller/checksetupcontroller.php] => Array
  851. (
  852. [expected] => 3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4
  853. [current] => 09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a
  854. )
  855. )
  856. )
  857. [bookmarks] => Array
  858. (
  859. [EXCEPTION] => Array
  860. (
  861. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  862. [message] => Signature data not found.
  863. )
  864. )
  865. [dav] => Array
  866. (
  867. [EXCEPTION] => Array
  868. (
  869. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  870. [message] => Signature data not found.
  871. )
  872. )
  873. [encryption] => Array
  874. (
  875. [EXCEPTION] => Array
  876. (
  877. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  878. [message] => Signature data not found.
  879. )
  880. )
  881. [external] => Array
  882. (
  883. [EXCEPTION] => Array
  884. (
  885. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  886. [message] => Signature data not found.
  887. )
  888. )
  889. [federation] => Array
  890. (
  891. [EXCEPTION] => Array
  892. (
  893. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  894. [message] => Signature data not found.
  895. )
  896. )
  897. [files] => Array
  898. (
  899. [EXCEPTION] => Array
  900. (
  901. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  902. [message] => Signature data not found.
  903. )
  904. )
  905. [files_antivirus] => Array
  906. (
  907. [EXCEPTION] => Array
  908. (
  909. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  910. [message] => Signature data not found.
  911. )
  912. )
  913. [files_drop] => Array
  914. (
  915. [EXCEPTION] => Array
  916. (
  917. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  918. [message] => Signature data not found.
  919. )
  920. )
  921. [files_external] => Array
  922. (
  923. [EXCEPTION] => Array
  924. (
  925. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  926. [message] => Signature data not found.
  927. )
  928. )
  929. [files_pdfviewer] => Array
  930. (
  931. [EXCEPTION] => Array
  932. (
  933. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  934. [message] => Signature data not found.
  935. )
  936. )
  937. [files_sharing] => Array
  938. (
  939. [EXCEPTION] => Array
  940. (
  941. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  942. [message] => Signature data not found.
  943. )
  944. )
  945. [files_trashbin] => Array
  946. (
  947. [EXCEPTION] => Array
  948. (
  949. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  950. [message] => Signature data not found.
  951. )
  952. )
  953. [files_versions] => Array
  954. (
  955. [EXCEPTION] => Array
  956. (
  957. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  958. [message] => Signature data not found.
  959. )
  960. )
  961. [files_videoviewer] => Array
  962. (
  963. [EXCEPTION] => Array
  964. (
  965. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  966. [message] => Signature data not found.
  967. )
  968. )
  969. [firstrunwizard] => Array
  970. (
  971. [EXCEPTION] => Array
  972. (
  973. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  974. [message] => Signature data not found.
  975. )
  976. )
  977. [gitsmart] => Array
  978. (
  979. [EXCEPTION] => Array
  980. (
  981. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  982. [message] => Signature data not found.
  983. )
  984. )
  985. [logreader] => Array
  986. (
  987. [EXCEPTION] => Array
  988. (
  989. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  990. [message] => Signature could not get verified.
  991. )
  992. )
  993. [password_policy] => Array
  994. (
  995. [EXCEPTION] => Array
  996. (
  997. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  998. [message] => Signature data not found.
  999. )
  1000. )
  1001. [provisioning_api] => Array
  1002. (
  1003. [EXCEPTION] => Array
  1004. (
  1005. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1006. [message] => Signature data not found.
  1007. )
  1008. )
  1009. [sketch] => Array
  1010. (
  1011. [EXCEPTION] => Array
  1012. (
  1013. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1014. [message] => Signature data not found.
  1015. )
  1016. )
  1017. [threatblock] => Array
  1018. (
  1019. [EXCEPTION] => Array
  1020. (
  1021. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1022. [message] => Signature data not found.
  1023. )
  1024. )
  1025. [two_factor_auth] => Array
  1026. (
  1027. [EXCEPTION] => Array
  1028. (
  1029. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1030. [message] => Signature data not found.
  1031. )
  1032. )
  1033. [user_ldap] => Array
  1034. (
  1035. [EXCEPTION] => Array
  1036. (
  1037. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1038. [message] => Signature data not found.
  1039. )
  1040. )
  1041. [user_shibboleth] => Array
  1042. (
  1043. [EXCEPTION] => Array
  1044. (
  1045. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1046. [message] => Signature data not found.
  1047. )
  1048. )
  1049. )
  1050. ',
  1051. Http::STATUS_OK,
  1052. [
  1053. 'Content-Type' => 'text/plain',
  1054. ]
  1055. );
  1056. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  1057. }
  1058. /**
  1059. * This function returns test values for the memory limit check.
  1060. * 1. the memory limit
  1061. * 2. the expected check value
  1062. *
  1063. * @return array
  1064. */
  1065. public function getMemoryLimitTestData(): array {
  1066. return [
  1067. 'unlimited' => [-1, true,],
  1068. '512M' => [512 * 1024 * 1024, true,],
  1069. '1G' => [1024 * 1024 * 1024, true,],
  1070. '64M' => [64 * 1024 * 1024, false,],
  1071. ];
  1072. }
  1073. /**
  1074. * Tests that if the memory limit is high enough, there is no message.
  1075. *
  1076. * @param string $memoryLimit The memory limit reported by MemoryInfo.
  1077. * @param bool $expected The expected memory check return value.
  1078. * @dataProvider getMemoryLimitTestData
  1079. */
  1080. public function testMemoryLimit(string $memoryLimit, bool $expected) {
  1081. $this->memoryInfo
  1082. ->method('getMemoryLimit')
  1083. ->willReturn($memoryLimit);
  1084. $this->assertSame(
  1085. $expected,
  1086. $this->invokePrivate($this->checkSetupController, 'isTheMemoryLimitHighEnough')
  1087. );
  1088. }
  1089. }