CheckSetupControllerTest.php 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439
  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;
  23. use OC\DB\Connection;
  24. use OC\MemoryInfo;
  25. use OC\Security\SecureRandom;
  26. use OC\Settings\Controller\CheckSetupController;
  27. use OCP\AppFramework\Http;
  28. use OCP\AppFramework\Http\DataDisplayResponse;
  29. use OCP\AppFramework\Http\DataResponse;
  30. use OCP\AppFramework\Http\RedirectResponse;
  31. use OCP\Http\Client\IClientService;
  32. use OCP\IConfig;
  33. use OCP\IDateTimeFormatter;
  34. use OCP\IL10N;
  35. use OCP\ILogger;
  36. use OCP\IRequest;
  37. use OCP\IURLGenerator;
  38. use OC_Util;
  39. use OCP\Lock\ILockingProvider;
  40. use PHPUnit\Framework\MockObject\MockObject;
  41. use Psr\Http\Message\ResponseInterface;
  42. use Symfony\Component\EventDispatcher\EventDispatcher;
  43. use Test\TestCase;
  44. use OC\IntegrityCheck\Checker;
  45. /**
  46. * Class CheckSetupControllerTest
  47. *
  48. * @backupStaticAttributes
  49. * @package Tests\Settings\Controller
  50. */
  51. class CheckSetupControllerTest extends TestCase {
  52. /** @var CheckSetupController | \PHPUnit_Framework_MockObject_MockObject */
  53. private $checkSetupController;
  54. /** @var IRequest | \PHPUnit_Framework_MockObject_MockObject */
  55. private $request;
  56. /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
  57. private $config;
  58. /** @var IClientService | \PHPUnit_Framework_MockObject_MockObject*/
  59. private $clientService;
  60. /** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject */
  61. private $urlGenerator;
  62. /** @var OC_Util */
  63. private $util;
  64. /** @var IL10N | \PHPUnit_Framework_MockObject_MockObject */
  65. private $l10n;
  66. /** @var ILogger */
  67. private $logger;
  68. /** @var Checker|\PHPUnit_Framework_MockObject_MockObject */
  69. private $checker;
  70. /** @var EventDispatcher|\PHPUnit_Framework_MockObject_MockObject */
  71. private $dispatcher;
  72. /** @var Connection|\PHPUnit_Framework_MockObject_MockObject */
  73. private $db;
  74. /** @var ILockingProvider|\PHPUnit_Framework_MockObject_MockObject */
  75. private $lockingProvider;
  76. /** @var IDateTimeFormatter|\PHPUnit_Framework_MockObject_MockObject */
  77. private $dateTimeFormatter;
  78. /** @var MemoryInfo|MockObject */
  79. private $memoryInfo;
  80. /** @var SecureRandom|\PHPUnit_Framework_MockObject_MockObject */
  81. private $secureRandom;
  82. /**
  83. * Holds a list of directories created during tests.
  84. *
  85. * @var array
  86. */
  87. private $dirsToRemove = [];
  88. public function setUp() {
  89. parent::setUp();
  90. $this->request = $this->getMockBuilder(IRequest::class)
  91. ->disableOriginalConstructor()->getMock();
  92. $this->config = $this->getMockBuilder(IConfig::class)
  93. ->disableOriginalConstructor()->getMock();
  94. $this->clientService = $this->getMockBuilder(IClientService::class)
  95. ->disableOriginalConstructor()->getMock();
  96. $this->util = $this->getMockBuilder('\OC_Util')
  97. ->disableOriginalConstructor()->getMock();
  98. $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)
  99. ->disableOriginalConstructor()->getMock();
  100. $this->l10n = $this->getMockBuilder(IL10N::class)
  101. ->disableOriginalConstructor()->getMock();
  102. $this->l10n->expects($this->any())
  103. ->method('t')
  104. ->will($this->returnCallback(function($message, array $replace) {
  105. return vsprintf($message, $replace);
  106. }));
  107. $this->dispatcher = $this->getMockBuilder(EventDispatcher::class)
  108. ->disableOriginalConstructor()->getMock();
  109. $this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
  110. ->disableOriginalConstructor()->getMock();
  111. $this->logger = $this->getMockBuilder(ILogger::class)->getMock();
  112. $this->db = $this->getMockBuilder(Connection::class)
  113. ->disableOriginalConstructor()->getMock();
  114. $this->lockingProvider = $this->getMockBuilder(ILockingProvider::class)->getMock();
  115. $this->dateTimeFormatter = $this->getMockBuilder(IDateTimeFormatter::class)->getMock();
  116. $this->memoryInfo = $this->getMockBuilder(MemoryInfo::class)
  117. ->setMethods(['isMemoryLimitSufficient',])
  118. ->getMock();
  119. $this->secureRandom = $this->getMockBuilder(SecureRandom::class)->getMock();
  120. $this->checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
  121. ->setConstructorArgs([
  122. 'settings',
  123. $this->request,
  124. $this->config,
  125. $this->clientService,
  126. $this->urlGenerator,
  127. $this->util,
  128. $this->l10n,
  129. $this->checker,
  130. $this->logger,
  131. $this->dispatcher,
  132. $this->db,
  133. $this->lockingProvider,
  134. $this->dateTimeFormatter,
  135. $this->memoryInfo,
  136. $this->secureRandom,
  137. ])
  138. ->setMethods([
  139. 'isReadOnlyConfig',
  140. 'hasValidTransactionIsolationLevel',
  141. 'hasFileinfoInstalled',
  142. 'hasWorkingFileLocking',
  143. 'getLastCronInfo',
  144. 'getSuggestedOverwriteCliURL',
  145. 'getOutdatedCaches',
  146. 'getCurlVersion',
  147. 'isPhpOutdated',
  148. 'isOpcacheProperlySetup',
  149. 'hasFreeTypeSupport',
  150. 'hasMissingIndexes',
  151. 'isSqliteUsed',
  152. 'isPHPMailerUsed',
  153. 'hasOpcacheLoaded',
  154. 'getAppDirsWithDifferentOwner',
  155. 'hasRecommendedPHPModules',
  156. 'hasBigIntConversionPendingColumns',
  157. 'isMysqlUsedWithoutUTF8MB4',
  158. 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed',
  159. ])->getMock();
  160. }
  161. /**
  162. * Removes directories created during tests.
  163. *
  164. * @after
  165. * @return void
  166. */
  167. public function removeTestDirectories() {
  168. foreach ($this->dirsToRemove as $dirToRemove) {
  169. rmdir($dirToRemove);
  170. }
  171. $this->dirsToRemove = [];
  172. }
  173. public function testIsInternetConnectionWorkingDisabledViaConfig() {
  174. $this->config->expects($this->once())
  175. ->method('getSystemValue')
  176. ->with('has_internet_connection', true)
  177. ->will($this->returnValue(false));
  178. $this->assertFalse(
  179. self::invokePrivate(
  180. $this->checkSetupController,
  181. 'isInternetConnectionWorking'
  182. )
  183. );
  184. }
  185. public function testIsInternetConnectionWorkingCorrectly() {
  186. $this->config->expects($this->at(0))
  187. ->method('getSystemValue')
  188. ->with('has_internet_connection', true)
  189. ->will($this->returnValue(true));
  190. $this->config->expects($this->at(1))
  191. ->method('getSystemValue')
  192. ->with('connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'])
  193. ->will($this->returnValue(['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']));
  194. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  195. ->disableOriginalConstructor()->getMock();
  196. $client->expects($this->any())
  197. ->method('get');
  198. $this->clientService->expects($this->once())
  199. ->method('newClient')
  200. ->will($this->returnValue($client));
  201. $this->assertTrue(
  202. self::invokePrivate(
  203. $this->checkSetupController,
  204. 'isInternetConnectionWorking'
  205. )
  206. );
  207. }
  208. public function testIsInternetConnectionFail() {
  209. $this->config->expects($this->at(0))
  210. ->method('getSystemValue')
  211. ->with('has_internet_connection', true)
  212. ->will($this->returnValue(true));
  213. $this->config->expects($this->at(1))
  214. ->method('getSystemValue')
  215. ->with('connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'])
  216. ->will($this->returnValue(['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']));
  217. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  218. ->disableOriginalConstructor()->getMock();
  219. $client->expects($this->any())
  220. ->method('get')
  221. ->will($this->throwException(new \Exception()));
  222. $this->clientService->expects($this->exactly(4))
  223. ->method('newClient')
  224. ->will($this->returnValue($client));
  225. $this->assertFalse(
  226. self::invokePrivate(
  227. $this->checkSetupController,
  228. 'isInternetConnectionWorking'
  229. )
  230. );
  231. }
  232. public function testIsMemcacheConfiguredFalse() {
  233. $this->config->expects($this->once())
  234. ->method('getSystemValue')
  235. ->with('memcache.local', null)
  236. ->will($this->returnValue(null));
  237. $this->assertFalse(
  238. self::invokePrivate(
  239. $this->checkSetupController,
  240. 'isMemcacheConfigured'
  241. )
  242. );
  243. }
  244. public function testIsMemcacheConfiguredTrue() {
  245. $this->config->expects($this->once())
  246. ->method('getSystemValue')
  247. ->with('memcache.local', null)
  248. ->will($this->returnValue('SomeProvider'));
  249. $this->assertTrue(
  250. self::invokePrivate(
  251. $this->checkSetupController,
  252. 'isMemcacheConfigured'
  253. )
  254. );
  255. }
  256. public function testIsPhpSupportedFalse() {
  257. $this->checkSetupController
  258. ->expects($this->once())
  259. ->method('isPhpOutdated')
  260. ->willReturn(true);
  261. $this->assertEquals(
  262. ['eol' => true, 'version' => PHP_VERSION],
  263. self::invokePrivate($this->checkSetupController, 'isPhpSupported')
  264. );
  265. }
  266. public function testIsPhpSupportedTrue() {
  267. $this->checkSetupController
  268. ->expects($this->exactly(2))
  269. ->method('isPhpOutdated')
  270. ->willReturn(false);
  271. $this->assertEquals(
  272. ['eol' => false, 'version' => PHP_VERSION],
  273. self::invokePrivate($this->checkSetupController, 'isPhpSupported')
  274. );
  275. $this->assertEquals(
  276. ['eol' => false, 'version' => PHP_VERSION],
  277. self::invokePrivate($this->checkSetupController, 'isPhpSupported')
  278. );
  279. }
  280. /**
  281. * @dataProvider dataForwardedForHeadersWorking
  282. *
  283. * @param array $trustedProxies
  284. * @param string $remoteAddrNoForwarded
  285. * @param string $remoteAddr
  286. * @param bool $result
  287. */
  288. public function testForwardedForHeadersWorking(array $trustedProxies, string $remoteAddrNoForwarded, string $remoteAddr, bool $result) {
  289. $this->config->expects($this->once())
  290. ->method('getSystemValue')
  291. ->with('trusted_proxies', [])
  292. ->willReturn($trustedProxies);
  293. $this->request->expects($this->once())
  294. ->method('getHeader')
  295. ->with('REMOTE_ADDR')
  296. ->willReturn($remoteAddrNoForwarded);
  297. $this->request->expects($this->any())
  298. ->method('getRemoteAddress')
  299. ->willReturn($remoteAddr);
  300. $this->assertEquals(
  301. $result,
  302. self::invokePrivate($this->checkSetupController, 'forwardedForHeadersWorking')
  303. );
  304. }
  305. public function dataForwardedForHeadersWorking() {
  306. return [
  307. // description => trusted proxies, getHeader('REMOTE_ADDR'), getRemoteAddr, expected result
  308. 'no trusted proxies' => [[], '2.2.2.2', '2.2.2.2', true],
  309. 'trusted proxy, remote addr not trusted proxy' => [['1.1.1.1'], '2.2.2.2', '2.2.2.2', true],
  310. 'trusted proxy, remote addr is trusted proxy, x-forwarded-for working' => [['1.1.1.1'], '1.1.1.1', '2.2.2.2', true],
  311. 'trusted proxy, remote addr is trusted proxy, x-forwarded-for not set' => [['1.1.1.1'], '1.1.1.1', '1.1.1.1', false],
  312. ];
  313. }
  314. public function testCheck() {
  315. $this->config->expects($this->at(0))
  316. ->method('getAppValue')
  317. ->with('core', 'cronErrors')
  318. ->willReturn('');
  319. $this->config->expects($this->at(2))
  320. ->method('getSystemValue')
  321. ->with('connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'])
  322. ->will($this->returnValue(['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']));
  323. $this->config->expects($this->at(3))
  324. ->method('getSystemValue')
  325. ->with('memcache.local', null)
  326. ->will($this->returnValue('SomeProvider'));
  327. $this->config->expects($this->at(4))
  328. ->method('getSystemValue')
  329. ->with('has_internet_connection', true)
  330. ->will($this->returnValue(true));
  331. $this->config->expects($this->at(5))
  332. ->method('getSystemValue')
  333. ->with('appstoreenabled', true)
  334. ->will($this->returnValue(false));
  335. $this->request->expects($this->once())
  336. ->method('getHeader')
  337. ->with('REMOTE_ADDR')
  338. ->willReturn('4.3.2.1');
  339. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  340. ->disableOriginalConstructor()->getMock();
  341. $client->expects($this->at(0))
  342. ->method('get')
  343. ->with('http://www.nextcloud.com/', [])
  344. ->will($this->throwException(new \Exception()));
  345. $client->expects($this->at(1))
  346. ->method('get')
  347. ->with('http://www.startpage.com/', [])
  348. ->will($this->throwException(new \Exception()));
  349. $client->expects($this->at(2))
  350. ->method('get')
  351. ->with('http://www.eff.org/', [])
  352. ->will($this->throwException(new \Exception()));
  353. $client->expects($this->at(3))
  354. ->method('get')
  355. ->with('http://www.edri.org/', [])
  356. ->will($this->throwException(new \Exception()));
  357. $this->clientService->expects($this->exactly(4))
  358. ->method('newClient')
  359. ->will($this->returnValue($client));
  360. $this->urlGenerator->expects($this->at(0))
  361. ->method('linkToDocs')
  362. ->with('admin-performance')
  363. ->willReturn('http://docs.example.org/server/go.php?to=admin-performance');
  364. $this->urlGenerator->expects($this->at(1))
  365. ->method('linkToDocs')
  366. ->with('admin-security')
  367. ->willReturn('https://docs.example.org/server/8.1/admin_manual/configuration_server/hardening.html');
  368. $this->checkSetupController
  369. ->expects($this->once())
  370. ->method('isPhpOutdated')
  371. ->willReturn(true);
  372. $this->checkSetupController
  373. ->expects($this->once())
  374. ->method('isOpcacheProperlySetup')
  375. ->willReturn(false);
  376. $this->urlGenerator->expects($this->at(2))
  377. ->method('linkToDocs')
  378. ->with('admin-reverse-proxy')
  379. ->willReturn('reverse-proxy-doc-link');
  380. $this->urlGenerator->expects($this->at(3))
  381. ->method('linkToDocs')
  382. ->with('admin-code-integrity')
  383. ->willReturn('http://docs.example.org/server/go.php?to=admin-code-integrity');
  384. $this->urlGenerator->expects($this->at(4))
  385. ->method('linkToDocs')
  386. ->with('admin-php-opcache')
  387. ->willReturn('http://docs.example.org/server/go.php?to=admin-php-opcache');
  388. $this->urlGenerator->expects($this->at(5))
  389. ->method('linkToDocs')
  390. ->with('admin-db-conversion')
  391. ->willReturn('http://docs.example.org/server/go.php?to=admin-db-conversion');
  392. $this->urlGenerator->expects($this->at(6))
  393. ->method('getAbsoluteURL')
  394. ->with('index.php/settings/admin')
  395. ->willReturn('https://server/index.php/settings/admin');
  396. $this->checkSetupController
  397. ->method('hasFreeTypeSupport')
  398. ->willReturn(false);
  399. $this->checkSetupController
  400. ->method('hasMissingIndexes')
  401. ->willReturn([]);
  402. $this->checkSetupController
  403. ->method('getOutdatedCaches')
  404. ->willReturn([]);
  405. $this->checkSetupController
  406. ->method('isSqliteUsed')
  407. ->willReturn(false);
  408. $this->checkSetupController
  409. ->expects($this->once())
  410. ->method('isReadOnlyConfig')
  411. ->willReturn(false);
  412. $this->checkSetupController
  413. ->expects($this->once())
  414. ->method('hasValidTransactionIsolationLevel')
  415. ->willReturn(true);
  416. $this->checkSetupController
  417. ->expects($this->once())
  418. ->method('hasFileinfoInstalled')
  419. ->willReturn(true);
  420. $this->checkSetupController
  421. ->expects($this->once())
  422. ->method('hasOpcacheLoaded')
  423. ->willReturn(true);
  424. $this->checkSetupController
  425. ->expects($this->once())
  426. ->method('hasWorkingFileLocking')
  427. ->willReturn(true);
  428. $this->checkSetupController
  429. ->expects($this->once())
  430. ->method('getSuggestedOverwriteCliURL')
  431. ->willReturn('');
  432. $this->checkSetupController
  433. ->expects($this->once())
  434. ->method('getLastCronInfo')
  435. ->willReturn([
  436. 'diffInSeconds' => 123,
  437. 'relativeTime' => '2 hours ago',
  438. 'backgroundJobsUrl' => 'https://example.org',
  439. ]);
  440. $this->checkSetupController
  441. ->expects($this->once())
  442. ->method('isPHPMailerUsed')
  443. ->willReturn(false);
  444. $this->checker
  445. ->expects($this->once())
  446. ->method('hasPassedCheck')
  447. ->willReturn(true);
  448. $this->memoryInfo
  449. ->method('isMemoryLimitSufficient')
  450. ->willReturn(true);
  451. $this->checkSetupController
  452. ->expects($this->once())
  453. ->method('getAppDirsWithDifferentOwner')
  454. ->willReturn([]);
  455. $this->checkSetupController
  456. ->expects($this->once())
  457. ->method('hasRecommendedPHPModules')
  458. ->willReturn([]);
  459. $this->checkSetupController
  460. ->expects($this->once())
  461. ->method('hasBigIntConversionPendingColumns')
  462. ->willReturn([]);
  463. $this->checkSetupController
  464. ->expects($this->once())
  465. ->method('isMysqlUsedWithoutUTF8MB4')
  466. ->willReturn(false);
  467. $this->checkSetupController
  468. ->expects($this->once())
  469. ->method('isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed')
  470. ->willReturn(true);
  471. $expected = new DataResponse(
  472. [
  473. 'isGetenvServerWorking' => true,
  474. 'isReadOnlyConfig' => false,
  475. 'hasValidTransactionIsolationLevel' => true,
  476. 'outdatedCaches' => [],
  477. 'hasFileinfoInstalled' => true,
  478. 'hasWorkingFileLocking' => true,
  479. 'suggestedOverwriteCliURL' => '',
  480. 'cronInfo' => [
  481. 'diffInSeconds' => 123,
  482. 'relativeTime' => '2 hours ago',
  483. 'backgroundJobsUrl' => 'https://example.org',
  484. ],
  485. 'cronErrors' => [],
  486. 'serverHasInternetConnection' => false,
  487. 'isMemcacheConfigured' => true,
  488. 'memcacheDocs' => 'http://docs.example.org/server/go.php?to=admin-performance',
  489. 'isRandomnessSecure' => self::invokePrivate($this->checkSetupController, 'isRandomnessSecure'),
  490. 'securityDocs' => 'https://docs.example.org/server/8.1/admin_manual/configuration_server/hardening.html',
  491. 'isUsedTlsLibOutdated' => '',
  492. 'phpSupported' => [
  493. 'eol' => true,
  494. 'version' => PHP_VERSION
  495. ],
  496. 'forwardedForHeadersWorking' => true,
  497. 'reverseProxyDocs' => 'reverse-proxy-doc-link',
  498. 'isCorrectMemcachedPHPModuleInstalled' => true,
  499. 'hasPassedCodeIntegrityCheck' => true,
  500. 'codeIntegrityCheckerDocumentation' => 'http://docs.example.org/server/go.php?to=admin-code-integrity',
  501. 'isOpcacheProperlySetup' => false,
  502. 'hasOpcacheLoaded' => true,
  503. 'phpOpcacheDocumentation' => 'http://docs.example.org/server/go.php?to=admin-php-opcache',
  504. 'isSettimelimitAvailable' => true,
  505. 'hasFreeTypeSupport' => false,
  506. 'isSqliteUsed' => false,
  507. 'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion',
  508. 'missingIndexes' => [],
  509. 'isPHPMailerUsed' => false,
  510. 'mailSettingsDocumentation' => 'https://server/index.php/settings/admin',
  511. 'isMemoryLimitSufficient' => true,
  512. 'appDirsWithDifferentOwner' => [],
  513. 'recommendedPHPModules' => [],
  514. 'pendingBigIntConversionColumns' => [],
  515. 'isMysqlUsedWithoutUTF8MB4' => false,
  516. 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => true,
  517. ]
  518. );
  519. $this->assertEquals($expected, $this->checkSetupController->check());
  520. }
  521. public function testIsPHPMailerUsed() {
  522. $checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
  523. ->setConstructorArgs([
  524. 'settings',
  525. $this->request,
  526. $this->config,
  527. $this->clientService,
  528. $this->urlGenerator,
  529. $this->util,
  530. $this->l10n,
  531. $this->checker,
  532. $this->logger,
  533. $this->dispatcher,
  534. $this->db,
  535. $this->lockingProvider,
  536. $this->dateTimeFormatter,
  537. $this->memoryInfo,
  538. $this->secureRandom,
  539. ])
  540. ->setMethods(null)->getMock();
  541. $this->config->expects($this->at(0))
  542. ->method('getSystemValue')
  543. ->with('mail_smtpmode', 'smtp')
  544. ->will($this->returnValue('php'));
  545. $this->config->expects($this->at(1))
  546. ->method('getSystemValue')
  547. ->with('mail_smtpmode', 'smtp')
  548. ->will($this->returnValue('not-php'));
  549. $this->assertTrue($this->invokePrivate($checkSetupController, 'isPHPMailerUsed'));
  550. $this->assertFalse($this->invokePrivate($checkSetupController, 'isPHPMailerUsed'));
  551. }
  552. public function testGetCurlVersion() {
  553. $checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
  554. ->setConstructorArgs([
  555. 'settings',
  556. $this->request,
  557. $this->config,
  558. $this->clientService,
  559. $this->urlGenerator,
  560. $this->util,
  561. $this->l10n,
  562. $this->checker,
  563. $this->logger,
  564. $this->dispatcher,
  565. $this->db,
  566. $this->lockingProvider,
  567. $this->dateTimeFormatter,
  568. $this->memoryInfo,
  569. $this->secureRandom,
  570. ])
  571. ->setMethods(null)->getMock();
  572. $this->assertArrayHasKey('ssl_version', $this->invokePrivate($checkSetupController, 'getCurlVersion'));
  573. }
  574. public function testIsUsedTlsLibOutdatedWithAnotherLibrary() {
  575. $this->config->expects($this->any())
  576. ->method('getSystemValue')
  577. ->will($this->returnValue(true));
  578. $this->checkSetupController
  579. ->expects($this->once())
  580. ->method('getCurlVersion')
  581. ->will($this->returnValue(['ssl_version' => 'SSLlib']));
  582. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  583. }
  584. public function testIsUsedTlsLibOutdatedWithMisbehavingCurl() {
  585. $this->config->expects($this->any())
  586. ->method('getSystemValue')
  587. ->will($this->returnValue(true));
  588. $this->checkSetupController
  589. ->expects($this->once())
  590. ->method('getCurlVersion')
  591. ->will($this->returnValue([]));
  592. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  593. }
  594. public function testIsUsedTlsLibOutdatedWithOlderOpenSsl() {
  595. $this->config->expects($this->any())
  596. ->method('getSystemValue')
  597. ->will($this->returnValue(true));
  598. $this->checkSetupController
  599. ->expects($this->once())
  600. ->method('getCurlVersion')
  601. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1c']));
  602. $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'));
  603. }
  604. public function testIsUsedTlsLibOutdatedWithOlderOpenSslAndWithoutAppstore() {
  605. $this->config
  606. ->expects($this->at(0))
  607. ->method('getSystemValue')
  608. ->with('has_internet_connection', true)
  609. ->will($this->returnValue(true));
  610. $this->checkSetupController
  611. ->expects($this->once())
  612. ->method('getCurlVersion')
  613. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1c']));
  614. $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'));
  615. }
  616. public function testIsUsedTlsLibOutdatedWithOlderOpenSsl1() {
  617. $this->config->expects($this->any())
  618. ->method('getSystemValue')
  619. ->will($this->returnValue(true));
  620. $this->checkSetupController
  621. ->expects($this->once())
  622. ->method('getCurlVersion')
  623. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.2a']));
  624. $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'));
  625. }
  626. public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion() {
  627. $this->config->expects($this->any())
  628. ->method('getSystemValue')
  629. ->will($this->returnValue(true));
  630. $this->checkSetupController
  631. ->expects($this->once())
  632. ->method('getCurlVersion')
  633. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.1d']));
  634. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  635. }
  636. public function testIsUsedTlsLibOutdatedWithMatchingOpenSslVersion1() {
  637. $this->config->expects($this->any())
  638. ->method('getSystemValue')
  639. ->will($this->returnValue(true));
  640. $this->checkSetupController
  641. ->expects($this->once())
  642. ->method('getCurlVersion')
  643. ->will($this->returnValue(['ssl_version' => 'OpenSSL/1.0.2b']));
  644. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  645. }
  646. /**
  647. * Setups a temp directory and some subdirectories.
  648. * Then calls the 'getAppDirsWithDifferentOwner' method.
  649. * The result is expected to be empty since
  650. * there are no directories with different owners than the current user.
  651. *
  652. * @return void
  653. */
  654. public function testAppDirectoryOwnersOk() {
  655. $tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
  656. mkdir($tempDir);
  657. mkdir($tempDir . DIRECTORY_SEPARATOR . 'app1');
  658. mkdir($tempDir . DIRECTORY_SEPARATOR . 'app2');
  659. $this->dirsToRemove[] = $tempDir . DIRECTORY_SEPARATOR . 'app1';
  660. $this->dirsToRemove[] = $tempDir . DIRECTORY_SEPARATOR . 'app2';
  661. $this->dirsToRemove[] = $tempDir;
  662. OC::$APPSROOTS = [
  663. [
  664. 'path' => $tempDir,
  665. 'url' => '/apps',
  666. 'writable' => true,
  667. ],
  668. ];
  669. $this->assertSame(
  670. [],
  671. $this->invokePrivate($this->checkSetupController, 'getAppDirsWithDifferentOwner')
  672. );
  673. }
  674. /**
  675. * Calls the check for a none existing app root that is marked as not writable.
  676. * It's expected that no error happens since the check shouldn't apply.
  677. *
  678. * @return void
  679. */
  680. public function testAppDirectoryOwnersNotWritable() {
  681. $tempDir = tempnam(sys_get_temp_dir(), 'apps') . 'dir';
  682. OC::$APPSROOTS = [
  683. [
  684. 'path' => $tempDir,
  685. 'url' => '/apps',
  686. 'writable' => false,
  687. ],
  688. ];
  689. $this->assertSame(
  690. [],
  691. $this->invokePrivate($this->checkSetupController, 'getAppDirsWithDifferentOwner')
  692. );
  693. }
  694. public function testIsBuggyNss400() {
  695. $this->config->expects($this->any())
  696. ->method('getSystemValue')
  697. ->will($this->returnValue(true));
  698. $this->checkSetupController
  699. ->expects($this->once())
  700. ->method('getCurlVersion')
  701. ->will($this->returnValue(['ssl_version' => 'NSS/1.0.2b']));
  702. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  703. ->disableOriginalConstructor()->getMock();
  704. $exception = $this->getMockBuilder('\GuzzleHttp\Exception\ClientException')
  705. ->disableOriginalConstructor()->getMock();
  706. $response = $this->getMockBuilder(ResponseInterface::class)
  707. ->disableOriginalConstructor()->getMock();
  708. $response->expects($this->once())
  709. ->method('getStatusCode')
  710. ->will($this->returnValue(400));
  711. $exception->expects($this->once())
  712. ->method('getResponse')
  713. ->will($this->returnValue($response));
  714. $client->expects($this->at(0))
  715. ->method('get')
  716. ->with('https://nextcloud.com/', [])
  717. ->will($this->throwException($exception));
  718. $this->clientService->expects($this->once())
  719. ->method('newClient')
  720. ->will($this->returnValue($client));
  721. $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'));
  722. }
  723. public function testIsBuggyNss200() {
  724. $this->config->expects($this->any())
  725. ->method('getSystemValue')
  726. ->will($this->returnValue(true));
  727. $this->checkSetupController
  728. ->expects($this->once())
  729. ->method('getCurlVersion')
  730. ->will($this->returnValue(['ssl_version' => 'NSS/1.0.2b']));
  731. $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
  732. ->disableOriginalConstructor()->getMock();
  733. $exception = $this->getMockBuilder('\GuzzleHttp\Exception\ClientException')
  734. ->disableOriginalConstructor()->getMock();
  735. $response = $this->getMockBuilder(ResponseInterface::class)
  736. ->disableOriginalConstructor()->getMock();
  737. $response->expects($this->once())
  738. ->method('getStatusCode')
  739. ->will($this->returnValue(200));
  740. $exception->expects($this->once())
  741. ->method('getResponse')
  742. ->will($this->returnValue($response));
  743. $client->expects($this->at(0))
  744. ->method('get')
  745. ->with('https://nextcloud.com/', [])
  746. ->will($this->throwException($exception));
  747. $this->clientService->expects($this->once())
  748. ->method('newClient')
  749. ->will($this->returnValue($client));
  750. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  751. }
  752. public function testIsUsedTlsLibOutdatedWithInternetDisabled() {
  753. $this->config
  754. ->expects($this->at(0))
  755. ->method('getSystemValue')
  756. ->with('has_internet_connection', true)
  757. ->will($this->returnValue(false));
  758. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  759. }
  760. public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingEnabled() {
  761. $this->config
  762. ->expects($this->at(0))
  763. ->method('getSystemValue')
  764. ->with('has_internet_connection', true)
  765. ->will($this->returnValue(true));
  766. $this->config
  767. ->expects($this->at(1))
  768. ->method('getSystemValue')
  769. ->with('appstoreenabled', true)
  770. ->will($this->returnValue(false));
  771. $this->config
  772. ->expects($this->at(2))
  773. ->method('getAppValue')
  774. ->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
  775. ->will($this->returnValue('no'));
  776. $this->config
  777. ->expects($this->at(3))
  778. ->method('getAppValue')
  779. ->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
  780. ->will($this->returnValue('yes'));
  781. $this->checkSetupController
  782. ->expects($this->once())
  783. ->method('getCurlVersion')
  784. ->will($this->returnValue([]));
  785. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  786. }
  787. public function testIsUsedTlsLibOutdatedWithAppstoreDisabledAndServerToServerSharingDisabled() {
  788. $this->config
  789. ->expects($this->at(0))
  790. ->method('getSystemValue')
  791. ->with('has_internet_connection', true)
  792. ->will($this->returnValue(true));
  793. $this->config
  794. ->expects($this->at(1))
  795. ->method('getSystemValue')
  796. ->with('appstoreenabled', true)
  797. ->will($this->returnValue(false));
  798. $this->config
  799. ->expects($this->at(2))
  800. ->method('getAppValue')
  801. ->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
  802. ->will($this->returnValue('no'));
  803. $this->config
  804. ->expects($this->at(3))
  805. ->method('getAppValue')
  806. ->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
  807. ->will($this->returnValue('no'));
  808. $this->checkSetupController
  809. ->expects($this->never())
  810. ->method('getCurlVersion')
  811. ->will($this->returnValue([]));
  812. $this->assertSame('', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
  813. }
  814. public function testRescanFailedIntegrityCheck() {
  815. $this->checker
  816. ->expects($this->once())
  817. ->method('runInstanceVerification');
  818. $this->urlGenerator
  819. ->expects($this->once())
  820. ->method('linkToRoute')
  821. ->with('settings.AdminSettings.index')
  822. ->will($this->returnValue('/admin'));
  823. $expected = new RedirectResponse('/admin');
  824. $this->assertEquals($expected, $this->checkSetupController->rescanFailedIntegrityCheck());
  825. }
  826. public function testGetFailedIntegrityCheckDisabled() {
  827. $this->checker
  828. ->expects($this->once())
  829. ->method('isCodeCheckEnforced')
  830. ->willReturn(false);
  831. $expected = new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
  832. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  833. }
  834. public function testGetFailedIntegrityCheckFilesWithNoErrorsFound() {
  835. $this->checker
  836. ->expects($this->once())
  837. ->method('isCodeCheckEnforced')
  838. ->willReturn(true);
  839. $this->checker
  840. ->expects($this->once())
  841. ->method('getResults')
  842. ->will($this->returnValue([]));
  843. $expected = new DataDisplayResponse(
  844. 'No errors have been found.',
  845. Http::STATUS_OK,
  846. [
  847. 'Content-Type' => 'text/plain',
  848. ]
  849. );
  850. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  851. }
  852. public function testGetFailedIntegrityCheckFilesWithSomeErrorsFound() {
  853. $this->checker
  854. ->expects($this->once())
  855. ->method('isCodeCheckEnforced')
  856. ->willReturn(true);
  857. $this->checker
  858. ->expects($this->once())
  859. ->method('getResults')
  860. ->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.', ), ), )));
  861. $expected = new DataDisplayResponse(
  862. 'Technical information
  863. =====================
  864. The following list covers which files have failed the integrity check. Please read
  865. the previous linked documentation to learn more about the errors and how to fix
  866. them.
  867. Results
  868. =======
  869. - core
  870. - EXTRA_FILE
  871. - /testfile
  872. - INVALID_HASH
  873. - /.idea/workspace.xml
  874. - /lib/private/integritycheck/checker.php
  875. - /settings/controller/checksetupcontroller.php
  876. - bookmarks
  877. - EXCEPTION
  878. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  879. - Signature data not found.
  880. - dav
  881. - EXCEPTION
  882. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  883. - Signature data not found.
  884. - encryption
  885. - EXCEPTION
  886. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  887. - Signature data not found.
  888. - external
  889. - EXCEPTION
  890. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  891. - Signature data not found.
  892. - federation
  893. - EXCEPTION
  894. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  895. - Signature data not found.
  896. - files
  897. - EXCEPTION
  898. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  899. - Signature data not found.
  900. - files_antivirus
  901. - EXCEPTION
  902. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  903. - Signature data not found.
  904. - files_drop
  905. - EXCEPTION
  906. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  907. - Signature data not found.
  908. - files_external
  909. - EXCEPTION
  910. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  911. - Signature data not found.
  912. - files_pdfviewer
  913. - EXCEPTION
  914. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  915. - Signature data not found.
  916. - files_sharing
  917. - EXCEPTION
  918. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  919. - Signature data not found.
  920. - files_trashbin
  921. - EXCEPTION
  922. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  923. - Signature data not found.
  924. - files_versions
  925. - EXCEPTION
  926. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  927. - Signature data not found.
  928. - files_videoviewer
  929. - EXCEPTION
  930. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  931. - Signature data not found.
  932. - firstrunwizard
  933. - EXCEPTION
  934. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  935. - Signature data not found.
  936. - gitsmart
  937. - EXCEPTION
  938. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  939. - Signature data not found.
  940. - logreader
  941. - EXCEPTION
  942. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  943. - Signature could not get verified.
  944. - password_policy
  945. - EXCEPTION
  946. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  947. - Signature data not found.
  948. - provisioning_api
  949. - EXCEPTION
  950. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  951. - Signature data not found.
  952. - sketch
  953. - EXCEPTION
  954. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  955. - Signature data not found.
  956. - threatblock
  957. - EXCEPTION
  958. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  959. - Signature data not found.
  960. - two_factor_auth
  961. - EXCEPTION
  962. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  963. - Signature data not found.
  964. - user_ldap
  965. - EXCEPTION
  966. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  967. - Signature data not found.
  968. - user_shibboleth
  969. - EXCEPTION
  970. - OC\IntegrityCheck\Exceptions\InvalidSignatureException
  971. - Signature data not found.
  972. Raw output
  973. ==========
  974. Array
  975. (
  976. [core] => Array
  977. (
  978. [EXTRA_FILE] => Array
  979. (
  980. [/testfile] => Array
  981. (
  982. )
  983. )
  984. [INVALID_HASH] => Array
  985. (
  986. [/.idea/workspace.xml] => Array
  987. (
  988. [expected] => f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216
  989. [current] => ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094
  990. )
  991. [/lib/private/integritycheck/checker.php] => Array
  992. (
  993. [expected] => c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea
  994. [current] => 88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585
  995. )
  996. [/settings/controller/checksetupcontroller.php] => Array
  997. (
  998. [expected] => 3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4
  999. [current] => 09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a
  1000. )
  1001. )
  1002. )
  1003. [bookmarks] => Array
  1004. (
  1005. [EXCEPTION] => Array
  1006. (
  1007. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1008. [message] => Signature data not found.
  1009. )
  1010. )
  1011. [dav] => Array
  1012. (
  1013. [EXCEPTION] => Array
  1014. (
  1015. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1016. [message] => Signature data not found.
  1017. )
  1018. )
  1019. [encryption] => Array
  1020. (
  1021. [EXCEPTION] => Array
  1022. (
  1023. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1024. [message] => Signature data not found.
  1025. )
  1026. )
  1027. [external] => Array
  1028. (
  1029. [EXCEPTION] => Array
  1030. (
  1031. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1032. [message] => Signature data not found.
  1033. )
  1034. )
  1035. [federation] => Array
  1036. (
  1037. [EXCEPTION] => Array
  1038. (
  1039. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1040. [message] => Signature data not found.
  1041. )
  1042. )
  1043. [files] => Array
  1044. (
  1045. [EXCEPTION] => Array
  1046. (
  1047. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1048. [message] => Signature data not found.
  1049. )
  1050. )
  1051. [files_antivirus] => Array
  1052. (
  1053. [EXCEPTION] => Array
  1054. (
  1055. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1056. [message] => Signature data not found.
  1057. )
  1058. )
  1059. [files_drop] => Array
  1060. (
  1061. [EXCEPTION] => Array
  1062. (
  1063. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1064. [message] => Signature data not found.
  1065. )
  1066. )
  1067. [files_external] => Array
  1068. (
  1069. [EXCEPTION] => Array
  1070. (
  1071. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1072. [message] => Signature data not found.
  1073. )
  1074. )
  1075. [files_pdfviewer] => Array
  1076. (
  1077. [EXCEPTION] => Array
  1078. (
  1079. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1080. [message] => Signature data not found.
  1081. )
  1082. )
  1083. [files_sharing] => Array
  1084. (
  1085. [EXCEPTION] => Array
  1086. (
  1087. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1088. [message] => Signature data not found.
  1089. )
  1090. )
  1091. [files_trashbin] => Array
  1092. (
  1093. [EXCEPTION] => Array
  1094. (
  1095. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1096. [message] => Signature data not found.
  1097. )
  1098. )
  1099. [files_versions] => Array
  1100. (
  1101. [EXCEPTION] => Array
  1102. (
  1103. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1104. [message] => Signature data not found.
  1105. )
  1106. )
  1107. [files_videoviewer] => Array
  1108. (
  1109. [EXCEPTION] => Array
  1110. (
  1111. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1112. [message] => Signature data not found.
  1113. )
  1114. )
  1115. [firstrunwizard] => Array
  1116. (
  1117. [EXCEPTION] => Array
  1118. (
  1119. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1120. [message] => Signature data not found.
  1121. )
  1122. )
  1123. [gitsmart] => Array
  1124. (
  1125. [EXCEPTION] => Array
  1126. (
  1127. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1128. [message] => Signature data not found.
  1129. )
  1130. )
  1131. [logreader] => Array
  1132. (
  1133. [EXCEPTION] => Array
  1134. (
  1135. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1136. [message] => Signature could not get verified.
  1137. )
  1138. )
  1139. [password_policy] => Array
  1140. (
  1141. [EXCEPTION] => Array
  1142. (
  1143. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1144. [message] => Signature data not found.
  1145. )
  1146. )
  1147. [provisioning_api] => Array
  1148. (
  1149. [EXCEPTION] => Array
  1150. (
  1151. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1152. [message] => Signature data not found.
  1153. )
  1154. )
  1155. [sketch] => Array
  1156. (
  1157. [EXCEPTION] => Array
  1158. (
  1159. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1160. [message] => Signature data not found.
  1161. )
  1162. )
  1163. [threatblock] => Array
  1164. (
  1165. [EXCEPTION] => Array
  1166. (
  1167. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1168. [message] => Signature data not found.
  1169. )
  1170. )
  1171. [two_factor_auth] => Array
  1172. (
  1173. [EXCEPTION] => Array
  1174. (
  1175. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1176. [message] => Signature data not found.
  1177. )
  1178. )
  1179. [user_ldap] => Array
  1180. (
  1181. [EXCEPTION] => Array
  1182. (
  1183. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1184. [message] => Signature data not found.
  1185. )
  1186. )
  1187. [user_shibboleth] => Array
  1188. (
  1189. [EXCEPTION] => Array
  1190. (
  1191. [class] => OC\IntegrityCheck\Exceptions\InvalidSignatureException
  1192. [message] => Signature data not found.
  1193. )
  1194. )
  1195. )
  1196. ',
  1197. Http::STATUS_OK,
  1198. [
  1199. 'Content-Type' => 'text/plain',
  1200. ]
  1201. );
  1202. $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
  1203. }
  1204. public function dataForIsMysqlUsedWithoutUTF8MB4() {
  1205. return [
  1206. ['sqlite', false, false],
  1207. ['sqlite', true, false],
  1208. ['postgres', false, false],
  1209. ['postgres', true, false],
  1210. ['oci', false, false],
  1211. ['oci', true, false],
  1212. ['mysql', false, true],
  1213. ['mysql', true, false],
  1214. ];
  1215. }
  1216. /**
  1217. * @dataProvider dataForIsMysqlUsedWithoutUTF8MB4
  1218. */
  1219. public function testIsMysqlUsedWithoutUTF8MB4(string $db, bool $useUTF8MB4, bool $expected) {
  1220. $this->config->method('getSystemValue')
  1221. ->will($this->returnCallback(function($key, $default) use ($db, $useUTF8MB4) {
  1222. if ($key === 'dbtype') {
  1223. return $db;
  1224. }
  1225. if ($key === 'mysql.utf8mb4') {
  1226. return $useUTF8MB4;
  1227. }
  1228. return $default;
  1229. }));
  1230. $checkSetupController = new CheckSetupController(
  1231. 'settings',
  1232. $this->request,
  1233. $this->config,
  1234. $this->clientService,
  1235. $this->urlGenerator,
  1236. $this->util,
  1237. $this->l10n,
  1238. $this->checker,
  1239. $this->logger,
  1240. $this->dispatcher,
  1241. $this->db,
  1242. $this->lockingProvider,
  1243. $this->dateTimeFormatter,
  1244. $this->memoryInfo,
  1245. $this->secureRandom
  1246. );
  1247. $this->assertSame($expected, $this->invokePrivate($checkSetupController, 'isMysqlUsedWithoutUTF8MB4'));
  1248. }
  1249. public function dataForIsEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed() {
  1250. return [
  1251. ['singlebucket', 'OC\\Files\\ObjectStore\\Swift', true],
  1252. ['multibucket', 'OC\\Files\\ObjectStore\\Swift', true],
  1253. ['singlebucket', 'OC\\Files\\ObjectStore\\Custom', true],
  1254. ['multibucket', 'OC\Files\\ObjectStore\\Custom', true],
  1255. ['singlebucket', 'OC\Files\ObjectStore\Swift', true],
  1256. ['multibucket', 'OC\Files\ObjectStore\Swift', true],
  1257. ['singlebucket', 'OC\Files\ObjectStore\Custom', true],
  1258. ['multibucket', 'OC\Files\ObjectStore\Custom', true],
  1259. ];
  1260. }
  1261. /**
  1262. * @dataProvider dataForIsEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed
  1263. */
  1264. public function testIsEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(string $mode, string $className, bool $expected) {
  1265. $this->config->method('getSystemValue')
  1266. ->will($this->returnCallback(function($key, $default) use ($mode, $className) {
  1267. if ($key === 'objectstore' && $mode === 'singlebucket') {
  1268. return ['class' => $className];
  1269. }
  1270. if ($key === 'objectstore_multibucket' && $mode === 'multibucket') {
  1271. return ['class' => $className];
  1272. }
  1273. return $default;
  1274. }));
  1275. $checkSetupController = new CheckSetupController(
  1276. 'settings',
  1277. $this->request,
  1278. $this->config,
  1279. $this->clientService,
  1280. $this->urlGenerator,
  1281. $this->util,
  1282. $this->l10n,
  1283. $this->checker,
  1284. $this->logger,
  1285. $this->dispatcher,
  1286. $this->db,
  1287. $this->lockingProvider,
  1288. $this->dateTimeFormatter,
  1289. $this->memoryInfo,
  1290. $this->secureRandom
  1291. );
  1292. $this->assertSame($expected, $this->invokePrivate($checkSetupController, 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed'));
  1293. }
  1294. }