mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
Migrate memcache check to SetupCheck API
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
6911dc30e6
commit
ddd13a90d8
8 changed files with 64 additions and 78 deletions
|
|
@ -79,6 +79,7 @@ return array(
|
|||
'OCA\\Settings\\SetupChecks\\FileLocking' => $baseDir . '/../lib/SetupChecks/FileLocking.php',
|
||||
'OCA\\Settings\\SetupChecks\\InternetConnectivity' => $baseDir . '/../lib/SetupChecks/InternetConnectivity.php',
|
||||
'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
|
||||
'OCA\\Settings\\SetupChecks\\MemcacheConfigured' => $baseDir . '/../lib/SetupChecks/MemcacheConfigured.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpGetEnv' => $baseDir . '/../lib/SetupChecks/PhpGetEnv.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpModules' => $baseDir . '/../lib/SetupChecks/PhpModules.php',
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ class ComposerStaticInitSettings
|
|||
'OCA\\Settings\\SetupChecks\\FileLocking' => __DIR__ . '/..' . '/../lib/SetupChecks/FileLocking.php',
|
||||
'OCA\\Settings\\SetupChecks\\InternetConnectivity' => __DIR__ . '/..' . '/../lib/SetupChecks/InternetConnectivity.php',
|
||||
'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
|
||||
'OCA\\Settings\\SetupChecks\\MemcacheConfigured' => __DIR__ . '/..' . '/../lib/SetupChecks/MemcacheConfigured.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpGetEnv' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpGetEnv.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpModules' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpModules.php',
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ use OCA\Settings\SetupChecks\EmailTestSuccessful;
|
|||
use OCA\Settings\SetupChecks\FileLocking;
|
||||
use OCA\Settings\SetupChecks\InternetConnectivity;
|
||||
use OCA\Settings\SetupChecks\LegacySSEKeyFormat;
|
||||
use OCA\Settings\SetupChecks\MemcacheConfigured;
|
||||
use OCA\Settings\SetupChecks\PhpDefaultCharset;
|
||||
use OCA\Settings\SetupChecks\PhpModules;
|
||||
use OCA\Settings\SetupChecks\PhpGetEnv;
|
||||
|
|
@ -157,6 +158,7 @@ class Application extends App implements IBootstrap {
|
|||
$context->registerSetupCheck(FileLocking::class);
|
||||
$context->registerSetupCheck(InternetConnectivity::class);
|
||||
$context->registerSetupCheck(LegacySSEKeyFormat::class);
|
||||
$context->registerSetupCheck(MemcacheConfigured::class);
|
||||
$context->registerSetupCheck(PhpDefaultCharset::class);
|
||||
$context->registerSetupCheck(PhpModules::class);
|
||||
$context->registerSetupCheck(PhpGetEnv::class);
|
||||
|
|
|
|||
|
|
@ -194,14 +194,6 @@ class CheckSetupController extends Controller {
|
|||
return $this->manager->isFairUseOfFreePushService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a local memcache is installed or not
|
||||
* @return bool
|
||||
*/
|
||||
private function isMemcacheConfigured() {
|
||||
return $this->config->getSystemValue('memcache.local', null) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether PHP can generate "secure" pseudorandom integers
|
||||
*
|
||||
|
|
@ -775,8 +767,6 @@ Raw output
|
|||
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
|
||||
'isBruteforceThrottled' => $this->throttler->getAttempts($this->request->getRemoteAddress()) !== 0,
|
||||
'bruteforceRemoteAddress' => $this->request->getRemoteAddress(),
|
||||
'isMemcacheConfigured' => $this->isMemcacheConfigured(),
|
||||
'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
|
||||
'isRandomnessSecure' => $this->isRandomnessSecure(),
|
||||
'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
|
||||
'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
|
||||
|
|
|
|||
60
apps/settings/lib/SetupChecks/MemcacheConfigured.php
Normal file
60
apps/settings/lib/SetupChecks/MemcacheConfigured.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Côme Chilliet <come.chilliet@nextcloud.com>
|
||||
*
|
||||
* @author Côme Chilliet <come.chilliet@nextcloud.com>
|
||||
*
|
||||
* @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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
namespace OCA\Settings\SetupChecks;
|
||||
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\SetupCheck\ISetupCheck;
|
||||
use OCP\SetupCheck\SetupResult;
|
||||
|
||||
class MemcacheConfigured implements ISetupCheck {
|
||||
public function __construct(
|
||||
private IL10N $l10n,
|
||||
private IConfig $config,
|
||||
private IURLGenerator $urlGenerator,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->l10n->t('Memcache');
|
||||
}
|
||||
|
||||
public function getCategory(): string {
|
||||
return 'system';
|
||||
}
|
||||
|
||||
public function run(): SetupResult {
|
||||
if ($this->config->getSystemValue('memcache.local', null) !== null) {
|
||||
return SetupResult::success($this->l10n->t('Configured'));
|
||||
} else {
|
||||
return SetupResult::info(
|
||||
$this->l10n->t('No memory cache has been configured. To enhance performance, please configure a memcache, if available.'),
|
||||
$this->urlGenerator->linkToDocs('admin-performance')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -222,34 +222,6 @@ class CheckSetupControllerTest extends TestCase {
|
|||
$this->dirsToRemove = [];
|
||||
}
|
||||
|
||||
public function testIsMemcacheConfiguredFalse() {
|
||||
$this->config->expects($this->once())
|
||||
->method('getSystemValue')
|
||||
->with('memcache.local', null)
|
||||
->willReturn(null);
|
||||
|
||||
$this->assertFalse(
|
||||
self::invokePrivate(
|
||||
$this->checkSetupController,
|
||||
'isMemcacheConfigured'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testIsMemcacheConfiguredTrue() {
|
||||
$this->config->expects($this->once())
|
||||
->method('getSystemValue')
|
||||
->with('memcache.local', null)
|
||||
->willReturn('SomeProvider');
|
||||
|
||||
$this->assertTrue(
|
||||
self::invokePrivate(
|
||||
$this->checkSetupController,
|
||||
'isMemcacheConfigured'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataForwardedForHeadersWorking
|
||||
*
|
||||
|
|
@ -471,8 +443,6 @@ class CheckSetupControllerTest extends TestCase {
|
|||
'backgroundJobsUrl' => 'https://example.org',
|
||||
],
|
||||
'cronErrors' => [],
|
||||
'isMemcacheConfigured' => true,
|
||||
'memcacheDocs' => 'http://docs.example.org/server/go.php?to=admin-performance',
|
||||
'isRandomnessSecure' => self::invokePrivate($this->checkSetupController, 'isRandomnessSecure'),
|
||||
'securityDocs' => 'https://docs.example.org/server/8.1/admin_manual/configuration_server/hardening.html',
|
||||
'isUsedTlsLibOutdated' => '',
|
||||
|
|
|
|||
|
|
@ -224,14 +224,6 @@
|
|||
type: OC.SetupChecks.MESSAGE_TYPE_ERROR
|
||||
});
|
||||
}
|
||||
if(!data.isMemcacheConfigured) {
|
||||
messages.push({
|
||||
msg: t('core', 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the {linkstart}documentation ↗{linkend}.')
|
||||
.replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.memcacheDocs + '">')
|
||||
.replace('{linkend}', '</a>'),
|
||||
type: OC.SetupChecks.MESSAGE_TYPE_INFO
|
||||
});
|
||||
}
|
||||
if(!data.isRandomnessSecure) {
|
||||
messages.push({
|
||||
msg: t('core', 'No suitable source for randomness found by PHP which is highly discouraged for security reasons. Further information can be found in the {linkstart}documentation ↗{linkend}.')
|
||||
|
|
|
|||
|
|
@ -226,7 +226,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
suggestedOverwriteCliURL: '',
|
||||
isRandomnessSecure: true,
|
||||
isFairUseOfFreePushService: true,
|
||||
memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance',
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -264,10 +263,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
|
||||
async.done(function( data, s, x ){
|
||||
expect(data).toEqual([
|
||||
{
|
||||
msg: 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/server/go.php?to=admin-performance">documentation ↗</a>.',
|
||||
type: OC.SetupChecks.MESSAGE_TYPE_INFO
|
||||
},
|
||||
{
|
||||
msg: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.',
|
||||
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
|
||||
|
|
@ -289,7 +284,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
suggestedOverwriteCliURL: '',
|
||||
isRandomnessSecure: true,
|
||||
isFairUseOfFreePushService: true,
|
||||
memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance',
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -327,10 +321,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
|
||||
async.done(function( data, s, x ){
|
||||
expect(data).toEqual([
|
||||
{
|
||||
msg: 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/server/go.php?to=admin-performance">documentation ↗</a>.',
|
||||
type: OC.SetupChecks.MESSAGE_TYPE_INFO
|
||||
},
|
||||
{
|
||||
msg: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.',
|
||||
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
|
||||
|
|
@ -352,7 +342,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
suggestedOverwriteCliURL: '',
|
||||
isRandomnessSecure: true,
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -412,7 +401,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: false,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -470,7 +458,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: false,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -528,7 +515,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -587,7 +573,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
suggestedOverwriteCliURL: '',
|
||||
isRandomnessSecure: true,
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: false,
|
||||
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
|
|
@ -647,7 +632,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isFairUseOfFreePushService: true,
|
||||
isBruteforceThrottled: true,
|
||||
bruteforceRemoteAddress: '::1',
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
|
|
@ -705,7 +689,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
suggestedOverwriteCliURL: '',
|
||||
isRandomnessSecure: true,
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
|
|
@ -763,7 +746,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
suggestedOverwriteCliURL: '',
|
||||
isRandomnessSecure: true,
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
|
|
@ -842,7 +824,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -907,7 +888,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -965,7 +945,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -1023,7 +1002,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -1085,7 +1063,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -1144,7 +1121,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -1200,7 +1176,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -1259,7 +1234,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -1318,7 +1292,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -1376,7 +1349,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -1434,7 +1406,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
@ -1499,7 +1470,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isRandomnessSecure: true,
|
||||
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
|
||||
isFairUseOfFreePushService: true,
|
||||
isMemcacheConfigured: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue