@@ -20,10 +20,11 @@ class ResetPasswordTest extends \Magento\TestFramework\TestCase\AbstractBackendC
20
20
protected $ baseControllerUrl = 'http://localhost/index.php/backend/customer/index/ ' ;
21
21
22
22
/**
23
- * Checks reset password functionality with default settings and customer reset request event.
23
+ * Checks reset password functionality with no restrictive settings and customer reset request event.
24
+ * Admin is not affected by this security check, so reset password email must be sent.
24
25
*
25
- * @magentoConfigFixture current_store admin/security /limit_password_reset_requests_method 1
26
- * @magentoConfigFixture current_store admin/security /min_time_between_password_reset_requests 10
26
+ * @magentoConfigFixture current_store customer/password /limit_password_reset_requests_method 0
27
+ * @magentoConfigFixture current_store customer/password /min_time_between_password_reset_requests 0
27
28
* @magentoDataFixture Magento/Customer/_files/customer.php
28
29
*/
29
30
public function testResetPasswordSuccess ()
@@ -40,11 +41,57 @@ public function testResetPasswordSuccess()
40
41
$ this ->assertRedirect ($ this ->stringStartsWith ($ this ->baseControllerUrl . 'edit ' ));
41
42
}
42
43
44
+ /**
45
+ * Checks reset password functionality with default restrictive min time between
46
+ * password reset requests and customer reset request event.
47
+ * Admin is not affected by this security check, so reset password email must be sent.
48
+ *
49
+ * @magentoConfigFixture current_store customer/password/max_number_password_reset_requests 0
50
+ * @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 10
51
+ * @magentoDataFixture Magento/Customer/_files/customer.php
52
+ */
53
+ public function testResetPasswordMinTimeError ()
54
+ {
55
+ $ this ->passwordResetRequestEventCreate (
56
+ \Magento \Security \Model \PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
57
+ );
58
+ $ this ->getRequest ()->setPostValue (['customer_id ' => '1 ' ]);
59
+ $ this ->dispatch ('backend/customer/index/resetPassword ' );
60
+ $ this ->assertSessionMessages (
61
+ $ this ->equalTo (['The customer will receive an email with a link to reset password. ' ]),
62
+ \Magento \Framework \Message \MessageInterface::TYPE_SUCCESS
63
+ );
64
+ $ this ->assertRedirect ($ this ->stringStartsWith ($ this ->baseControllerUrl . 'edit ' ));
65
+ }
66
+
67
+ /**
68
+ * Checks reset password functionality with default restrictive limited number
69
+ * password reset requests and customer reset request event.
70
+ * Admin is not affected by this security check, so reset password email must be sent.
71
+ *
72
+ * @magentoConfigFixture current_store customer/password/max_number_password_reset_requests 1
73
+ * @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 0
74
+ * @magentoDataFixture Magento/Customer/_files/customer.php
75
+ */
76
+ public function testResetPasswordLimitError ()
77
+ {
78
+ $ this ->passwordResetRequestEventCreate (
79
+ \Magento \Security \Model \PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
80
+ );
81
+ $ this ->getRequest ()->setPostValue (['customer_id ' => '1 ' ]);
82
+ $ this ->dispatch ('backend/customer/index/resetPassword ' );
83
+ $ this ->assertSessionMessages (
84
+ $ this ->equalTo (['The customer will receive an email with a link to reset password. ' ]),
85
+ \Magento \Framework \Message \MessageInterface::TYPE_SUCCESS
86
+ );
87
+ $ this ->assertRedirect ($ this ->stringStartsWith ($ this ->baseControllerUrl . 'edit ' ));
88
+ }
89
+
43
90
/**
44
91
* Checks reset password functionality with default settings, customer and admin reset request events.
45
92
*
46
- * @magentoConfigFixture current_store admin/security /limit_password_reset_requests_method 1
47
- * @magentoConfigFixture current_store admin/security /min_time_between_password_reset_requests 10
93
+ * @magentoConfigFixture current_store customer/password /limit_password_reset_requests_method 1
94
+ * @magentoConfigFixture current_store customer/password /min_time_between_password_reset_requests 10
48
95
* @magentoConfigFixture current_store contact/email/recipient_email [email protected]
49
96
* @magentoDataFixture Magento/Customer/_files/customer.php
50
97
*/
@@ -59,10 +106,8 @@ public function testResetPasswordWithSecurityViolationException()
59
106
$ this ->getRequest ()->setPostValue (['customer_id ' => '1 ' ]);
60
107
$ this ->dispatch ('backend/customer/index/resetPassword ' );
61
108
$ this ->assertSessionMessages (
62
- $ this ->equalTo (
63
- [
'Too many password reset requests. Please wait and try again or contact [email protected] . ' ]
64
- ),
65
- \Magento \Framework \Message \MessageInterface::TYPE_ERROR
109
+ $ this ->equalTo (['The customer will receive an email with a link to reset password. ' ]),
110
+ \Magento \Framework \Message \MessageInterface::TYPE_SUCCESS
66
111
);
67
112
$ this ->assertRedirect ($ this ->stringStartsWith ($ this ->baseControllerUrl . 'edit ' ));
68
113
}
0 commit comments