? 20080812.session_login_without_cookie.patch
? simpletest-clearcookies.patch
? modules/simpletest/drupal_web_test_case.php.mod
? modules/simpletest/drupal_web_test_case.php.mod2
? modules/simpletest/tests/session.test.mod
? 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.36
diff -u -p -r1.36 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	30 Aug 2008 09:42:25 -0000	1.36
+++ modules/simpletest/drupal_web_test_case.php	30 Aug 2008 23:49:05 -0000
@@ -743,18 +743,23 @@ class DrupalWebTestCase {
    * simpletest_httpauth_username and simpletest_httpauth_pass variables.
    * Also, see the description of $curl_options among the properties.
    */
-  protected function curlConnect() {
+  protected function curlConnect($clear_cookies = FALSE) {
     global $base_url, $db_prefix;
+    if ($clear_cookies) {
+      $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 (!$clear_cookies) {
+        $curl_options[CURLOPT_COOKIEJAR] = $this->cookie_file;
+      }
       if (preg_match('/simpletest\d+/', $db_prefix)) {
         $curl_options[CURLOPT_USERAGENT] = $db_prefix;
       }
@@ -776,9 +781,12 @@ class DrupalWebTestCase {
    * @return
    *   Content returned from the exec.
    */
-  protected function curlExec($curl_options) {
-    $this->curlConnect();
+  protected function curlExec($curl_options, $clear_cookies = FALSE) {
+    $this->curlConnect($clear_cookies);
     $url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL];
+    if ($clear_cookies) {
+      $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'));
@@ -873,7 +881,7 @@ class DrupalWebTestCase {
    * @param $options
    *   Options to be forwarded to url().
    */
-  function drupalPost($path, $edit, $submit, $options = array()) {
+  function drupalPost($path, $edit, $submit, $options = array(), $clear_cookies = FALSE) {
     $submit_matches = FALSE;
     if (isset($path)) {
       $html = $this->drupalGet($path, $options);
@@ -910,7 +918,7 @@ class DrupalWebTestCase {
             }
             $post = implode('&', $post);
           }
-          $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HEADER => FALSE, CURLOPT_NOBODY => FALSE));
+          $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HEADER => FALSE, CURLOPT_NOBODY => FALSE), $clear_cookies);
           // 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.10
diff -u -p -r1.10 user.test
--- modules/user/user.test	27 Jun 2008 07:25:11 -0000	1.10
+++ modules/user/user.test	30 Aug 2008 23:49:05 -0000
@@ -99,6 +99,17 @@ 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
+    $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.'));
   }
 }
 
