[TASK] Provide AcceptanceTest for stand alone install tool 45/61945/12
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 10 Oct 2019 14:59:29 +0000 (16:59 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 12 Oct 2019 07:49:50 +0000 (09:49 +0200)
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 <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
composer.lock
typo3/sysext/core/Tests/Acceptance/InstallTool/AbstractCest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Acceptance/InstallTool/LoginCest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Acceptance/InstallTool/MaintenanceCest.php [new file with mode: 0644]
typo3/sysext/core/Tests/codeception.yml

index 4ebb9a8..c177304 100644 (file)
             "time": "2017-01-16T07:08:25+00:00"
         },
         {
-            "name": "mikey179/vfsstream",
+            "name": "mikey179/vfsStream",
             "version": "v1.6.5",
             "source": {
                 "type": "git",
             "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.",
             "authors": [
                 {
                     "name": "Sebastian Bergmann",
-                    "email": "sebastian@phpunit.de",
-                    "role": "lead"
+                    "role": "lead",
+                    "email": "sebastian@phpunit.de"
                 }
             ],
             "description": "Utility class for timing",
             "authors": [
                 {
                     "name": "Sebastian Bergmann",
-                    "email": "sebastian@phpunit.de",
-                    "role": "lead"
+                    "role": "lead",
+                    "email": "sebastian@phpunit.de"
                 }
             ],
             "description": "The PHP Unit Testing framework.",
             "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",
         },
         {
             "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": {
                 "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 (file)
index 0000000..35d58ee
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Core\Tests\Acceptance\InstallTool;
+
+/*
+ * 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\Environment;
+use TYPO3\CMS\Core\Crypto\PasswordHashing\Argon2iPasswordHash;
+use TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+class AbstractCest
+{
+    public const ENABLE_INSTALL_TOOL_FILEPATH = 'typo3conf/ENABLE_INSTALL_TOOL';
+    public const ADDITIONAL_CONFIGURATION_FILEPATH = 'typo3conf/AdditionalConfiguration.php';
+
+    public function _before(BackendTester $I)
+    {
+        $I->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,
+            '<?php' . PHP_EOL . '$GLOBALS[\'TYPO3_CONF_VARS\'][\'BE\'][\'installToolPassword\'] = \'' . $hashedPassword . '\';'
+        );
+        return $password;
+    }
+}
diff --git a/typo3/sysext/core/Tests/Acceptance/InstallTool/LoginCest.php b/typo3/sysext/core/Tests/Acceptance/InstallTool/LoginCest.php
new file mode 100644 (file)
index 0000000..2be9bee
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Core\Tests\Acceptance\InstallTool;
+
+/*
+ * 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\Tests\Acceptance\Support\BackendTester;
+
+class LoginCest extends AbstractCest
+{
+    public function installToolLogin(BackendTester $I)
+    {
+        $I->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 (file)
index 0000000..af34b2a
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Core\Tests\Acceptance\InstallTool;
+
+/*
+ * 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\Tests\Acceptance\Support\BackendTester;
+
+class MaintenanceCest extends AbstractCest
+{
+    public function _before(BackendTester $I)
+    {
+        parent::_before($I);
+        $this->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');
+    }
+}
index 6371d91..1c96699 100644 (file)
@@ -11,3 +11,6 @@ extensions:
   enabled:
     - Codeception\Extension\RunFailed
     - Codeception\Extension\Recorder
+modules:
+  enabled:
+    - Filesystem