diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-12-07 13:28:44 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-12-07 13:28:44 +0100 |
commit | f32a30eecacba212850a11b7b4740d0a69bd49de (patch) | |
tree | 0e16041b781b9356564a1746005140f78ad60894 | |
parent | a7f2788c72dd45b65de494ca72d13aaee3b140d6 (diff) | |
download | forums-f32a30eecacba212850a11b7b4740d0a69bd49de.tar forums-f32a30eecacba212850a11b7b4740d0a69bd49de.tar.gz forums-f32a30eecacba212850a11b7b4740d0a69bd49de.tar.bz2 forums-f32a30eecacba212850a11b7b4740d0a69bd49de.tar.xz forums-f32a30eecacba212850a11b7b4740d0a69bd49de.zip |
[ticket/11997] Fix tests for path_helper's get_controller_redirect_url()
PHPBB3-11997
-rw-r--r-- | tests/functional/extension_controller_test.php | 19 | ||||
-rw-r--r-- | tests/security/redirect_test.php | 29 |
2 files changed, 29 insertions, 19 deletions
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index b280f01638..fe21ec5bd8 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -115,28 +115,27 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_redirect() { + $filesystem = new \phpbb\filesystem(); $this->phpbb_extension_manager->enable('foo/bar'); $crawler = self::request('GET', 'app.php/foo/redirect'); $test_redirects = array( 'index.php', - '../index.php', + 'index.php', + 'tests/index.php', 'tests/index.php', - '../tests/index.php', 'app.php/index', - 'index', - '../index', + 'app.php/index', + 'app.php/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) { - $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'); diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index 6ea94d33be..48360e3034 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -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('./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', true, false, 'http://localhost/app.php/foobar'), - array('./../app.php/foo/bar', false, false, 'http://localhost/app.php/foo/bar'), - array('./../app.php/foo/bar', true, false, 'http://localhost/app.php/foo/bar'), - array('./../foo/bar', false, false, 'http://localhost/foo/bar'), - array('./../foo/bar', true, false, 'http://localhost/foo/bar'), + array('./../app.php/foobar', false, false, 'http://localhost/phpBB/app.php/foobar'), + array('./../app.php/foobar', true, 'INSECURE_REDIRECT', false), + array('./../app.php/foo/bar', false, false, 'http://localhost/phpBB/app.php/foo/bar'), + array('./../app.php/foo/bar', true, 'INSECURE_REDIRECT', false), + array('./../foo/bar', false, false, 'http://localhost/phpBB/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('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('./../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', 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', false, false, 'http://localhost/phpBB/index.php'), ); @@ -53,6 +53,15 @@ class phpbb_security_redirect_test extends phpbb_security_test_base $GLOBALS['config'] = array( '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) { - 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; // We need to hack phpbb_root_path here, so it matches the actual fileinfo of the testing script. |