-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Do not require sudo mode in development context
The sudo mode, introduced in #92836, is required whenever the install tool is accessed in the backend. Especially in development context accessing the install tool is a frequent task, e.g. for clearing all caches, to test global configuration or to run the database analyzer. Therefore, the sudo mode is now not longer required while the installations application context is set to "Development". Resolves: #93160 Releases: master, 10.4, 9.5 Change-Id: If61fa08847181491c01417d301a6bc1f480bae1b Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68097 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
typo3/sysext/install/Tests/Functional/Controller/BackendModuleControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
namespace TYPO3\CMS\Install\Tests\Functional\Controller; | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
use TYPO3\CMS\Core\Core\ApplicationContext; | ||
use TYPO3\CMS\Core\Core\Environment; | ||
use TYPO3\CMS\Install\Controller\BackendModuleController; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
class BackendModuleControllerTest extends FunctionalTestCase | ||
{ | ||
/** | ||
* @test | ||
* @dataProvider environmentContextIsRespectedTestDataProvider | ||
* | ||
* @param string $module | ||
*/ | ||
public function environmentContextIsRespectedTest(string $module): void | ||
{ | ||
$subject = new BackendModuleController(); | ||
$action = $module . 'Action'; | ||
|
||
self::assertIsCallable([$subject, $action]); | ||
|
||
// Ensure we are not in development context | ||
self::assertFalse(Environment::getContext()->isDevelopment()); | ||
|
||
// Sudo mode is required | ||
self::assertEquals(403, $subject->{$action}()->getStatusCode()); | ||
|
||
// Initialize environment with development context | ||
Environment::initialize( | ||
new ApplicationContext('Development'), | ||
Environment::isComposerMode(), | ||
Environment::isComposerMode(), | ||
Environment::getProjectPath(), | ||
Environment::getPublicPath(), | ||
Environment::getVarPath(), | ||
Environment::getConfigPath(), | ||
Environment::getBackendPath() . '/index.php', | ||
Environment::isWindows() ? 'WINDOWS' : 'UNIX' | ||
); | ||
|
||
// Authorized redirect to the install tool is performed, sudo mode is not required | ||
$response = $subject->{$action}(); | ||
self::assertEquals(303, $response->getStatusCode()); | ||
self::assertNotEmpty($response->getHeader('location')); | ||
self::assertStringContainsString( | ||
'install.php?install[controller]=' . $module . '&install[context]=backend', | ||
$response->getHeaderLine('location') | ||
); | ||
} | ||
|
||
public function environmentContextIsRespectedTestDataProvider(): \Generator | ||
{ | ||
yield 'maintenance module' => ['maintenance']; | ||
yield 'settings module' => ['settings']; | ||
yield 'upgrade module' => ['upgrade']; | ||
yield 'environment module' => ['environment']; | ||
} | ||
} |