Commit 3874b0c8 authored by alexpott's avatar alexpott

Issue #2332029 by Eric115: Add test coverage for .htaccess rules

parent b6ee00e2
......@@ -15,21 +15,51 @@
* @group system
*/
class HtaccessTest extends WebTestBase {
/**
* Get an array of file paths for access testing.
*
* @return array
* An array of file paths to be access-tested.
*/
protected function getProtectedFiles() {
$path = drupal_get_path('module', 'system') . '/tests/fixtures/HtaccessTest';
$file_exts = [
'engine',
'inc',
'install',
'make',
'module',
'profile',
'po',
'sh',
'sql',
'theme',
'twig',
'tpl.php',
'xtmpl',
'yml',
];
foreach ($file_exts as $file_ext) {
$file_paths[] = "$path/access_test.$file_ext";
}
return $file_paths;
}
/**
* Tests accessing files with .yml extensions at various locations.
* Iterates over protected files and calls assertNoFileAccess().
*/
public function testYamlFileAccess() {
// Try accessing the core services YAML file.
$this->assertNoFileAccess('core/core.services.yml');
// Try accessing a core module YAML file.
$this->assertNoFileAccess('core/modules/system/system.services.yml');
public function testFileAccess() {
foreach ($this->getProtectedFiles() as $file) {
$this->assertNoFileAccess($file);
}
}
/**
* Asserts that a file exists but not accessible via HTTP.
*
* @param $path
* @param string $path
* Path to file. Without leading slash.
*/
protected function assertNoFileAccess($path) {
......
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