summaryrefslogtreecommitdiff
path: root/modules/user/user.test
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-12-18 00:56:18 +0000
committerDries Buytaert <dries@buytaert.net>2010-12-18 00:56:18 +0000
commit57b1af03188120e4e76b8e1304123b724dd25aca (patch)
treed72679b007bd727e5a64db107b797188da00ede0 /modules/user/user.test
parent4b687afc002b0608a730e82d4ad5d605347e55bc (diff)
downloadbrdo-57b1af03188120e4e76b8e1304123b724dd25aca.tar.gz
brdo-57b1af03188120e4e76b8e1304123b724dd25aca.tar.bz2
- Patch #991270 by carlos8f, chx: password_count_log2 var out of bounds is a sorry mess.
Diffstat (limited to 'modules/user/user.test')
-rw-r--r--modules/user/user.test25
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/user/user.test b/modules/user/user.test
index a49a89b5c..d999c85e2 100644
--- a/modules/user/user.test
+++ b/modules/user/user.test
@@ -367,6 +367,31 @@ class UserLoginTestCase extends DrupalWebTestCase {
}
/**
+ * Test that user password is re-hashed upon login after changing $count_log2.
+ */
+ function testPasswordRehashOnLogin() {
+ // Load password hashing API.
+ require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
+ // Set initial $count_log2 to the default, DRUPAL_HASH_COUNT.
+ variable_set('password_count_log2', DRUPAL_HASH_COUNT);
+ // Create a new user and authenticate.
+ $account = $this->drupalCreateUser(array());
+ $password = $account->pass_raw;
+ $this->drupalLogin($account);
+ $this->drupalLogout();
+ // Load the stored user. The password hash should reflect $count_log2.
+ $account = user_load($account->uid);
+ $this->assertIdentical(_password_get_count_log2($account->pass), DRUPAL_HASH_COUNT);
+ // Change $count_log2 and log in again.
+ variable_set('password_count_log2', DRUPAL_HASH_COUNT + 1);
+ $account->pass_raw = $password;
+ $this->drupalLogin($account);
+ // Load the stored user, which should have a different password hash now.
+ $account = user_load($account->uid, TRUE);
+ $this->assertIdentical(_password_get_count_log2($account->pass), DRUPAL_HASH_COUNT + 1);
+ }
+
+ /**
* Make an unsuccessful login attempt.
*
* @param $account