From 4a0b7aaf6c80f59552b1da861432476a8ac4c7cf Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 12 Jun 2018 16:16:29 +0200 Subject: [PATCH] Merge tips & tricks section into setup checks Signed-off-by: Morris Jobke --- core/js/setupchecks.js | 24 ++++- core/js/tests/specHelper.js | 4 +- core/js/tests/specs/setupchecksSpec.js | 18 ++-- lib/composer/composer/autoload_classmap.php | 1 - lib/composer/composer/autoload_static.php | 1 - lib/private/Settings/Admin/TipsTricks.php | 72 --------------- lib/private/Settings/Manager.php | 6 -- settings/Controller/CheckSetupController.php | 6 ++ settings/css/settings.scss | 14 ++- .../templates/settings/admin/overview.php | 6 +- .../templates/settings/admin/tipstricks.php | 50 ---------- .../AdminSettingsControllerTest.php | 5 +- .../Controller/CheckSetupControllerTest.php | 11 ++- tests/lib/Settings/Admin/TipsTricksTest.php | 91 ------------------- tests/lib/Settings/ManagerTest.php | 6 +- 15 files changed, 69 insertions(+), 246 deletions(-) delete mode 100644 lib/private/Settings/Admin/TipsTricks.php delete mode 100644 settings/templates/settings/admin/tipstricks.php delete mode 100644 tests/lib/Settings/Admin/TipsTricksTest.php diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index a3155287ac..8f6f916ea5 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -198,6 +198,22 @@ type: OC.SetupChecks.MESSAGE_TYPE_INFO }) } + if (data.isSqliteUsed) { + messages.push({ + msg: t( + 'core', + 'SQLite is currently being used as the backend database. For larger installations we recommend that you switch to a different database backend.' + ) + ' ' + t('core', 'This is particularly recommended when using the desktop client for file synchronisation.') + ' ' + + t( + 'core', + 'To migrate to another database use the command line tool: \'occ db:convert-type\', or see the documentation ↗.', + { + docLink: data.databaseConversionDocumentation, + } + ), + type: OC.SetupChecks.MESSAGE_TYPE_WARNING + }) + } } else { messages.push({ msg: t('core', 'Error occurred while checking server setup'), @@ -305,7 +321,7 @@ xhr.getResponseHeader('Referrer-Policy').toLowerCase() !== 'strict-origin' && xhr.getResponseHeader('Referrer-Policy').toLowerCase() !== 'strict-origin-when-cross-origin')) { messages.push({ - msg: t('core', 'The "{header}" HTTP header is not set to "{val1}", "{val2}", "{val3}" or "{val4}". This can leak referer information. See the W3C Recommendation.', + msg: t('core', 'The "{header}" HTTP header is not set to "{val1}", "{val2}", "{val3}" or "{val4}". This can leak referer information. See the W3C Recommendation ↗.', { header: 'Referrer-Policy', val1: 'no-referrer', @@ -337,7 +353,7 @@ var messages = []; if (xhr.status === 200) { - var tipsUrl = OC.generateUrl('settings/admin/tips-tricks'); + var tipsUrl = oc_defaults.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-security'); if(OC.getProtocol() === 'https') { // Extract the value of 'Strict-Transport-Security' var transportSecurityValidity = xhr.getResponseHeader('Strict-Transport-Security'); @@ -353,13 +369,13 @@ var minimumSeconds = 15552000; if(isNaN(transportSecurityValidity) || transportSecurityValidity <= (minimumSeconds - 1)) { messages.push({ - msg: t('core', 'The "Strict-Transport-Security" HTTP header is not set to at least "{seconds}" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips.', {'seconds': minimumSeconds, docUrl: tipsUrl}), + msg: t('core', 'The "Strict-Transport-Security" HTTP header is not set to at least "{seconds}" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips ↗.', {'seconds': minimumSeconds, docUrl: tipsUrl}), type: OC.SetupChecks.MESSAGE_TYPE_WARNING }); } } else { messages.push({ - msg: t('core', 'Accessing site insecurely via HTTP. You are strongly adviced to set up your server to require HTTPS instead, as described in the security tips.', {docUrl: tipsUrl}), + msg: t('core', 'Accessing site insecurely via HTTP. You are strongly adviced to set up your server to require HTTPS instead, as described in the security tips ↗.', {docUrl: tipsUrl}), type: OC.SetupChecks.MESSAGE_TYPE_WARNING }); } diff --git a/core/js/tests/specHelper.js b/core/js/tests/specHelper.js index a411ade7de..f2fc288844 100644 --- a/core/js/tests/specHelper.js +++ b/core/js/tests/specHelper.js @@ -100,7 +100,9 @@ window.oc_config = { window.oc_appconfig = { core: {} }; -window.oc_defaults = {}; +window.oc_defaults = { + docPlaceholderUrl: 'https://docs.example.org/PLACEHOLDER' +}; /* jshint camelcase: true */ diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index feef66c353..b3f0c3b1c2 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -539,7 +539,7 @@ describe('OC.SetupChecks tests', function() { msg: 'The "X-Permitted-Cross-Domain-Policies" HTTP header is not set to "none". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING }, { - msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation.', + msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation ↗.', type: OC.SetupChecks.MESSAGE_TYPE_INFO } ]); @@ -702,7 +702,7 @@ describe('OC.SetupChecks tests', function() { result.done(function( data, s, x ){ expect(data).toEqual([ { - msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation.', + msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation ↗.', type: OC.SetupChecks.MESSAGE_TYPE_INFO } ]); @@ -728,7 +728,7 @@ describe('OC.SetupChecks tests', function() { result.done(function( data, s, x ){ expect(data).toEqual([ { - msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation.', + msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation ↗.', type: OC.SetupChecks.MESSAGE_TYPE_INFO } ]); @@ -754,7 +754,7 @@ describe('OC.SetupChecks tests', function() { result.done(function( data, s, x ){ expect(data).toEqual([ { - msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation.', + msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation ↗.', type: OC.SetupChecks.MESSAGE_TYPE_INFO } ]); @@ -780,7 +780,7 @@ describe('OC.SetupChecks tests', function() { result.done(function( data, s, x ){ expect(data).toEqual([ { - msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation.', + msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation ↗.', type: OC.SetupChecks.MESSAGE_TYPE_INFO } ]); @@ -808,7 +808,7 @@ describe('OC.SetupChecks tests', function() { async.done(function( data, s, x ){ expect(data).toEqual([{ - msg: 'Accessing site insecurely via HTTP. You are strongly adviced to set up your server to require HTTPS instead, as described in the security tips.', + msg: 'Accessing site insecurely via HTTP. You are strongly adviced to set up your server to require HTTPS instead, as described in the security tips ↗.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING }]); done(); @@ -855,7 +855,7 @@ describe('OC.SetupChecks tests', function() { async.done(function( data, s, x ){ expect(data).toEqual([{ - msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips.', + msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips ↗.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING }]); done(); @@ -881,7 +881,7 @@ describe('OC.SetupChecks tests', function() { async.done(function( data, s, x ){ expect(data).toEqual([{ - msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips.', + msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips ↗.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING }]); done(); @@ -907,7 +907,7 @@ describe('OC.SetupChecks tests', function() { async.done(function( data, s, x ){ expect(data).toEqual([{ - msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips.', + msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips ↗.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING }]); done(); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 701f723468..08f8760b32 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -907,7 +907,6 @@ return array( 'OC\\Settings\\Admin\\Server' => $baseDir . '/lib/private/Settings/Admin/Server.php', 'OC\\Settings\\Admin\\ServerDevNotice' => $baseDir . '/lib/private/Settings/Admin/ServerDevNotice.php', 'OC\\Settings\\Admin\\Sharing' => $baseDir . '/lib/private/Settings/Admin/Sharing.php', - 'OC\\Settings\\Admin\\TipsTricks' => $baseDir . '/lib/private/Settings/Admin/TipsTricks.php', 'OC\\Settings\\Application' => $baseDir . '/settings/Application.php', 'OC\\Settings\\BackgroundJobs\\VerifyUserData' => $baseDir . '/settings/BackgroundJobs/VerifyUserData.php', 'OC\\Settings\\Controller\\AdminSettingsController' => $baseDir . '/settings/Controller/AdminSettingsController.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index da4556a718..4c5756b98e 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -937,7 +937,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Settings\\Admin\\Server' => __DIR__ . '/../../..' . '/lib/private/Settings/Admin/Server.php', 'OC\\Settings\\Admin\\ServerDevNotice' => __DIR__ . '/../../..' . '/lib/private/Settings/Admin/ServerDevNotice.php', 'OC\\Settings\\Admin\\Sharing' => __DIR__ . '/../../..' . '/lib/private/Settings/Admin/Sharing.php', - 'OC\\Settings\\Admin\\TipsTricks' => __DIR__ . '/../../..' . '/lib/private/Settings/Admin/TipsTricks.php', 'OC\\Settings\\Application' => __DIR__ . '/../../..' . '/settings/Application.php', 'OC\\Settings\\BackgroundJobs\\VerifyUserData' => __DIR__ . '/../../..' . '/settings/BackgroundJobs/VerifyUserData.php', 'OC\\Settings\\Controller\\AdminSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/AdminSettingsController.php', diff --git a/lib/private/Settings/Admin/TipsTricks.php b/lib/private/Settings/Admin/TipsTricks.php deleted file mode 100644 index 9b295bb989..0000000000 --- a/lib/private/Settings/Admin/TipsTricks.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * @author Arthur Schiwon - * @author Lukas Reschke - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -namespace OC\Settings\Admin; - -use OCP\AppFramework\Http\TemplateResponse; -use OCP\IConfig; -use OCP\Settings\ISettings; - -class TipsTricks implements ISettings { - /** @var IConfig */ - private $config; - - /** - * @param IConfig $config - */ - public function __construct(IConfig $config) { - $this->config = $config; - } - - /** - * @return TemplateResponse - */ - public function getForm() { - $databaseOverload = (strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false); - - $parameters = [ - 'databaseOverload' => $databaseOverload, - ]; - - return new TemplateResponse('settings', 'settings/admin/tipstricks', $parameters, ''); - } - - /** - * @return string the section ID, e.g. 'sharing' - */ - public function getSection() { - return 'tips-tricks'; - } - - /** - * @return int whether the form should be rather on the top or bottom of - * the admin section. The forms are arranged in ascending order of the - * priority values. It is required to return a value between 0 and 100. - * - * E.g.: 70 - */ - public function getPriority() { - return 0; - } -} diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php index d8130ed6b5..bfccdf392b 100644 --- a/lib/private/Settings/Manager.php +++ b/lib/private/Settings/Manager.php @@ -232,7 +232,6 @@ class Manager implements IManager { 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], - 99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0, $this->url->imagePath('settings', 'help.svg'))], ]; $appSections = $this->getSections('admin'); @@ -282,11 +281,6 @@ class Manager implements IManager { $form = new Admin\Sharing($this->config, $this->l); $forms[$form->getPriority()] = [$form]; } - if ($section === 'tips-tricks') { - /** @var ISettings $form */ - $form = new Admin\TipsTricks($this->config); - $forms[$form->getPriority()] = [$form]; - } return $forms; } diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php index e1073be469..c3fd126792 100644 --- a/settings/Controller/CheckSetupController.php +++ b/settings/Controller/CheckSetupController.php @@ -428,6 +428,10 @@ Raw output return $indexInfo->getListOfMissingIndexes(); } + protected function isSqliteUsed() { + return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false; + } + /** * @return DataResponse */ @@ -451,6 +455,8 @@ Raw output 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), 'hasMissingIndexes' => $this->hasMissingIndexes(), + 'isSqliteUsed' => $this->isSqliteUsed(), + 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'), ] ); } diff --git a/settings/css/settings.scss b/settings/css/settings.scss index 97ef8e15d8..5c1714021f 100644 --- a/settings/css/settings.scss +++ b/settings/css/settings.scss @@ -1314,8 +1314,18 @@ doesnotexist:-o-prefocus, .strengthify-wrapper { } } -#security-warning > ul { - color: $color-error; +#security-warning { + a { + text-decoration: underline; + } + + & > ul { + color: $color-error; + } + + .extra-top-margin { + margin-top: 12px; + } } #admin-tips li { diff --git a/settings/templates/settings/admin/overview.php b/settings/templates/settings/admin/overview.php index 08aee8b5b7..5fb5e110eb 100644 --- a/settings/templates/settings/admin/overview.php +++ b/settings/templates/settings/admin/overview.php @@ -28,7 +28,7 @@

t('Security & setup warnings'));?>

-

t('It\'s important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the Tips & Tricks section and the documentation for more information.'));?>

+

t('It\'s important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the linked documentation for more information.'));?>

    t('Please double check the installation guides ↗, and check for any errors or warnings in the log.', [link_to_docs('admin-install'), \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => 'logging'])] )); ?>

    +

    + t('Check the security of your Nextcloud over our security scan ↗.', ['https://scan.nextcloud.com']));?> +

    +
diff --git a/settings/templates/settings/admin/tipstricks.php b/settings/templates/settings/admin/tipstricks.php deleted file mode 100644 index 3ab337e06f..0000000000 --- a/settings/templates/settings/admin/tipstricks.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * @author Arthur Schiwon - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -/** @var \OCP\IL10N $l */ -/** @var array $_ */ - -?> - -
-

t('Tips & tricks'));?>

