‪TYPO3CMS  11.5
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  public const ‪ENABLE_INSTALL_TOOL_FILE = 'ENABLE_INSTALL_TOOL';
28  public const ‪ADDITIONAL_CONFIGURATION_FILE = 'AdditionalConfiguration.php';
29  public const ‪INSTALL_TOOL_PASSWORD = 'temporary password';
30 
31  public function ‪_before(‪ApplicationTester $I): void
32  {
33  $I->amOnPage('typo3/install.php');
34  }
35 
36  public function ‪_after(‪ApplicationTester $I): void
37  {
38  $I->click('Logout');
39  // Make sure logout has finished
40  $I->waitForText('The Install Tool is locked', 20);
41 
42  $I->amGoingTo('clean up created files');
43  if (getenv('TYPO3_ACCEPTANCE_INSTALLTOOL_PW_PRESET') !== '1') {
44  unlink(getenv('TYPO3_ACCEPTANCE_PATH_CONFIG') . '/' . self::ADDITIONAL_CONFIGURATION_FILE);
45  }
46 
47  $I->dontSeeFileFound($this->‪getEnableInstallToolFilePath());
48  if (getenv('TYPO3_ACCEPTANCE_INSTALLTOOL_PW_PRESET') !== '1') {
49  $I->dontSeeFileFound(getenv('TYPO3_ACCEPTANCE_PATH_CONFIG') . '/' . self::ADDITIONAL_CONFIGURATION_FILE);
50  }
51  }
52 
53  protected function ‪getEnableInstallToolFilePath(): string
54  {
55  return getenv('TYPO3_ACCEPTANCE_PATH_CONFIG') . '/' . ‪self::ENABLE_INSTALL_TOOL_FILE;
56  }
57 
58  protected function ‪logIntoInstallTool(‪ApplicationTester $I): void
59  {
60  $password = $this->‪setInstallToolPassword($I);
61 
62  printf("write to file: %s\n", $this->‪getEnableInstallToolFilePath());
63  $I->writeToFile($this->‪getEnableInstallToolFilePath(), '');
64  $I->reloadPage();
65  $I->waitForElementVisible('#t3-install-form-password');
66  $I->fillField('#t3-install-form-password', $password);
67  $I->click('Login');
68  $I->waitForText('Maintenance');
69  }
70 
74  private function ‪setInstallToolPassword(‪ApplicationTester $I): string
75  {
77  if (getenv('TYPO3_ACCEPTANCE_INSTALLTOOL_PW_PRESET') === '1') {
78  return $password;
79  }
80  $hashMethod = GeneralUtility::makeInstance(Argon2iPasswordHash::class);
81  $hashedPassword = $hashMethod->getHashedPassword($password);
82  $I->writeToFile(
83  getenv('TYPO3_ACCEPTANCE_PATH_CONFIG') . '/' . self::ADDITIONAL_CONFIGURATION_FILE,
84  '<?php' . PHP_EOL . '$GLOBALS[\'TYPO3_CONF_VARS\'][\'BE\'][\'installToolPassword\'] = \'' . $hashedPassword . '\';'
85  );
86  return $password;
87  }
88 }
‪TYPO3\CMS\Core\Crypto\PasswordHashing\InvalidPasswordHashException
Definition: InvalidPasswordHashException.php:25
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\_after
‪_after(ApplicationTester $I)
Definition: AbstractCest.php:36
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\logIntoInstallTool
‪logIntoInstallTool(ApplicationTester $I)
Definition: AbstractCest.php:58
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\ENABLE_INSTALL_TOOL_FILE
‪const ENABLE_INSTALL_TOOL_FILE
Definition: AbstractCest.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool
Definition: AbstractCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\getEnableInstallToolFilePath
‪getEnableInstallToolFilePath()
Definition: AbstractCest.php:53
‪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:31
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Crypto\PasswordHashing\Argon2iPasswordHash
Definition: Argon2iPasswordHash.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\ADDITIONAL_CONFIGURATION_FILE
‪const ADDITIONAL_CONFIGURATION_FILE
Definition: AbstractCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\setInstallToolPassword
‪setInstallToolPassword(ApplicationTester $I)
Definition: AbstractCest.php:74
‪TYPO3\CMS\Core\Tests\Acceptance\Application\InstallTool\AbstractCest\INSTALL_TOOL_PASSWORD
‪const INSTALL_TOOL_PASSWORD
Definition: AbstractCest.php:29