diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-07-22 04:45:35 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-07-22 04:45:35 +0000 |
commit | 3a29ee48f82eed3adfd2a90d0eae63a5903149fa (patch) | |
tree | c0de7a472a7db4dff57dd9b89c25d5e084c79ca8 /modules/simpletest | |
parent | 4ddecc05c9d2054568300d25748569dcd34fec7d (diff) | |
download | brdo-3a29ee48f82eed3adfd2a90d0eae63a5903149fa.tar.gz brdo-3a29ee48f82eed3adfd2a90d0eae63a5903149fa.tar.bz2 |
- Patch #3518404 by bopombatower: lock down DB config based on simpletest UA headers.
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 9 | ||||
-rw-r--r-- | modules/simpletest/simpletest.install | 9 |
2 files changed, 15 insertions, 3 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 8b5655d51..f04c99ec0 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -1194,6 +1194,7 @@ class DrupalWebTestCase extends DrupalTestCase { */ protected function curlInitialize() { global $base_url, $db_prefix; + if (!isset($this->curlHandle)) { $this->curlHandle = curl_init(); $curl_options = $this->additionalCurlOptions + array( @@ -1206,9 +1207,6 @@ class DrupalWebTestCase extends DrupalTestCase { CURLOPT_SSL_VERIFYHOST => FALSE, // Required to make the tests run on https. CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'), ); - if (preg_match('/simpletest\d+/', $db_prefix, $matches)) { - $curl_options[CURLOPT_USERAGENT] = $matches[0]; - } if (isset($this->httpauth_credentials)) { $curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials; } @@ -1217,6 +1215,11 @@ class DrupalWebTestCase extends DrupalTestCase { // By default, the child session name should be the same as the parent. $this->session_name = session_name(); } + // We set the user agent header on each request so as to use the current + // time and a new uniqid. + if (preg_match('/simpletest\d+/', $db_prefix, $matches)) { + curl_setopt($this->curlHandle, CURLOPT_USERAGENT, drupal_generate_test_ua($matches[0])); + } } /** diff --git a/modules/simpletest/simpletest.install b/modules/simpletest/simpletest.install index 6d77ff14e..42d625c93 100644 --- a/modules/simpletest/simpletest.install +++ b/modules/simpletest/simpletest.install @@ -130,6 +130,7 @@ function simpletest_requirements($phase) { $t = get_t(); $has_curl = function_exists('curl_init'); + $has_hash = function_exists('hash_hmac'); $has_domdocument = class_exists('DOMDocument'); $requirements['curl'] = array( @@ -140,6 +141,14 @@ function simpletest_requirements($phase) { $requirements['curl']['severity'] = REQUIREMENT_ERROR; $requirements['curl']['description'] = $t('Simpletest could not be installed because the PHP <a href="@curl_url">cURL</a> library is not available.', array('@curl_url' => 'http://php.net/manual/en/curl.setup.php')); } + $requirements['hash'] = array( + 'title' => $t('hash'), + 'value' => $has_hash ? $t('Enabled') : $t('Not found'), + ); + if (!$has_hash) { + $requirements['hash']['severity'] = REQUIREMENT_ERROR; + $requirements['hash']['description'] = $t('Simpletest could not be installed because the PHP <a href="@hash_url">hash</a> extension is disabled.', array('@hash_url' => 'http://php.net/manual/en/book.hash.php')); + } $requirements['php_domdocument'] = array( 'title' => $t('PHP DOMDocument class'), |