-

t('There are a lot of features and config switches available to optimally customize and use this instance. Here are some pointers for more information.')); ?>

- -
diff --git a/tests/Settings/Controller/AdminSettingsControllerTest.php b/tests/Settings/Controller/AdminSettingsControllerTest.php index d5650b397f..5bc4880302 100644 --- a/tests/Settings/Controller/AdminSettingsControllerTest.php +++ b/tests/Settings/Controller/AdminSettingsControllerTest.php @@ -22,10 +22,9 @@ */ namespace Tests\Settings\Controller; -use OC\Settings\Admin\TipsTricks; +use OC\Settings\Admin\ServerDevNotice; use OC\Settings\Controller\AdminSettingsController; use OCP\AppFramework\Http\TemplateResponse; -use OCP\IConfig; use OCP\INavigationManager; use OCP\IRequest; use OCP\Settings\IManager; @@ -88,7 +87,7 @@ class AdminSettingsControllerTest extends TestCase { ->expects($this->once()) ->method('getAdminSettings') ->with('test') - ->willReturn([5 => new TipsTricks($this->getMockBuilder(IConfig::class)->getMock())]); + ->willReturn([5 => new ServerDevNotice()]); $expected = new TemplateResponse('settings', 'settings/frame', ['forms' => ['personal' => [], 'admin' => []], 'content' => '']); $this->assertEquals($expected, $this->adminSettingsController->index('test')); diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php index 7760be1649..f0e19e007f 100644 --- a/tests/Settings/Controller/CheckSetupControllerTest.php +++ b/tests/Settings/Controller/CheckSetupControllerTest.php @@ -103,7 +103,7 @@ class CheckSetupControllerTest extends TestCase { $this->logger, $this->dispatcher, ]) - ->setMethods(['getCurlVersion', 'isPhpOutdated', 'isOpcacheProperlySetup', 'hasFreeTypeSupport', 'hasMissingIndexes'])->getMock(); + ->setMethods(['getCurlVersion', 'isPhpOutdated', 'isOpcacheProperlySetup', 'hasFreeTypeSupport', 'hasMissingIndexes', 'isSqliteUsed'])->getMock(); } public function testIsInternetConnectionWorkingDisabledViaConfig() { @@ -332,12 +332,19 @@ class CheckSetupControllerTest extends TestCase { ->method('linkToDocs') ->with('admin-php-opcache') ->willReturn('http://docs.example.org/server/go.php?to=admin-php-opcache'); + $this->urlGenerator->expects($this->at(5)) + ->method('linkToDocs') + ->with('admin-db-conversion') + ->willReturn('http://docs.example.org/server/go.php?to=admin-db-conversion'); $this->checkSetupController ->method('hasFreeTypeSupport') ->willReturn(false); $this->checkSetupController ->method('hasMissingIndexes') ->willReturn([]); + $this->checkSetupController + ->method('isSqliteUsed') + ->willReturn(false); $expected = new DataResponse( [ @@ -361,6 +368,8 @@ class CheckSetupControllerTest extends TestCase { 'isSettimelimitAvailable' => true, 'hasFreeTypeSupport' => false, 'hasMissingIndexes' => [], + 'isSqliteUsed' => false, + 'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion', ] ); $this->assertEquals($expected, $this->checkSetupController->check()); diff --git a/tests/lib/Settings/Admin/TipsTricksTest.php b/tests/lib/Settings/Admin/TipsTricksTest.php deleted file mode 100644 index 2bbadab52c..0000000000 --- a/tests/lib/Settings/Admin/TipsTricksTest.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * @author Lukas Reschke - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -namespace Test\Settings\Admin; - -use OC\Settings\Admin\TipsTricks; -use OCP\AppFramework\Http\TemplateResponse; -use OCP\IConfig; -use Test\TestCase; - -class TipsTrickTest extends TestCase { - /** @var TipsTricks */ - private $admin; - /** @var IConfig */ - private $config; - - public function setUp() { - parent::setUp(); - $this->config = $this->getMockBuilder(IConfig::class)->getMock(); - - $this->admin = new TipsTricks( - $this->config - ); - } - - public function testGetFormWithExcludedGroupsWithSQLite() { - $this->config - ->expects($this->once()) - ->method('getSystemValue') - ->with('dbtype') - ->willReturn('sqlite'); - - $expected = new TemplateResponse( - 'settings', - 'settings/admin/tipstricks', - [ - 'databaseOverload' => true, - ], - '' - ); - - $this->assertEquals($expected, $this->admin->getForm()); - } - - public function testGetFormWithExcludedGroupsWithoutSQLite() { - $this->config - ->expects($this->once()) - ->method('getSystemValue') - ->with('dbtype') - ->willReturn('mysql'); - - $expected = new TemplateResponse( - 'settings', - 'settings/admin/tipstricks', - [ - 'databaseOverload' => false, - ], - '' - ); - - $this->assertEquals($expected, $this->admin->getForm()); - } - - public function testGetSection() { - $this->assertSame('tips-tricks', $this->admin->getSection()); - } - - public function testGetPriority() { - $this->assertSame(0, $this->admin->getPriority()); - } -} diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php index 5c4e2fe7a2..8d26828090 100644 --- a/tests/lib/Settings/ManagerTest.php +++ b/tests/lib/Settings/ManagerTest.php @@ -115,7 +115,7 @@ class ManagerTest extends TestCase { $this->manager->registerSection('admin', \OCA\WorkflowEngine\Settings\Section::class); - $this->url->expects($this->exactly(7)) + $this->url->expects($this->exactly(6)) ->method('imagePath') ->willReturnMap([ ['settings', 'admin.svg', '0'], @@ -133,7 +133,6 @@ class ManagerTest extends TestCase { 45 => [new Section('encryption', 'Encryption', 0, '3')], 55 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)], 98 => [new Section('additional', 'Additional settings', 0, '1')], - 99 => [new Section('tips-tricks', 'Tips & tricks', 0, '4')], ], $this->manager->getAdminSections()); } @@ -167,7 +166,7 @@ class ManagerTest extends TestCase { ->method('t') ->will($this->returnArgument(0)); - $this->url->expects($this->exactly(7)) + $this->url->expects($this->exactly(6)) ->method('imagePath') ->willReturnMap([ ['settings', 'admin.svg', '0'], @@ -184,7 +183,6 @@ class ManagerTest extends TestCase { 10 => [new Section('security', 'Security', 0, '3')], 45 => [new Section('encryption', 'Encryption', 0, '3')], 98 => [new Section('additional', 'Additional settings', 0, '1')], - 99 => [new Section('tips-tricks', 'Tips & tricks', 0, '4')], ], $this->manager->getAdminSections()); }