? simpletest_339210.patch
Index: drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.2.2.3.2.23
diff -u -p -r1.2.2.3.2.23 drupal_web_test_case.php
--- drupal_web_test_case.php	10 Dec 2008 16:29:26 -0000	1.2.2.3.2.23
+++ drupal_web_test_case.php	17 Dec 2008 15:18:31 -0000
@@ -679,6 +679,12 @@ class DrupalWebTestCase {
    *   List of modules to enable for the duration of the test.
    */
   function setUp() {
+    
+    // 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', '');
+    
     global $db_prefix;
 
     // Store necessary current values before switching to prefixed database.
@@ -795,11 +801,15 @@ class DrupalWebTestCase {
       if (preg_match('/simpletest\d+/', $db_prefix)) {
         $curl_options[CURLOPT_USERAGENT] = $db_prefix;
       }
-      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->ch, $this->curl_options + $curl_options);
     }
Index: simpletest.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.module,v
retrieving revision 1.33.2.4.2.10
diff -u -p -r1.33.2.4.2.10 simpletest.module
--- simpletest.module	31 Oct 2008 03:00:36 -0000	1.33.2.4.2.10
+++ simpletest.module	17 Dec 2008 15:18:31 -0000
@@ -29,6 +29,13 @@ function simpletest_menu() {
     'description' => 'Run tests against Drupal core and your active modules. These tests help assure that your site code is working as designed.',
     'access arguments' => array('administer unit tests'),
   );
+  $items['admin/settings/simpletest'] = array(
+    'title' => 'Simpletest settings',
+    'description' => 'Configure unit testing framework.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('simpletest_settings'),
+    'access arguments' => array('access administration pages'),
+  );
   return $items;
 }
 
@@ -611,3 +618,35 @@ function simpletest_clean_results_table(
     drupal_set_message(t('Removed @count test results.', array('@count' => $count)));
   }
 }
+
+/**
+ * Menu callback for simpletest HTTP auth settings
+ */
+function simpletest_settings() {
+  $form = array();
+
+  $form['http_auth'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('HTTP authentication'),
+    '#description' => t('If needed, enter a username and password for reaching your web site. This is not a drupal username/password.') .
+                      t('This is a login presented by your web server. Most sites may leave this section empty.'),
+  );
+  $form['http_auth']['simpletest_httpauth'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use http authentication'),
+    '#default_value' => variable_get('simpletest_httpauth', false),
+  );
+  $form['http_auth']['simpletest_httpauth_username'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Username'),
+    '#default_value' => variable_get('simpletest_httpauth_username', ''),
+  );
+  $form['http_auth']['simpletest_httpauth_pass'] = array(
+    '#title' => t('Password'),
+    '#type' => 'password',
+    '#default_value' => variable_get('simpletest_httpauth_pass', ''),
+  );
+  
+  return system_settings_form($form);
+
+}
