mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/11997] Fix tests for path_helper's get_controller_redirect_url()
PHPBB3-11997
This commit is contained in:
parent
a7f2788c72
commit
f32a30eeca
2 changed files with 29 additions and 19 deletions
|
@ -115,28 +115,27 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||||
*/
|
*/
|
||||||
public function test_redirect()
|
public function test_redirect()
|
||||||
{
|
{
|
||||||
|
$filesystem = new \phpbb\filesystem();
|
||||||
$this->phpbb_extension_manager->enable('foo/bar');
|
$this->phpbb_extension_manager->enable('foo/bar');
|
||||||
$crawler = self::request('GET', 'app.php/foo/redirect');
|
$crawler = self::request('GET', 'app.php/foo/redirect');
|
||||||
|
|
||||||
$test_redirects = array(
|
$test_redirects = array(
|
||||||
'index.php',
|
'index.php',
|
||||||
'../index.php',
|
'index.php',
|
||||||
|
'tests/index.php',
|
||||||
'tests/index.php',
|
'tests/index.php',
|
||||||
'../tests/index.php',
|
|
||||||
'app.php/index',
|
'app.php/index',
|
||||||
'index',
|
'app.php/index',
|
||||||
'../index',
|
'app.php/index',
|
||||||
|
'app.php/tests/index',
|
||||||
|
'app.php/tests/index',
|
||||||
|
'app.php/tests/index',
|
||||||
'app.php/tests/index',
|
'app.php/tests/index',
|
||||||
'tests/index',
|
|
||||||
'../tests/index',
|
|
||||||
'index',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$filesystem = new \phpbb\filesystem();
|
|
||||||
|
|
||||||
foreach ($test_redirects as $row_num => $redirect)
|
foreach ($test_redirects as $row_num => $redirect)
|
||||||
{
|
{
|
||||||
$this->assertContains($filesystem->clean_path(self::$root_url . $redirect), $crawler->filter('#redirect_' . $row_num)->text());
|
$this->assertContains($filesystem->clean_path(self::$root_url) . $redirect, $crawler->filter('#redirect_' . $row_num)->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpbb_extension_manager->purge('foo/bar');
|
$this->phpbb_extension_manager->purge('foo/bar');
|
||||||
|
|
|
@ -26,21 +26,21 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
|
||||||
array('http://localhost/phpBB/app.php/foobar', false, false, 'http://localhost/phpBB/app.php/foobar'),
|
array('http://localhost/phpBB/app.php/foobar', false, false, 'http://localhost/phpBB/app.php/foobar'),
|
||||||
array('./app.php/foobar', false, false, 'http://localhost/phpBB/app.php/foobar'),
|
array('./app.php/foobar', false, false, 'http://localhost/phpBB/app.php/foobar'),
|
||||||
array('app.php/foobar', false, false, 'http://localhost/phpBB/app.php/foobar'),
|
array('app.php/foobar', false, false, 'http://localhost/phpBB/app.php/foobar'),
|
||||||
array('./../app.php/foobar', false, false, 'http://localhost/app.php/foobar'),
|
array('./../app.php/foobar', false, false, 'http://localhost/phpBB/app.php/foobar'),
|
||||||
array('./../app.php/foobar', true, false, 'http://localhost/app.php/foobar'),
|
array('./../app.php/foobar', true, 'INSECURE_REDIRECT', false),
|
||||||
array('./../app.php/foo/bar', false, false, 'http://localhost/app.php/foo/bar'),
|
array('./../app.php/foo/bar', false, false, 'http://localhost/phpBB/app.php/foo/bar'),
|
||||||
array('./../app.php/foo/bar', true, false, 'http://localhost/app.php/foo/bar'),
|
array('./../app.php/foo/bar', true, 'INSECURE_REDIRECT', false),
|
||||||
array('./../foo/bar', false, false, 'http://localhost/foo/bar'),
|
array('./../foo/bar', false, false, 'http://localhost/phpBB/foo/bar'),
|
||||||
array('./../foo/bar', true, false, 'http://localhost/foo/bar'),
|
array('./../foo/bar', true, 'INSECURE_REDIRECT', false),
|
||||||
array('app.php/', false, false, 'http://localhost/phpBB/app.php/'),
|
array('app.php/', false, false, 'http://localhost/phpBB/app.php/'),
|
||||||
array('./app.php/', false, false, 'http://localhost/phpBB/app.php/'),
|
array('./app.php/', false, false, 'http://localhost/phpBB/app.php/'),
|
||||||
array('foobar', false, false, 'http://localhost/phpBB/foobar'),
|
array('foobar', false, false, 'http://localhost/phpBB/foobar'),
|
||||||
array('./foobar', false, false, 'http://localhost/phpBB/foobar'),
|
array('./foobar', false, false, 'http://localhost/phpBB/foobar'),
|
||||||
array('foo/bar', false, false, 'http://localhost/phpBB/foo/bar'),
|
array('foo/bar', false, false, 'http://localhost/phpBB/foo/bar'),
|
||||||
array('./foo/bar', false, false, 'http://localhost/phpBB/foo/bar'),
|
array('./foo/bar', false, false, 'http://localhost/phpBB/foo/bar'),
|
||||||
array('./../index.php', false, false, 'http://localhost/index.php'),
|
array('./../index.php', false, false, 'http://localhost/phpBB/index.php'),
|
||||||
array('./../index.php', true, false, 'http://localhost/index.php'),
|
array('./../index.php', true, false, 'http://localhost/index.php'),
|
||||||
array('../index.php', false, false, 'http://localhost/index.php'),
|
array('../index.php', false, false, 'http://localhost/phpBB/index.php'),
|
||||||
array('../index.php', true, false, 'http://localhost/index.php'),
|
array('../index.php', true, false, 'http://localhost/index.php'),
|
||||||
array('./index.php', false, false, 'http://localhost/phpBB/index.php'),
|
array('./index.php', false, false, 'http://localhost/phpBB/index.php'),
|
||||||
);
|
);
|
||||||
|
@ -53,6 +53,15 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
|
||||||
$GLOBALS['config'] = array(
|
$GLOBALS['config'] = array(
|
||||||
'force_server_vars' => '0',
|
'force_server_vars' => '0',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->path_helper = new \phpbb\path_helper(
|
||||||
|
new \phpbb\symfony_request(
|
||||||
|
new phpbb_mock_request()
|
||||||
|
),
|
||||||
|
new \phpbb\filesystem(),
|
||||||
|
$this->phpbb_root_path,
|
||||||
|
'php'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +69,9 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
|
||||||
*/
|
*/
|
||||||
public function test_redirect($test, $disable_cd_check, $expected_error, $expected_result)
|
public function test_redirect($test, $disable_cd_check, $expected_error, $expected_result)
|
||||||
{
|
{
|
||||||
global $user, $phpbb_root_path;
|
global $user, $phpbb_root_path, $phpbb_path_helper;
|
||||||
|
|
||||||
|
$phpbb_path_helper = $this->path_helper;
|
||||||
|
|
||||||
$temp_phpbb_root_path = $phpbb_root_path;
|
$temp_phpbb_root_path = $phpbb_root_path;
|
||||||
// We need to hack phpbb_root_path here, so it matches the actual fileinfo of the testing script.
|
// We need to hack phpbb_root_path here, so it matches the actual fileinfo of the testing script.
|
||||||
|
|
Loading…
Add table
Reference in a new issue