? 20080812.session_login_without_cookie.patch
? 20080920.session_login_without_cookie.patch
? 20081016_drupalpost_cookie.patch
? simpletest-302075-20.patch
? simpletest-clearcookies.patch
? simpletest-clearcookies_0.patch
? simpletest-clearcookies_1.patch
? 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.67
diff -u -p -r1.67 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	3 Dec 2008 16:32:22 -0000	1.67
+++ modules/simpletest/drupal_web_test_case.php	5 Dec 2008 22:35:47 -0000
@@ -719,11 +719,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.
    */
-  protected function drupalLogin($user = NULL) {
+  protected function drupalLogin($user = NULL, $curl_restart = FALSE) {
     if ($this->isLoggedIn) {
       $this->drupalLogout();
     }
@@ -736,7 +738,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(), 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'));
@@ -891,9 +893,15 @@ class DrupalWebTestCase {
    * This function will add authentication headers as specified in the
    * 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 curlInitialize() {
+  protected function curlInitialize($curl_restart = FALSE) {
     global $base_url, $db_prefix;
+    if ($curl_restart) {
+      $this->curlClose();
+    }
     if (!isset($this->curlHandle)) {
       $this->curlHandle = curl_init();
       $curl_options = $this->additionalCurlOptions + array(
@@ -905,6 +913,9 @@ class DrupalWebTestCase {
         CURLOPT_SSL_VERIFYHOST => FALSE,  // Required to make the tests run on https://
         CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'),
       );
+      if (!$curl_restart) {
+        $curl_options[CURLOPT_COOKIEJAR] = $this->cookie_file;
+      }
       if (preg_match('/simpletest\d+/', $db_prefix, $matches)) {
         $curl_options[CURLOPT_USERAGENT] = $matches[0];
       }
@@ -923,12 +934,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->curlInitialize();
+  protected function curlExec($curl_options, $curl_restart = FALSE) {
+    $this->curlInitialize($curl_restart);
     $url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL];
+    if ($curl_restart) {
+      $curl_options[CURLOPT_COOKIEJAR] = $this->cookie_file;
+    }
     curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
     $this->headers = array();
     $this->drupalSetContent(curl_exec($this->curlHandle), curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL));
@@ -1057,8 +1073,10 @@ class DrupalWebTestCase {
    * @param $headers
    *   An array containing additional HTTP request headers, each formatted as
    *   "name: value".
+   * @param $curl_restart
+   *   Restart the cURL session.
    */
-  protected function drupalPost($path, $edit, $submit, Array $options = array(), Array $headers = array()) {
+  protected function drupalPost($path, $edit, $submit, Array $options = array(), Array $headers = array(), $curl_restart = FALSE) {
     $submit_matches = FALSE;
     if (isset($path)) {
       $html = $this->drupalGet($path, $options);
@@ -1098,7 +1116,7 @@ class DrupalWebTestCase {
             }
             $post = implode('&', $post);
           }
-          $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HTTPHEADER => $headers));
+          $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HTTPHEADER => $headers), $curl_restart);
           // Ensure that any changes to variables in the other thread are picked up.
           $this->refreshVariables();
 
Index: modules/user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.22
diff -u -p -r1.22 user.test
--- modules/user/user.test	25 Nov 2008 13:14:29 -0000	1.22
+++ modules/user/user.test	5 Dec 2008 22:35:47 -0000
@@ -80,12 +80,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.'));
@@ -96,6 +96,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.'));
   }
 }
 
