Skip to content

Commit

Permalink
Merge remote-tracking branch 'sudheer/30179-graphql-resetPassword-err…
Browse files Browse the repository at this point in the history
…or' into 2.4-develop
  • Loading branch information
prabhuram93 committed Oct 8, 2020
2 parents d31cd74 + cff5e3a commit 71ed28e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function resolve(
$args['newPassword']
);
} catch (LocalizedException $e) {
throw new GraphQlInputException(__('Cannot set the customer\'s password'), $e);
throw new GraphQlInputException(__($e->getMessage()), $e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function testResetPasswordTokenEmptyValue()
public function testResetPasswordTokenMismatched()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Cannot set the customer\'s password');
$this->expectExceptionMessage('The password token is mismatched. Reset and try again');
$query = <<<QUERY
mutation {
resetPassword (
Expand Down Expand Up @@ -192,6 +192,52 @@ public function testNewPasswordEmptyValue()
$this->graphQlMutation($query);
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
*
* @throws NoSuchEntityException
* @throws Exception
* @throws LocalizedException
*/
public function testNewPasswordCheckMinLength()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('The password needs at least 8 characters. Create a new password and try again');
$query = <<<QUERY
mutation {
resetPassword (
email: "{$this->getCustomerEmail()}"
resetPasswordToken: "{$this->getResetPasswordToken()}"
newPassword: "new_"
)
}
QUERY;
$this->graphQlMutation($query);
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
*
* @throws NoSuchEntityException
* @throws Exception
* @throws LocalizedException
*/
public function testNewPasswordCheckCharactersStrength()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Minimum of different classes of characters in password is 3. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.');
$query = <<<QUERY
mutation {
resetPassword (
email: "{$this->getCustomerEmail()}"
resetPasswordToken: "{$this->getResetPasswordToken()}"
newPassword: "new_password"
)
}
QUERY;
$this->graphQlMutation($query);
}

/**
* Check password reset for lock customer
*
Expand Down

0 comments on commit 71ed28e

Please sign in to comment.