Issue #2942769 by alexpott, Eli-T: Consolidate umami .htaccess files and testing

8.6.x
Gabor Hojtsy 2018-02-16 10:57:30 +01:00
parent c57b1901b8
commit 153931658e
5 changed files with 46 additions and 56 deletions

View File

@ -1,12 +0,0 @@
# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
# Turn off all options we don't need.
Options None
Options +FollowSymLinks

View File

@ -1,11 +0,0 @@
# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews

View File

@ -0,0 +1,46 @@
<?php
namespace Drupal\Tests\demo_umami_content\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests that files provided by demo_umami_content are not accessible.
*
* Note that this test only installs the testing profile because the Umami
* profile is not required for the test.
*
* @group demo_umami_content
*/
class DefaultContentFilesAccessTest extends BrowserTestBase {
/**
* Tests that sample images, recipes and articles are not accessible.
*/
public function testAccessDeniedToFiles() {
$file_name = 'chocolate-brownie-umami.jpg';
$file_path = '/' . drupal_get_path('module', 'demo_umami_content') . '/default_content/images/' . $file_name;
$this->assertTrue(file_exists(DRUPAL_ROOT . $file_path));
$this->drupalGet($file_path);
$this->assertSession()->statusCodeEquals(403);
$file_name = 'chocolate-brownie-umami.html';
$file_path = '/' . drupal_get_path('module', 'demo_umami_content') . '/default_content/recipe_instructions/' . $file_name;
$this->assertTrue(file_exists(DRUPAL_ROOT . $file_path));
$this->drupalGet($file_path);
$this->assertSession()->statusCodeEquals(403);
$file_name = 'lets-hear-it-for-carrots.html';
$file_path = '/' . drupal_get_path('module', 'demo_umami_content') . '/default_content/article_body/' . $file_name;
$this->assertTrue(file_exists(DRUPAL_ROOT . $file_path));
$this->drupalGet($file_path);
$this->assertSession()->statusCodeEquals(403);
$file_name = 'articles.csv';
$file_path = '/' . drupal_get_path('module', 'demo_umami_content') . '/default_content/' . $file_name;
$this->assertTrue(file_exists(DRUPAL_ROOT . $file_path));
$this->drupalGet($file_path);
$this->assertSession()->statusCodeEquals(403);
}
}

View File

@ -163,37 +163,4 @@ class DemoUmamiProfileTest extends BrowserTestBase {
$web_assert->pageTextNotContains('This installation is for demonstration purposes only.');
}
/**
* Tests that sample images are not accessible to the webserver.
*/
public function testAccessDeniedToSampleImages() {
$file_name = 'chocolate-brownie-umami.jpg';
$file_path = '/' . drupal_get_path('module', 'demo_umami_content') . '/default_content/images/' . $file_name;
$this->assertTrue(file_exists(DRUPAL_ROOT . $file_path));
$this->drupalGet($file_path);
$this->assertSession()->statusCodeEquals(403);
}
/**
* Tests that sample recipes are not accessible to the webserver.
*/
public function testAccessDeniedToSampleRecipes() {
$file_name = 'chocolate-brownie-umami.html';
$file_path = '/' . drupal_get_path('module', 'demo_umami_content') . '/default_content/recipe_instructions/' . $file_name;
$this->assertTrue(file_exists(DRUPAL_ROOT . $file_path));
$this->drupalGet($file_path);
$this->assertSession()->statusCodeEquals(403);
}
/**
* Tests that sample articles are not accessible to the webserver.
*/
public function testAccessDeniedToSampleArticles() {
$file_name = 'lets-hear-it-for-carrots.html';
$file_path = '/' . drupal_get_path('module', 'demo_umami_content') . '/default_content/article_body/' . $file_name;
$this->assertTrue(file_exists(DRUPAL_ROOT . $file_path));
$this->drupalGet($file_path);
$this->assertSession()->statusCodeEquals(403);
}
}