CheckSetupControllerTest.php 47 KB

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