Skip to content
Snippets Groups Projects
Commit 24fad1cc authored by Jess's avatar Jess
Browse files

Issue #3135390 by munish.kumar, jungle, mondrake, xjm, daffie: Replace...

Issue #3135390 by munish.kumar, jungle, mondrake, xjm, daffie: Replace assertions involving calls to is_readable() and is_writeable() on files and directories with PHPUnit assertions
parent a7ff8b30
No related branches found
No related tags found
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -65,8 +65,10 @@ public function testSitesDirectoryHardeningConfig() {
$this->assertStringContainsString('settings.php is not protected from modifications and poses a security risk.', $description);
$this->assertStringContainsString('services.yml is not protected from modifications and poses a security risk.', $description);
$this->assertTrue(is_writable($site_path), 'Site directory remains writable when automatically fixing permissions is disabled.');
$this->assertTrue(is_writable($settings_file), 'settings.php remains writable when automatically fixing permissions is disabled.');
// Verify that site directory and the settings.php remain writable when
// automatically enforcing file permissions is disabled.
$this->assertDirectoryIsWritable($site_path);
$this->assertFileIsWritable($settings_file);
// Re-enable permissions enforcement.
$settings = Settings::getAll();
......@@ -77,8 +79,10 @@ public function testSitesDirectoryHardeningConfig() {
$requirements = $this->checkSystemRequirements();
$this->assertEquals('Protected', (string) $requirements['configuration_files']['value']);
$this->assertFalse(is_writable($site_path), 'Site directory is protected when automatically fixing permissions is enabled.');
$this->assertFalse(is_writable($settings_file), 'settings.php is protected when automatically fixing permissions is enabled.');
// Verify that site directory and the settings.php remain protected when
// automatically enforcing file permissions is enabled.
$this->assertDirectoryNotIsWritable($site_path);
$this->assertFileNotIsWritable($settings_file);
}
/**
......
......@@ -27,8 +27,8 @@ protected function prepareEnvironment() {
*/
protected function setUpSite() {
$site_directory = $this->container->getParameter('app.root') . '/' . $this->siteDirectory;
$this->assertTrue(is_writable($site_directory));
$this->assertTrue(is_writable($site_directory . '/settings.php'));
$this->assertDirectoryIsWritable($site_directory);
$this->assertFileIsWritable($site_directory . '/settings.php');
$this->assertSession()->responseContains('All necessary changes to <em class="placeholder">' . $this->siteDirectory . '</em> and <em class="placeholder">' . $this->siteDirectory . '/settings.php</em> have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href="https://www.drupal.org/server-permissions">online handbook</a>.');
......
......@@ -95,8 +95,8 @@ protected function setUpSite() {
// Test that SiteConfigureForm::buildForm() has made the site directory and
// the settings file non-writable.
$site_directory = $this->container->getParameter('app.root') . '/' . $this->siteDirectory;
$this->assertFalse(is_writable($site_directory));
$this->assertFalse(is_writable($site_directory . '/settings.php'));
$this->assertDirectoryNotIsWritable($site_directory);
$this->assertFileNotIsWritable($site_directory . '/settings.php');
parent::setUpSite();
}
......
......@@ -188,7 +188,7 @@ public function testGetMimeType() {
public function testIsValid() {
$this->getTestImage(FALSE);
$this->assertTrue($this->image->isValid());
$this->assertTrue(is_readable($this->image->getSource()));
$this->assertFileIsReadable($this->image->getSource());
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment