aboutsummaryrefslogtreecommitdiffstats
path: root/tests/security/base.php
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2011-01-07 01:39:18 +0100
committerIgor Wiedler <igor@wiedler.ch>2011-01-07 01:39:59 +0100
commit14a84cf89cd41da36545f5f04348c49d4eadfb45 (patch)
treeb04a5988c982b8b367697f03bde3f20ace7d022c /tests/security/base.php
parentda4617b14b11ade6f664b8c1ab94e3aeb5b7428d (diff)
parent5b752a2fed82f27cb1e383583dc4ccb87f7e12e5 (diff)
downloadforums-14a84cf89cd41da36545f5f04348c49d4eadfb45.tar
forums-14a84cf89cd41da36545f5f04348c49d4eadfb45.tar.gz
forums-14a84cf89cd41da36545f5f04348c49d4eadfb45.tar.bz2
forums-14a84cf89cd41da36545f5f04348c49d4eadfb45.tar.xz
forums-14a84cf89cd41da36545f5f04348c49d4eadfb45.zip
Merge branch 'develop-olympus' into develop
This commit also ports all ascraeus tests to the new format. Conflicts: tests/all_tests.php tests/network/all_tests.php tests/request/all_tests.php tests/request/request_var.php tests/template/templates/includephp.html
Diffstat (limited to 'tests/security/base.php')
-rw-r--r--tests/security/base.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/security/base.php b/tests/security/base.php
new file mode 100644
index 0000000000..db9c884cf4
--- /dev/null
+++ b/tests/security/base.php
@@ -0,0 +1,54 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+abstract class phpbb_security_test_base extends phpbb_test_case
+{
+ /**
+ * Set up the required user object and server variables for the suites
+ */
+ protected function setUp()
+ {
+ global $user, $phpbb_root_path;
+
+ // Put this into a global function being run by every test to init a proper user session
+ $_SERVER['HTTP_HOST'] = 'localhost';
+ $_SERVER['SERVER_NAME'] = 'localhost';
+ $_SERVER['SERVER_ADDR'] = '127.0.0.1';
+ $_SERVER['SERVER_PORT'] = 80;
+ $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+ $_SERVER['QUERY_STRING'] = '';
+ $_SERVER['REQUEST_URI'] = '/tests/';
+ $_SERVER['SCRIPT_NAME'] = '/tests/index.php';
+ $_SERVER['PHP_SELF'] = '/tests/index.php';
+ $_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';
+ $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
+
+/*
+ [HTTP_ACCEPT_ENCODING] => gzip,deflate
+ [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
+ DOCUMENT_ROOT] => /var/www/
+ [SCRIPT_FILENAME] => /var/www/tests/index.php
+*/
+
+ // Set no user and trick a bit to circumvent errors
+ $user = new user();
+ $user->lang = true;
+ $user->browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : '';
+ $user->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : '';
+ $user->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
+ $user->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
+ $user->page = session::extract_current_page($phpbb_root_path);
+ }
+
+ protected function tearDown()
+ {
+ global $user;
+ $user = NULL;
+ }
+}