aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2014-02-17 16:14:37 +0100
committerMarc Alexander <admin@m-a-styles.de>2014-02-17 16:18:56 +0100
commit3cb702f4ab66f21b267d51f2402a9bd5ef7f97e1 (patch)
treed9c810d79f5e9aacd56483cf3e511a5f8194e44e
parent4c62cb4989fbf8d2fa9f5d60839311ea5b4c5f68 (diff)
downloadforums-3cb702f4ab66f21b267d51f2402a9bd5ef7f97e1.tar
forums-3cb702f4ab66f21b267d51f2402a9bd5ef7f97e1.tar.gz
forums-3cb702f4ab66f21b267d51f2402a9bd5ef7f97e1.tar.bz2
forums-3cb702f4ab66f21b267d51f2402a9bd5ef7f97e1.tar.xz
forums-3cb702f4ab66f21b267d51f2402a9bd5ef7f97e1.zip
[ticket/12183] Test activating new password after reset
PHPBB3-12183
-rw-r--r--tests/functional/user_password_reset_test.php66
1 files changed, 65 insertions, 1 deletions
diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php
index 4e151202b1..9548b70eeb 100644
--- a/tests/functional/user_password_reset_test.php
+++ b/tests/functional/user_password_reset_test.php
@@ -12,10 +12,12 @@
*/
class phpbb_functional_user_password_reset_test extends phpbb_functional_test_case
{
+ protected $user_data;
+
public function test_password_reset()
{
$this->add_lang('ucp');
- $this->create_user('reset-password-test-user');
+ $user_id = $this->create_user('reset-password-test-user');
$crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
$form = $crawler->selectButton('submit')->form(array(
@@ -31,5 +33,67 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
));
$crawler = self::submit($form);
$this->assertContainsLang('PASSWORD_UPDATED', $crawler->text());
+
+ // Make sure we know the password
+ $db = $this->get_db();
+ $this->passwords_manager = $this->get_passwords_manager();
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_newpasswd = '" . $db->sql_escape($this->passwords_manager->hash('reset-password-test-user')) . "'
+ WHERE user_id = " . $user_id;
+ $db->sql_query($sql);
+ }
+
+ public function test_login_after_reset()
+ {
+ $this->get_user_data();
+ $this->assertNotNull($this->user_data['user_actkey']);
+ $this->assertNotNull($this->user_data['user_newpasswd']);
+ $this->login('reset-password-test-user');
+ }
+
+ public function data_activate_new_password()
+ {
+ return array(
+ array('WRONG_ACTIVATION', false, 'FOOBAR', false),
+ array('ALREADY_ACTIVATED', 2, 'FOOBAR', false),
+ array('PASSWORD_ACTIVATED', false, false, true),
+ array('ALREADY_ACTIVATED', false, false, false),
+ );
+ }
+
+ /**
+ * @dataProvider data_activate_new_password
+ */
+ public function test_activate_new_password($expected, $user_id, $act_key, $login_with_newpasswd)
+ {
+ $this->add_lang('ucp');
+ $this->get_user_data();
+ $user_id = (!$user_id) ? $this->user_data['user_id'] : $user_id;
+ $act_key = (!$act_key) ? $this->user_data['user_actkey'] : $act_key;
+
+ $crawler = self::request('GET', "ucp.php?mode=activate&u=$user_id&k=$act_key&sid={$this->sid}");
+ $this->assertContainsLang($expected, $crawler->text());
+
+ // Can't use login method here
+ if ($login_with_newpasswd)
+ {
+ $crawler = self::request('GET', 'ucp.php');
+ $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
+
+ $form = $crawler->selectButton($this->lang('LOGIN'))->form();
+ $crawler = self::submit($form, array('username' => 'reset-password-test-user', 'password' => 'reset-password-test-user'));
+ $this->assertNotContains($this->lang('LOGIN'), $crawler->filter('.navbar')->text());
+ }
+ }
+
+ protected function get_user_data()
+ {
+ $db = $this->get_db();
+ $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
+ FROM ' . USERS_TABLE . "
+ WHERE username = 'reset-password-test-user'";
+ $result = $db->sql_query($sql);
+ $this->user_data = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
}
}