‪TYPO3CMS  ‪main
AbstractCest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
24 
26 {
27  private const ‪ADDITIONAL_CONFIGURATION_FILEPATH = '/system/additional.php';
28  protected const ‪INSTALL_TOOL_PASSWORD = 'temporary password';
29 
30  public function ‪_before(‪ApplicationTester $I): void
31  {
32  $I->amOnPage('typo3/install.php');
33  }
34 
35  public function ‪_after(‪ApplicationTester $I): void
36  {
37  $I->click('Logout');
38  // Make sure logout has finished
39  $I->waitForText('The Install Tool is locked', 20);
40 
41  $I->amGoingTo('clean up created files');
42  if (getenv('TYPO3_ACCEPTANCE_INSTALLTOOL_PW_PRESET') !== '1') {
43  unlink(getenv('TYPO3_ACCEPTANCE_PATH_CONFIG') . self::ADDITIONAL_CONFIGURATION_FILEPATH);
44  }
45 
46  $I->dontSeeFileFound($this->‪getEnableInstallToolFilePath());
47  if (getenv('TYPO3_ACCEPTANCE_INSTALLTOOL_PW_PRESET') !== '1') {
48  $I->dontSeeFileFound(getenv('TYPO3_ACCEPTANCE_PATH_CONFIG') . self::ADDITIONAL_CONFIGURATION_FILEPATH);
49  }
50  }
51 
52  protected function ‪getEnableInstallToolFilePath(): string
53  {
54  return getenv('TYPO3_ACCEPTANCE_PATH_VAR') . '/transient/' . ‪EnableFileService::INSTALL_TOOL_ENABLE_FILE_PATH;
55  }
56 
57  protected function ‪logIntoInstallTool(‪ApplicationTester $I): void
58  {
59  $password = $this->‪setInstallToolPassword($I);
60 
61  $I->writeToFile($this->‪getEnableInstallToolFilePath(), '');
62  $I->reloadPage();
63  $I->waitForElementVisible('#t3-install-form-password');
64  $I->fillField('#t3-install-form-password', $password);
65  $I->click('Login');
66  $I->waitForText('Maintenance');
67  }
68 
69  private function ‪setInstallToolPassword(‪ApplicationTester $I): string
70  {
72  if (getenv('TYPO3_ACCEPTANCE_INSTALLTOOL_PW_PRESET') === '1') {
73  return $password;
74  }
75  $hashMethod = GeneralUtility::makeInstance(Argon2iPasswordHash::class);
76  $hashedPassword = $hashMethod->getHashedPassword($password);
77  $I->writeToFile(
78  getenv('TYPO3_ACCEPTANCE_PATH_CONFIG') . self::ADDITIONAL_CONFIGURATION_FILEPATH,
79  '<?php' . PHP_EOL . '$GLOBALS[\'TYPO3_CONF_VARS\'][\'BE\'][\'installToolPassword\'] = \'' . $hashedPassword . '\';'
80  );
81  return $password;
82  }
83 }
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:28
‪TYPO3\CMS\Install\Service\EnableFileService\INSTALL_TOOL_ENABLE_FILE_PATH
‪const INSTALL_TOOL_ENABLE_FILE_PATH
Definition: EnableFileService.php:30
‪TYPO3\CMS\Install\Service\EnableFileService
Definition: EnableFileService.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\_after
‪_after(ApplicationTester $I)
Definition: AbstractCest.php:35
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\logIntoInstallTool
‪logIntoInstallTool(ApplicationTester $I)
Definition: AbstractCest.php:57
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool
Definition: AbstractCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\getEnableInstallToolFilePath
‪getEnableInstallToolFilePath()
Definition: AbstractCest.php:52
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest
Definition: AbstractCest.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\_before
‪_before(ApplicationTester $I)
Definition: AbstractCest.php:30
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\ADDITIONAL_CONFIGURATION_FILEPATH
‪const ADDITIONAL_CONFIGURATION_FILEPATH
Definition: AbstractCest.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Crypto\PasswordHashing\Argon2iPasswordHash
Definition: Argon2iPasswordHash.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\setInstallToolPassword
‪setInstallToolPassword(ApplicationTester $I)
Definition: AbstractCest.php:69
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\INSTALL_TOOL_PASSWORD
‪const INSTALL_TOOL_PASSWORD
Definition: AbstractCest.php:28