Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consider file permissions when writing configuration in system tests (#…
…43466) * Fix for issue #43465 writing configuration.php Fix for issue #43465 'Cypress System Tests fail when writing configuration.php' . remember the original file permission . set 644 . write file . restore original file permission additional: . writing file to ${Cypress.env('cmsPath')}/configuration.php` and no more to 'configuration.php' . error handle file is not existing * typo * updated system tests README * corrected task names * Update tests/System/README.md of course, thank you for checking Co-authored-by: Richard Fath <richard67@users.noreply.github.com> * deleted failure handler config_setParameter() deleted failure handler for readFile as it is not needed, tested with chmod 0, Cypress fails with clear reason: CypressError: `cy.readFile("./configuration.php")` failed while trying to read the file at the following path: `.../43465/joomla-cms/configuration.php` The following error occurred: > "EACCES: permission denied, open '/Users/hlu/Desktop/no_backup/43465/joomla-cms/configuration.php'" * typo Co-authored-by: Brian Teeman <brian@teeman.net> * typo Co-authored-by: Brian Teeman <brian@teeman.net> * chain the then()-calls Chaining the then()-calls for a not so deeply nested code source looks catchy - thank Allon for the recommendation * adopted code formatting for better readability * fixing lint:js errors - deleted console.log statements - used const for never changing value - refactored file mask to not use bitwise operation '&' * fixed lint:testjs errors * Better fix for configuration.php permission issue Working with the code when fighting with the drone shows that a `chmod` was already implemented in `writeFile()`. Following changes with this commit: - Only using `chmod` method synchronously - Replaced setting directory mode to setting file mode before writing - Setting file mode only if the file exists - Having final file mode as parameter with default 0o444 - Using 0o444 as default file mode and not hard-wired 0o777 - The methods `getFilePermissions()` and `changeFilePermissions()` created for this PR earlier are deleted. Enhancement of the `tests/System/README.md` for troubleshooting three-user-problem in having Cypress running user, web server running user and `root` user. This commitment has been extensively tested in various combinations. Every test contains: - Checking error before - Doing the patch - Running installation twice and running overall test suite Tests are: - macOS 14.5 Sonoma, local with apache & Cypress same user, branch 4.4-dev - error before `> EACCES: permission denied, open './configuration.php'` - Docker, one container with joomla and one container with Cypress, using `root` users inside containers - no error before, but `configuration.php` is 777 - after the patch `configuration.php` is 444 inside container and shown 644 on host - tested four times, branches 4.4-dev, 5.1-dev, 5.2-dev and 6.0-dev - Ubuntu 24.04 LTS local installation, one non-root users running Cypress and another non-root user running Apache, branch 4.4-dev - error before `> EACCES: permission denied, open './configuration.php'` - need to use `sudo` and need to set `umask 0`, see troubleshooting - Windows 11 Pro, Laragon with Cmder, branch 4.4-dev - error before `> EPERM: operation not permitted, open 'C:\laragon\www\joomla-cms\configuration.php'` All tests are successful: - running `Installation.cy.js` twice, checking `configuration.php` 444 and params are set - running complete system test suite without errors * configuration.php CMS path relative && umask 0 - corrected mistake task writeFile was used with cmsPath + 'configuration.php' - extended writeFile to set process umask 0 - to prevent the 3-user-problem == no need to set umask 0 in sudo anymore This commitment has been tested in various combinations. Every test contains: - Checking error before - Doing the patch - Running Installation.cy.js only and running overall test suite Tests are: - Docker environment with drone images, root running Cypress and www-data running Apache, branch 4.4-dev - no error before, but /tests/www/cmysql/configuration.php has 777 - Ubuntu 24.04 LTS local installation, one non-root user running Cypress and another non-root user running Apache, branch 4.4-dev - error before `> EACCES: permission denied, open './configuration.php'` - need to use `sudo`, see troubleshooting (umask 0 is no more needed) - Windows 11 Pro, Laragon with Cmder, branch 4.4-dev - error before `> EPERM: operation not permitted, open 'C:\laragon\www\joomla-cms\configuration.php'` - found out that on the second run cy.exec('rm configuration.php') does not work under Windows - deleted file manually and i will create an issue afterwards to avoid enlarging this one - macOS 14.5 Sonoma, local with apache & Cypress same user, branch 4.4-dev - error before `> EACCES: permission denied, open './configuration.php'` All tests are successful: - running `Installation.cy.js`, checking `configuration.php` 444 and params are set - running complete system test suite without errors --------- Co-authored-by: Richard Fath <richard67@users.noreply.github.com> Co-authored-by: Brian Teeman <brian@teeman.net> Co-authored-by: Allon Moritz <allon.moritz@digital-peak.com>
- Loading branch information