From 24ea052411f5b752ed75dce66f4e5e6b99a4d9a7 Mon Sep 17 00:00:00 2001 From: Anja Leichsenring Date: Thu, 10 Oct 2019 16:59:29 +0200 Subject: [PATCH] [TASK] Provide AcceptanceTest for stand alone install tool A simple test asserting the login and logout mechanics for the stand alone install tool are functional. Cards in the maintenance page received basic checks ensuring no Javascript errors occur. Additionally, typo3/testing-framework will be raised, so the new tests gets integrated into the automatic bamboo run. Used update command: composer update typo3/testing-framework Resolves: #89393 Resolves: #89397 Releases: master Change-Id: I1eb916405dec682fa57ee07794d892b1fc6255ab Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61945 Tested-by: TYPO3com Tested-by: Andreas Fernandez Tested-by: Anja Leichsenring Reviewed-by: Andreas Fernandez Reviewed-by: Anja Leichsenring --- composer.lock | 28 +++--- .../Acceptance/InstallTool/AbstractCest.php | 70 +++++++++++++ .../Acceptance/InstallTool/LoginCest.php | 87 +++++++++++++++++ .../InstallTool/MaintenanceCest.php | 97 +++++++++++++++++++ typo3/sysext/core/Tests/codeception.yml | 3 + 5 files changed, 271 insertions(+), 14 deletions(-) create mode 100644 typo3/sysext/core/Tests/Acceptance/InstallTool/AbstractCest.php create mode 100644 typo3/sysext/core/Tests/Acceptance/InstallTool/LoginCest.php create mode 100644 typo3/sysext/core/Tests/Acceptance/InstallTool/MaintenanceCest.php diff --git a/composer.lock b/composer.lock index 4ebb9a8e2e32..c177304ca321 100644 --- a/composer.lock +++ b/composer.lock @@ -4714,7 +4714,7 @@ "time": "2017-01-16T07:08:25+00:00" }, { - "name": "mikey179/vfsstream", + "name": "mikey179/vfsStream", "version": "v1.6.5", "source": { "type": "git", @@ -5118,8 +5118,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", @@ -5260,8 +5260,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "Utility class for timing", @@ -5390,8 +5390,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "The PHP Unit Testing framework.", @@ -5967,8 +5967,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "Collection of value objects that represent the types of the PHP type system", @@ -6509,16 +6509,16 @@ }, { "name": "typo3/testing-framework", - "version": "5.0.14", + "version": "5.0.15", "source": { "type": "git", "url": "https://github.com/TYPO3/testing-framework.git", - "reference": "7781f33c5e9ec705e963d336b435e2b79324d491" + "reference": "391f5595f04039dc7e79aa23ac55ef52858da658" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/7781f33c5e9ec705e963d336b435e2b79324d491", - "reference": "7781f33c5e9ec705e963d336b435e2b79324d491", + "url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/391f5595f04039dc7e79aa23ac55ef52858da658", + "reference": "391f5595f04039dc7e79aa23ac55ef52858da658", "shasum": "" }, "require": { @@ -6565,7 +6565,7 @@ "tests", "typo3" ], - "time": "2019-09-13T09:32:41+00:00" + "time": "2019-10-11T09:41:53+00:00" } ], "aliases": [], diff --git a/typo3/sysext/core/Tests/Acceptance/InstallTool/AbstractCest.php b/typo3/sysext/core/Tests/Acceptance/InstallTool/AbstractCest.php new file mode 100644 index 000000000000..35d58ee50ecb --- /dev/null +++ b/typo3/sysext/core/Tests/Acceptance/InstallTool/AbstractCest.php @@ -0,0 +1,70 @@ +amOnPage('typo3/install.php'); + } + + public function _after(BackendTester $I) + { + $I->click('Logout'); + + $I->amGoingTo('clean up created files'); + unlink(Environment::getProjectPath() . '/' . self::ADDITIONAL_CONFIGURATION_FILEPATH); + + $I->dontSeeFileFound(self::ENABLE_INSTALL_TOOL_FILEPATH); + $I->dontSeeFileFound(self::ADDITIONAL_CONFIGURATION_FILEPATH); + } + + protected function logIntoInstallTool(BackendTester $I) + { + $password = $this->setInstallToolPassword($I); + + $I->writeToFile(AbstractCest::ENABLE_INSTALL_TOOL_FILEPATH, ''); + $I->reloadPage(); + $I->fillField('#t3-install-form-password', $password); + $I->click('Login'); + $I->waitForText('Maintenance'); + } + + /** + * @param BackendTester $I + * @return string + * @throws \TYPO3\CMS\Core\Crypto\PasswordHashing\InvalidPasswordHashException + */ + private function setInstallToolPassword(BackendTester $I): string + { + $hashMethod = GeneralUtility::makeInstance(Argon2iPasswordHash::class); + $password = 'temporary password'; + $hashedPassword = $hashMethod->getHashedPassword($password); + $I->writeToFile( + self::ADDITIONAL_CONFIGURATION_FILEPATH, + 'amGoingTo('assert the install tool is locked in the first place'); + $I->see('The Install Tool is locked'); + $I->assertFileNotExists(self::ENABLE_INSTALL_TOOL_FILEPATH); + + $I->amGoingTo('lock the tool without logging in'); + $I->writeToFile(self::ENABLE_INSTALL_TOOL_FILEPATH, ''); + $I->seeFileFound(self::ENABLE_INSTALL_TOOL_FILEPATH); + $I->reloadPage(); + $I->see('Login to TYPO3 Install Tool'); + $I->click('Lock Install Tool again'); + $I->see('The Install Tool is locked'); + $I->dontSeeFileFound(self::ENABLE_INSTALL_TOOL_FILEPATH); + + $I->amGoingTo('log into Install Tool'); + $this->logIntoInstallTool($I); + + $I->amGoingTo('assert page Maintenance contains the 8 expected cards'); + $I->click('Maintenance'); + $I->see('Maintenance', 'h1'); + $I->see('Flush TYPO3 and PHP Cache', 'h1.card-title'); + $I->see('Analyze Database Structure', 'h1.card-title'); + $I->see('Remove Temporary Assets', 'h1.card-title'); + $I->see('Rebuild PHP Autoload Information', 'h1.card-title'); + $I->see('Clear Persistent Database Tables', 'h1.card-title'); + $I->see('Create Administrative User', 'h1.card-title'); + $I->see('Reset Backend User Preferences', 'h1.card-title'); + $I->see('Manage Language Packs', 'h1.card-title'); + $I->seeNumberOfElements('.card', 8); + + $I->amGoingTo('assert page Settings contains the 6 expected cards'); + $I->click('Settings'); + $I->see('Settings', 'h1'); + $I->see('Extension Configuration', 'h1.card-title'); + $I->see('Change Install Tool Password', 'h1.card-title'); + $I->see('Manage System Maintainers', 'h1.card-title'); + $I->see('Configuration Presets', 'h1.card-title'); + $I->see('Feature Toggles', 'h1.card-title'); + $I->see('Configure Installation-Wide Options', 'h1.card-title'); + $I->seeNumberOfElements('.card', 6); + + $I->amGoingTo('assert page Upgrade contains the 7 expected cards'); + $I->click('Upgrade'); + $I->see('Upgrade', 'h1'); + $I->see('Update TYPO3 Core', 'h1.card-title'); + $I->see('Upgrade Wizard', 'h1.card-title'); + $I->see('View Upgrade Documentation', 'h1.card-title'); + $I->see('Check TCA in ext_tables.php', 'h1.card-title'); + $I->see('Check for Broken Extensions', 'h1.card-title'); + $I->see('Check TCA Migrations', 'h1.card-title'); + $I->see('Scan Extension Files', 'h1.card-title'); + $I->seeNumberOfElements('.card', 7); + + $I->amGoingTo('assert page Environment contains the 6 expected cards'); + $I->click('Environment'); + $I->see('Environment', 'h1'); + $I->see('Environment Overview', 'h1.card-title'); + $I->see('Environment Status', 'h1.card-title'); + $I->see('Directory Status', 'h1.card-title'); + $I->see('PHP Info', 'h1.card-title'); + $I->see('Test Mail Setup', 'h1.card-title'); + $I->see('Image Processing', 'h1.card-title'); + $I->seeNumberOfElements('.card', 6); + } +} diff --git a/typo3/sysext/core/Tests/Acceptance/InstallTool/MaintenanceCest.php b/typo3/sysext/core/Tests/Acceptance/InstallTool/MaintenanceCest.php new file mode 100644 index 000000000000..af34b2aa93d8 --- /dev/null +++ b/typo3/sysext/core/Tests/Acceptance/InstallTool/MaintenanceCest.php @@ -0,0 +1,97 @@ +logIntoInstallTool($I); + $I->click('Maintenance'); + $I->see('Maintenance', 'h1'); + } + public function flushCacheWorks(BackendTester $I) + { + $I->click('Flush cache'); + $I->waitForElementVisible('.alert-success'); + $I->see('Caches cleared', '.alert-success h4'); + } + + public function analyzeDatabaseStructureWorks(BackendTester $I) + { + $I->click('Analyze database'); + $I->waitForElementVisible('.modal-dialog'); + $I->see('Analyze Database Structure', '.modal-dialog h4'); + $I->waitForElementVisible('.callout-success'); + $I->see('Database schema is up to date. Good job!', '.callout-success h4'); + $I->click('.t3js-modal-close'); + $I->waitForElementNotVisible('.modal-dialog'); + } + + public function removeTemporaryAssetsWorks(BackendTester $I) + { + $I->click('Scan temporary files'); + $I->waitForElementVisible('.modal-dialog'); + $I->see('Remove Temporary Assets', '.modal-dialog h4'); + $I->click('.t3js-modal-close'); + $I->waitForElementNotVisible('.modal-dialog'); + } + + public function dumpAutoloadWorks(BackendTester $I) + { + $I->click('Dump autoload'); + $I->waitForElementVisible('.alert-success'); + $I->see('Successfully dumped class loading information for extensions.', '.alert-success h4'); + } + + public function clearPersistentTablesWorks(BackendTester $I) + { + $I->click('Scan tables'); + $I->waitForElementVisible('.modal-dialog'); + $I->see('Clear Persistent Database Tables', '.modal-dialog h4'); + $I->click('.t3js-modal-close'); + $I->waitForElementNotVisible('.modal-dialog'); + } + + public function createAdminUserWorks(BackendTester $I) + { + $I->click('Create Administrator'); + $I->waitForElementVisible('.modal-dialog'); + $I->see('Create Administrative User', '.modal-dialog h4'); + $I->click('.t3js-modal-close'); + $I->waitForElementNotVisible('.modal-dialog'); + } + + public function resetBackendUserPreferencesWorks(BackendTester $I) + { + $I->click('Reset backend user preferences'); + $I->waitForElementVisible('.alert-success'); + $I->see('Preferences of all backend users have been reset', '.alert-success h4'); + } + + public function manageLanguagePacksWorks(BackendTester $I) + { + $I->click('Manage languages'); + $I->waitForElementVisible('.modal-dialog'); + $I->see('Manage Language Packs', '.modal-dialog h4'); + $I->see('Active Languages', '.modal-dialog h3'); + $I->click('.t3js-modal-close'); + $I->waitForElementNotVisible('.modal-dialog'); + } +} diff --git a/typo3/sysext/core/Tests/codeception.yml b/typo3/sysext/core/Tests/codeception.yml index 6371d9182165..1c966995bc44 100644 --- a/typo3/sysext/core/Tests/codeception.yml +++ b/typo3/sysext/core/Tests/codeception.yml @@ -11,3 +11,6 @@ extensions: enabled: - Codeception\Extension\RunFailed - Codeception\Extension\Recorder +modules: + enabled: + - Filesystem -- 2.20.1