Index: simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.51
diff -u -p -r1.51 drupal_web_test_case.php
--- simpletest/drupal_web_test_case.php	15 Oct 2008 16:05:51 -0000	1.51
+++ simpletest/drupal_web_test_case.php	16 Oct 2008 22:40:29 -0000
@@ -628,11 +628,13 @@ class DrupalWebTestCase {
    *
    * @param $user
    *   User object representing the user to login.
+   * @param $curl_restart
+   *   Restart the cURL session.
    * @return
    *   User that was logged in. Useful if no user was passed in order to retrieve
    *   the created user.
    */
-  function drupalLogin($user = NULL) {
+  function drupalLogin($user = NULL, $curl_restart = FALSE) {
     if ($this->_logged_in) {
       $this->drupalLogout();
     }
@@ -645,7 +647,7 @@ class DrupalWebTestCase {
       'name' => $user->name,
       'pass' => $user->pass_raw
     );
-    $this->drupalPost('user', $edit, t('Log in'));
+    $this->drupalPost('user', $edit, t('Log in'), array(), $curl_restart);
 
     $pass = $this->assertText($user->name, t('Found name: %name', array('%name' => $user->name)), t('User login'));
     $pass = $pass && $this->assertNoText(t('The username %name has been blocked.', array('%name' => $user->name)), t('No blocked message at login page'), t('User login'));
@@ -787,19 +789,27 @@ class DrupalWebTestCase {
    * This function will add authentication headers as specified in
    * simpletest_httpauth_username and simpletest_httpauth_pass variables.
    * Also, see the description of $curl_options among the properties.
+   *
+   * @param $curl_restart
+   *   Restart the cURL session.
    */
-  protected function curlConnect() {
+  protected function curlConnect($curl_restart = FALSE) {
     global $base_url, $db_prefix;
+    if ($curl_restart) {
+      $this->curlClose();
+    }
     if (!isset($this->ch)) {
       $this->ch = curl_init();
       $curl_options = $this->curl_options + array(
-        CURLOPT_COOKIEJAR => $this->cookie_file,
         CURLOPT_URL => $base_url,
         CURLOPT_FOLLOWLOCATION => TRUE,
         CURLOPT_RETURNTRANSFER => TRUE,
         CURLOPT_SSL_VERIFYPEER => FALSE,  // Required to make the tests run on https://
         CURLOPT_SSL_VERIFYHOST => FALSE,  // Required to make the tests run on https://
       );
+      if (!$curl_restart) {
+        $curl_options[CURLOPT_COOKIEJAR] = $this->cookie_file;
+      }
       if (preg_match('/simpletest\d+/', $db_prefix)) {
         $curl_options[CURLOPT_USERAGENT] = $db_prefix;
       }
@@ -818,12 +828,17 @@ class DrupalWebTestCase {
    *
    * @param
    *   $curl_options Custom cURL options.
+   * @param $curl_restart
+   *   Restart the cURL session.
    * @return
    *   Content returned from the exec.
    */
-  protected function curlExec($curl_options) {
-    $this->curlConnect();
+  protected function curlExec($curl_options, $curl_restart = FALSE) {
+    $this->curlConnect($curl_restart);
     $url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL];
+    if ($curl_restart) {
+      $curl_options[CURLOPT_COOKIEJAR] = $this->cookie_file;
+    }
     curl_setopt_array($this->ch, $this->curl_options + $curl_options);
     $this->drupalSetContent(curl_exec($this->ch), curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL));
     $this->assertTrue($this->_content !== FALSE, t('!method to !url, response is !length bytes.', array('!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'), '!url' => $url, '!length' => strlen($this->_content))), t('Browser'));
@@ -922,8 +937,10 @@ class DrupalWebTestCase {
    *   Value of the submit button.
    * @param $options
    *   Options to be forwarded to url().
+   * @param $curl_restart
+   *   Restart the cURL session.
    */
-  function drupalPost($path, $edit, $submit, $options = array()) {
+  function drupalPost($path, $edit, $submit, $options = array(), $curl_restart = FALSE) {
     $submit_matches = FALSE;
     if (isset($path)) {
       $html = $this->drupalGet($path, $options);
@@ -960,7 +977,7 @@ class DrupalWebTestCase {
             }
             $post = implode('&', $post);
           }
-          $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HEADER => FALSE));
+          $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HEADER => FALSE, CURLOPT_NOBODY => FALSE), $curl_restart);
           // Ensure that any changes to variables in the other thread are picked up.
           $this->refreshVariables();
 
Index: user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.17
diff -u -p -r1.17 user.test
--- user/user.test	10 Oct 2008 07:49:49 -0000	1.17
+++ user/user.test	16 Oct 2008 22:40:30 -0000
@@ -83,12 +83,12 @@ class UserRegistrationTestCase extends D
     // Logout of user account.
     $this->clickLink(t('Log out'));
     $this->assertNoText($user->name, t('Logged out.'));
+    
+    // Add the raw password so that we can log in as this user.
+    $user->pass_raw = $new_pass;
 
     // Login user.
-    $edit = array();
-    $edit['name'] = $user->name;
-    $edit['pass'] = $new_pass;
-    $this->drupalPost('user', $edit, t('Log in'));
+    $this->drupalLogin($user);
     $this->assertText(t('Log out'), t('Logged in.'));
 
     $this->assertText($user->name, t('[logged in] Username found.'));
@@ -99,6 +99,14 @@ class UserRegistrationTestCase extends D
     $this->assertText($user->name, t('[user auth] Not login page.'));
     $this->assertText(t('View'), t('[user auth] Found view tab on the profile page.'));
     $this->assertText(t('Edit'), t('[user auth] Found edit tab on the profile page.'));
+
+    // Logout of user account.
+    $this->clickLink(t('Log out'));
+    $this->assertNoText($user->name, t('Logged out.'));
+
+    // Login user without cookies.
+    $this->drupalLogin($user, TRUE);
+    $this->assertText(t('Log out'), t('Logged in.'));
   }
 }
 
