Skip to content

Commit 71ed28e

Browse files
author
Prabhu Ram
committed
Merge remote-tracking branch 'sudheer/30179-graphql-resetPassword-error' into 2.4-develop
2 parents d31cd74 + cff5e3a commit 71ed28e

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

app/code/Magento/CustomerGraphQl/Model/Resolver/ResetPassword.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function resolve(
118118
$args['newPassword']
119119
);
120120
} catch (LocalizedException $e) {
121-
throw new GraphQlInputException(__('Cannot set the customer\'s password'), $e);
121+
throw new GraphQlInputException(__($e->getMessage()), $e);
122122
}
123123
}
124124
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/ResetPasswordTest.php

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function testResetPasswordTokenEmptyValue()
156156
public function testResetPasswordTokenMismatched()
157157
{
158158
$this->expectException(\Exception::class);
159-
$this->expectExceptionMessage('Cannot set the customer\'s password');
159+
$this->expectExceptionMessage('The password token is mismatched. Reset and try again');
160160
$query = <<<QUERY
161161
mutation {
162162
resetPassword (
@@ -192,6 +192,52 @@ public function testNewPasswordEmptyValue()
192192
$this->graphQlMutation($query);
193193
}
194194

195+
/**
196+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
197+
*
198+
* @throws NoSuchEntityException
199+
* @throws Exception
200+
* @throws LocalizedException
201+
*/
202+
public function testNewPasswordCheckMinLength()
203+
{
204+
$this->expectException(\Exception::class);
205+
$this->expectExceptionMessage('The password needs at least 8 characters. Create a new password and try again');
206+
$query = <<<QUERY
207+
mutation {
208+
resetPassword (
209+
email: "{$this->getCustomerEmail()}"
210+
resetPasswordToken: "{$this->getResetPasswordToken()}"
211+
newPassword: "new_"
212+
)
213+
}
214+
QUERY;
215+
$this->graphQlMutation($query);
216+
}
217+
218+
/**
219+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
220+
*
221+
* @throws NoSuchEntityException
222+
* @throws Exception
223+
* @throws LocalizedException
224+
*/
225+
public function testNewPasswordCheckCharactersStrength()
226+
{
227+
$this->expectException(\Exception::class);
228+
$this->expectExceptionMessage('Minimum of different classes of characters in password is 3. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.');
229+
$query = <<<QUERY
230+
mutation {
231+
resetPassword (
232+
email: "{$this->getCustomerEmail()}"
233+
resetPasswordToken: "{$this->getResetPasswordToken()}"
234+
newPassword: "new_password"
235+
)
236+
}
237+
QUERY;
238+
$this->graphQlMutation($query);
239+
}
240+
195241
/**
196242
* Check password reset for lock customer
197243
*

0 commit comments

Comments
 (0)