diff options
| author | Nils Adermann <naderman@naderman.de> | 2010-03-10 16:24:19 +0100 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2010-03-10 16:24:19 +0100 |
| commit | 60bd1edcb5e5992e6e693d0f68db47e678f7d54a (patch) | |
| tree | dffc10407f0ef6a85d034415d7e30407ccf3f21a /tests/security/extract_current_page.php | |
| parent | d9567f121b11d3f5b068b85e7c862c27fc495005 (diff) | |
| download | forums-60bd1edcb5e5992e6e693d0f68db47e678f7d54a.tar forums-60bd1edcb5e5992e6e693d0f68db47e678f7d54a.tar.gz forums-60bd1edcb5e5992e6e693d0f68db47e678f7d54a.tar.bz2 forums-60bd1edcb5e5992e6e693d0f68db47e678f7d54a.tar.xz forums-60bd1edcb5e5992e6e693d0f68db47e678f7d54a.zip | |
[develop-olympus] Backported 3.1 unit tests to 3.0.
Start adding unit tests for bugs you fix! Tests for anything are
welcome really. We have to work on these a lot.
Diffstat (limited to 'tests/security/extract_current_page.php')
| -rw-r--r-- | tests/security/extract_current_page.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/security/extract_current_page.php b/tests/security/extract_current_page.php new file mode 100644 index 0000000000..8c72fe1440 --- /dev/null +++ b/tests/security/extract_current_page.php @@ -0,0 +1,53 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2008 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once 'test_framework/framework.php'; + +require_once '../phpBB/includes/functions.php'; +require_once '../phpBB/includes/session.php'; + +class phpbb_security_extract_current_page_test extends phpbb_test_case +{ + public static function security_variables() + { + return array( + array('http://localhost/phpBB/index.php', 'mark=forums&x="><script>alert(/XSS/);</script>', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E'), + array('http://localhost/phpBB/index.php', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E'), + ); + } + + /** + * @dataProvider security_variables + */ + public function test_query_string_php_self($url, $query_string, $expected) + { + $_SERVER['PHP_SELF'] = $url; + $_SERVER['QUERY_STRING'] = $query_string; + + $result = session::extract_current_page('./'); + + $label = 'Running extract_current_page on ' . $query_string . ' with PHP_SELF filled.'; + $this->assertEquals($expected, $result['query_string'], $label); + } + + /** + * @dataProvider security_variables + */ + public function test_query_string_request_uri($url, $query_string, $expected) + { + $_SERVER['REQUEST_URI'] = $url . '?' . $query_string; + $_SERVER['QUERY_STRING'] = $query_string; + + $result = session::extract_current_page('./'); + + $label = 'Running extract_current_page on ' . $query_string . ' with REQUEST_URI filled.'; + $this->assertEquals($expected, $result['query_string'], $label); + } +} + |
