function ExtensionStreamTest::testPathTraversal

Tests path traversal.

Attributes

#[TestWith([ 'file_module_test.info.yml', TRUE, TRUE, ])] #[TestWith([ 'src/../file_module_test.info.yml', TRUE, TRUE, ])] #[TestWith([ '/./file_module_test.info.yml', TRUE, TRUE, ])] #[TestWith([ 'file_module_test.does_not_exist.yml', FALSE, FALSE, ])] #[TestWith([ 'src/../file_module_test.does_not_exist.yml', FALSE, FALSE, ])] #[TestWith([ 'src/../../../file.info.yml', FALSE, TRUE, ])]

File

core/tests/Drupal/KernelTests/Core/StreamWrapper/ExtensionStreamTest.php, line 260

Class

ExtensionStreamTest
Tests extension stream wrappers.

Namespace

Drupal\KernelTests\Core\StreamWrapper

Code

public function testPathTraversal(string $path, bool $stream_wrapper_exists, bool $file_exists) : void {
  $stream_assert = $stream_wrapper_exists ? 'assertFileExists' : 'assertFileDoesNotExist';
  $file_assert = $file_exists ? 'assertFileExists' : 'assertFileDoesNotExist';
  $this->{$stream_assert}('module://file_module_test/' . $path);
  $this->{$file_assert}($this->container
    ->get('module_handler')
    ->getModule('file_module_test')
    ->getPath() . "/{$path}");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.