mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(updatenotification): respect updatechecker config
If disabled: - Hide admin settings - Do not create Nextcloud server update notifications Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
a2eed985aa
commit
957efe0670
4 changed files with 56 additions and 7 deletions
|
|
@ -64,9 +64,14 @@ class UpdateAvailableNotifications extends TimedJob {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check for ownCloud update
|
||||
* Check for Nextcloud server update
|
||||
*/
|
||||
protected function checkCoreUpdate() {
|
||||
if (!$this->config->getSystemValueBool('updatechecker', true)) {
|
||||
// update checker is disabled so no core update check!
|
||||
return;
|
||||
}
|
||||
|
||||
if (\in_array($this->serverVersion->getChannel(), ['daily', 'git'], true)) {
|
||||
// "These aren't the update channels you're looking for." - Ben Obi-Wan Kenobi
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -130,7 +130,12 @@ class Admin implements ISettings {
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function getSection(): string {
|
||||
public function getSection(): ?string {
|
||||
if (!$this->config->getSystemValueBool('updatechecker', true)) {
|
||||
// update checker is disabled so we do not show the section at all
|
||||
return null;
|
||||
}
|
||||
|
||||
return 'overview';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||
use Test\TestCase;
|
||||
|
||||
class UpdateAvailableNotificationsTest extends TestCase {
|
||||
private ServerVersion $serverVersion;
|
||||
private ServerVersion&MockObject $serverVersion;
|
||||
private IConfig|MockObject $config;
|
||||
private IManager|MockObject $notificationManager;
|
||||
private IGroupManager|MockObject $groupManager;
|
||||
|
|
@ -96,13 +96,12 @@ class UpdateAvailableNotificationsTest extends TestCase {
|
|||
$job->expects($this->once())
|
||||
->method('checkAppUpdates');
|
||||
|
||||
$this->config->expects($this->exactly(2))
|
||||
$this->config->expects(self::exactly(2))
|
||||
->method('getSystemValueBool')
|
||||
->willReturnMap([
|
||||
['has_internet_connection', true, true],
|
||||
['debug', false, true],
|
||||
['has_internet_connection', true, true],
|
||||
]);
|
||||
|
||||
self::invokePrivate($job, 'run', [null]);
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +116,9 @@ class UpdateAvailableNotificationsTest extends TestCase {
|
|||
$job->expects($this->never())
|
||||
->method('checkAppUpdates');
|
||||
|
||||
$this->config->method('getSystemValueBool')
|
||||
$this->config
|
||||
->expects(self::once())
|
||||
->method('getSystemValueBool')
|
||||
->with('has_internet_connection', true)
|
||||
->willReturn(false);
|
||||
|
||||
|
|
@ -212,6 +213,13 @@ class UpdateAvailableNotificationsTest extends TestCase {
|
|||
->with('core', $version, $readableVersion);
|
||||
}
|
||||
|
||||
$this->config->expects(self::any())
|
||||
->method('getSystemValueBool')
|
||||
->willReturnMap([
|
||||
['updatechecker', true, true],
|
||||
['has_internet_connection', true, true],
|
||||
]);
|
||||
|
||||
self::invokePrivate($job, 'checkCoreUpdate');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,11 @@ class AdminTest extends TestCase {
|
|||
['updater.server.url', 'https://updates.nextcloud.com/updater_server/', 'https://updates.nextcloud.com/updater_server/'],
|
||||
['upgrade.disable-web', false, false],
|
||||
]);
|
||||
$this->config
|
||||
->expects(self::any())
|
||||
->method('getSystemValueBool')
|
||||
->with('updatechecker', true)
|
||||
->willReturn(true);
|
||||
$this->dateTimeFormatter
|
||||
->expects($this->once())
|
||||
->method('formatDateTime')
|
||||
|
|
@ -192,6 +197,11 @@ class AdminTest extends TestCase {
|
|||
->method('getValueInt')
|
||||
->with('core', 'lastupdatedat', 0)
|
||||
->willReturn(12345);
|
||||
$this->config
|
||||
->expects(self::any())
|
||||
->method('getSystemValueBool')
|
||||
->with('updatechecker', true)
|
||||
->willReturn(true);
|
||||
$this->config
|
||||
->expects($this->once())
|
||||
->method('getAppValue')
|
||||
|
|
@ -287,6 +297,11 @@ class AdminTest extends TestCase {
|
|||
->method('getValueInt')
|
||||
->with('core', 'lastupdatedat', 0)
|
||||
->willReturn(12345);
|
||||
$this->config
|
||||
->expects(self::any())
|
||||
->method('getSystemValueBool')
|
||||
->with('updatechecker', true)
|
||||
->willReturn(true);
|
||||
$this->config
|
||||
->expects($this->once())
|
||||
->method('getAppValue')
|
||||
|
|
@ -363,9 +378,25 @@ class AdminTest extends TestCase {
|
|||
|
||||
|
||||
public function testGetSection(): void {
|
||||
$this->config
|
||||
->expects(self::atLeastOnce())
|
||||
->method('getSystemValueBool')
|
||||
->with('updatechecker', true)
|
||||
->willReturn(true);
|
||||
|
||||
$this->assertSame('overview', $this->admin->getSection());
|
||||
}
|
||||
|
||||
public function testGetSectionDisabled(): void {
|
||||
$this->config
|
||||
->expects(self::atLeastOnce())
|
||||
->method('getSystemValueBool')
|
||||
->with('updatechecker', true)
|
||||
->willReturn(false);
|
||||
|
||||
$this->assertNull($this->admin->getSection());
|
||||
}
|
||||
|
||||
public function testGetPriority(): void {
|
||||
$this->assertSame(11, $this->admin->getPriority());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue