Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
26 / 26 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| phpbb_security_test_base | |
100.00% |
26 / 26 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| setUp | |
100.00% |
24 / 24 |
|
100.00% |
1 / 1 |
1 | |||
| tearDown | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | abstract class phpbb_security_test_base extends phpbb_test_case |
| 15 | { |
| 16 | protected $server = array(); |
| 17 | |
| 18 | /** |
| 19 | * Set up the required user object and server variables for the suites |
| 20 | */ |
| 21 | protected function setUp(): void |
| 22 | { |
| 23 | global $user, $phpbb_root_path, $phpEx, $request, $symfony_request, $phpbb_filesystem; |
| 24 | |
| 25 | // Put this into a global function being run by every test to init a proper user session |
| 26 | $this->server['HTTP_HOST'] = 'localhost'; |
| 27 | $this->server['SERVER_NAME'] = 'localhost'; |
| 28 | $this->server['SERVER_ADDR'] = '127.0.0.1'; |
| 29 | $this->server['SERVER_PORT'] = 80; |
| 30 | $this->server['REMOTE_ADDR'] = '127.0.0.1'; |
| 31 | $this->server['QUERY_STRING'] = ''; |
| 32 | $this->server['REQUEST_URI'] = '/tests/'; |
| 33 | $this->server['SCRIPT_NAME'] = '/tests/index.php'; |
| 34 | $this->server['SCRIPT_FILENAME'] = '/var/www/tests/index.php'; |
| 35 | $this->server['PHP_SELF'] = '/tests/index.php'; |
| 36 | $this->server['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'; |
| 37 | $this->server['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3'; |
| 38 | |
| 39 | /* |
| 40 | [HTTP_ACCEPT_ENCODING] => gzip,deflate |
| 41 | [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 |
| 42 | DOCUMENT_ROOT] => /var/www/ |
| 43 | [SCRIPT_FILENAME] => /var/www/tests/index.php |
| 44 | */ |
| 45 | |
| 46 | $request = new phpbb_mock_request(array(), array(), array(), $this->server); |
| 47 | $symfony_request = new \phpbb\symfony_request($request); |
| 48 | |
| 49 | $phpbb_filesystem = new \phpbb\filesystem\filesystem(); |
| 50 | |
| 51 | // Set no user and trick a bit to circumvent errors |
| 52 | $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); |
| 53 | $lang = new \phpbb\language\language($lang_loader); |
| 54 | $user = new \phpbb\user($lang, '\phpbb\datetime'); |
| 55 | $user->browser = $this->server['HTTP_USER_AGENT']; |
| 56 | $user->referer = ''; |
| 57 | $user->forwarded_for = ''; |
| 58 | $user->host = $this->server['HTTP_HOST']; |
| 59 | $user->page = \phpbb\session::extract_current_page($phpbb_root_path); |
| 60 | } |
| 61 | |
| 62 | protected function tearDown(): void |
| 63 | { |
| 64 | global $user; |
| 65 | $user = NULL; |
| 66 | } |
| 67 | } |