? simpletest_7_339210.patch
Index: drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.86
diff -u -p -r1.86 drupal_web_test_case.php
--- drupal_web_test_case.php	22 Feb 2009 20:12:03 -0000	1.86
+++ drupal_web_test_case.php	25 Feb 2009 12:11:06 -0000
@@ -813,6 +813,11 @@ class DrupalWebTestCase {
    */
   protected function setUp() {
     global $db_prefix, $user;
+    
+    // HTTP auth settings
+    $this->httpauth = variable_get('simpletest_httpauth', FALSE);
+    $this->httpauth_username = variable_get('simpletest_httpauth_username', '');
+    $this->httpauth_pass = variable_get('simpletest_httpauth_pass', '');
 
     // Store necessary current values before switching to prefixed database.
     $this->originalPrefix = $db_prefix;
@@ -963,11 +968,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);
     }
