mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-23 19:45:10 +01:00
[task/functional] Allow tests to bypass certain restrictions with DEBUG_TEST
PHPBB3-10758
This commit is contained in:
parent
7cffebbd49
commit
7dfe26dd78
@ -2811,7 +2811,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
|
||||
$diff = time() - $creation_time;
|
||||
|
||||
// If creation_time and the time() now is zero we can assume it was not a human doing this (the check for if ($diff)...
|
||||
if ($diff && ($diff <= $timespan || $timespan === -1))
|
||||
if (defined('DEBUG_TEST') || $diff && ($diff <= $timespan || $timespan === -1))
|
||||
{
|
||||
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
|
||||
$key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid);
|
||||
|
@ -551,10 +551,12 @@ function adjust_language_keys_callback($matches)
|
||||
* @param string $dbms The name of the DBAL class to use
|
||||
* @param array $load_extensions Array of additional extensions that should be loaded
|
||||
* @param bool $debug If the debug constants should be enabled by default or not
|
||||
* @param bool $debug_test If the DEBUG_TEST constant should be added
|
||||
* NOTE: Only for use within the testing framework
|
||||
*
|
||||
* @return string The output to write to the file
|
||||
*/
|
||||
function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false)
|
||||
function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false, $debug_test = false)
|
||||
{
|
||||
$load_extensions = implode(',', $load_extensions);
|
||||
|
||||
@ -584,6 +586,7 @@ function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug =
|
||||
{
|
||||
$config_data .= "@define('DEBUG', true);\n";
|
||||
$config_data .= "@define('DEBUG_EXTRA', true);\n";
|
||||
$config_data .= "@define('DEBUG_TEST', true);\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -47,13 +47,6 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
||||
// is not at least 2 seconds before submission, cancel the form
|
||||
$form_data['lastclick'] = 0;
|
||||
|
||||
// The add_form_key()/check_form_key() safeguards present a challenge because they require
|
||||
// the timestamp created in add_form_key() to be sent as-is to check_form_key() but in check_form_key()
|
||||
// it won't allow the current time to be the same as the timestamp it requires.
|
||||
// As such, automated scripts like this one have to somehow bypass this without being able to change
|
||||
// the timestamp. The only way I can think to do so is using sleep()
|
||||
sleep(1);
|
||||
|
||||
// I use a request because the form submission method does not allow you to send data that is not
|
||||
// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
|
||||
// Instead, I send it as a request with the submit button "post" set to true.
|
||||
@ -96,9 +89,8 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
||||
}
|
||||
}
|
||||
|
||||
// For reasoning behind the following two commands, see the test_post_new_topic() test
|
||||
// For reasoning behind the following command, see the test_post_new_topic() test
|
||||
$form_data['lastclick'] = 0;
|
||||
sleep(1);
|
||||
|
||||
// Submit the post
|
||||
$crawler = $this->client->request('POST', 'posting.php', $form_data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user