Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.39
diff -u -r1.39 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	14 Sep 2008 06:46:34 -0000	1.39
+++ modules/simpletest/drupal_web_test_case.php	16 Sep 2008 03:23:30 -0000
@@ -779,19 +779,27 @@
    * 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;
       }
@@ -810,12 +818,17 @@
    *
    * @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'));
@@ -909,8 +922,10 @@
    *   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);
@@ -947,7 +962,7 @@
             }
             $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();
           return $out;
Index: modules/user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.13
diff -u -r1.13 user.test
--- modules/user/user.test	15 Sep 2008 20:48:10 -0000	1.13
+++ modules/user/user.test	16 Sep 2008 03:23:31 -0000
@@ -99,6 +99,17 @@
     $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
+    $edit = array();
+    $edit['name'] = $user->name;
+    $edit['pass'] = $new_pass;
+    $this->drupalPost('user', $edit, t('Log in'), array(), TRUE);
+    $this->assertText(t('Log out'), t('Logged in.'));
   }
 }
 
