Commit 24fad1cc authored by xjm's avatar xjm

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
......@@ -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());
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment