? simpletest_339210.patch
? sites/default/files
? sites/default/settings.php
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.92
diff -u -p -r1.92 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	30 Mar 2009 05:35:35 -0000	1.92
+++ modules/simpletest/drupal_web_test_case.php	15 Apr 2009 12:51:54 -0000
@@ -395,6 +395,12 @@ class DrupalWebTestCase {
    * Run all tests in this class.
    */
   public function run() {
+    // HTTP auth settings for the simpletest browser when sending requests
+    // to the test site. Can be enabled or disabled with $this->httpauth.
+    $this->httpauth = variable_get('simpletest_httpauth', FALSE);
+    $this->httpauth_username = variable_get('simpletest_httpauth_username', '');
+    $this->httpauth_pass = variable_get('simpletest_httpauth_pass', '');
+ 
     set_error_handler(array($this, 'errorHandler'));
     $methods = array();
     // Iterate through all the methods in this class.
@@ -941,9 +947,11 @@ class DrupalWebTestCase {
   /**
    * Initializes the cURL connection.
    *
-   * This function will add authentication headers as specified in the
-   * simpletest_httpauth_username and simpletest_httpauth_pass variables. Also,
-   * see the description of $curl_options among the properties.
+   * If the simpletest_httpauth variable is set, this function will add
+   * authentication headers as specified in the simpletest_httpauth_username
+   * and simpletest_httpauth_pass variables. This is neccessary for testing
+   * sites that are protected by login credentials from public access.
+   * Also, see the description of $curl_options among the properties.
    */
   protected function curlInitialize() {
     global $base_url, $db_prefix;
@@ -962,11 +970,15 @@ class DrupalWebTestCase {
       if (preg_match('/simpletest\d+/', $db_prefix, $matches)) {
         $curl_options[CURLOPT_USERAGENT] = $matches[0];
       }
-      if (!isset($curl_options[CURLOPT_USERPWD]) && ($auth = variable_get('simpletest_httpauth_username', ''))) {
-        if ($pass = variable_get('simpletest_httpauth_pass', '')) {
-          $auth .= ':' . $pass;
+      if ($this->httpauth) {
+        $curl_options[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
+        if (empty($curl_options[CURLOPT_USERPWD]) && (!empty($this->httpauth_username))) {
+	  $auth = $this->httpauth_username;
+          if (!empty($this->httpauth_pass)) {
+            $auth .= ':' . $this->httpauth_pass;
+          }
+          $curl_options[CURLOPT_USERPWD] = $auth;
         }
-        $curl_options[CURLOPT_USERPWD] = $auth;
       }
       curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
     }
