From 42d2b92fcf2f8a00f67f16ac7ff8f2bd1821337b Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 4 Aug 2020 10:11:33 +0100 Subject: [PATCH] Issue #3136762 by dww, codersukanta, webchick, larowlan: Update.php includes link to 'Put site into maintenance mode' for users without permission to use it (cherry picked from commit 4833c49b0cd7c94ab59a4d741eed5732987515e5) --- core/modules/system/system.routing.yml | 2 +- .../Functional/UpdateSystem/UpdateScriptTest.php | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index e0f497860e..6a9c208742 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -220,7 +220,7 @@ system.site_maintenance_mode: _form: '\Drupal\system\Form\SiteMaintenanceModeForm' _title: 'Maintenance mode' requirements: - _permission: 'administer site configuration' + _permission: 'administer site configuration+administer software updates' system.run_cron: path: '/admin/reports/status/run-cron' diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php index 5cb492dfb3..827a9c8fc4 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php @@ -659,17 +659,26 @@ public function testSuccessfulMultilingualUpdateFunctionality() { * Tests maintenance mode link on update.php. */ public function testMaintenanceModeLink() { - $admin_user = $this->drupalCreateUser([ + $full_admin_user = $this->drupalCreateUser([ 'administer software updates', 'access administration pages', 'administer site configuration', ]); - $this->drupalLogin($admin_user); + $this->drupalLogin($full_admin_user); + $this->drupalGet($this->updateUrl, ['external' => TRUE]); + $this->assertSession()->statusCodeEquals(200); + $this->clickLink('maintenance mode'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->elementContains('css', 'main h1', 'Maintenance mode'); + + // Now login as a user with only 'administer software updates' (but not + // 'administer site configuration') permission and try again. + $this->drupalLogin($this->updateUser); $this->drupalGet($this->updateUrl, ['external' => TRUE]); $this->assertSession()->statusCodeEquals(200); $this->clickLink('maintenance mode'); $this->assertSession()->statusCodeEquals(200); - $this->assertEquals('Maintenance mode', $this->cssSelect('main h1')[0]->getText()); + $this->assertSession()->elementContains('css', 'main h1', 'Maintenance mode'); } /** -- GitLab