1 user_password_reset.test | public UserPasswordResetTest::testUserPasswordResetExpired() |
Attempts login using an expired password reset link.
File
- core/
modules/ user/ tests/ user_password_reset.test, line 137 - Tests for resetting the password.
Class
Code
public function testUserPasswordResetExpired() {
// Set password reset timeout variable to 43200 seconds = 12 hours.
$timeout = 43200;
config_set('system.core', 'user_password_reset_timeout', $timeout);
// Create a user.
$account = $this->backdropCreateUser();
$this->backdropLogin($account);
// Load real user object.
$account = user_load($account->uid, TRUE);
$this->backdropLogout();
// To attempt an expired password reset, create a password reset link as if
// its request time was 60 seconds older than the allowed limit of timeout.
$bogus_timestamp = REQUEST_TIME - config_get('system.core', 'user_password_reset_timeout') - 60;
$this->backdropGet("user/reset/$account->uid/$bogus_timestamp/" . user_pass_rehash($account->pass, $bogus_timestamp, $account->login, $account->uid, $account->mail));
$this->assertText(t('You have tried to use a reset password link that has expired. Please request a new one using the form below.'), 'Expired password reset request rejected.');
}