-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from BitBagCommerce/release/20230629
Release 20230629
- Loading branch information
Showing
20 changed files
with
345 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@resetting_password | ||
Feature: Resetting one customer password | ||
In order to reset my password | ||
As a Customer | ||
I need to be able to reset it by reset query | ||
|
||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store has locale "en_US" | ||
And there is a customer account "[email protected]" | ||
|
||
@graphql | ||
Scenario: Setting token for password reset | ||
Given I prepare password reset request operation for user "[email protected]" | ||
And I send that GraphQL request | ||
Then I should receive a JSON response | ||
And This response should contain pattern '/^\{"data":\{"shop_send_reset_password_emailCustomer":\{"customer":\{"id":"\/api\/v2\/shop\/customers\/(\d+)"\}\}\}\}$/' | ||
And user "[email protected]" should have reset password token set | ||
|
||
@graphql | ||
Scenario: Checking for valid reset password token availability | ||
Given I prepare password reset request operation for user "[email protected]" | ||
And I send that GraphQL request | ||
And I prepare check reset password token operation for user's "[email protected]" token | ||
And I send that GraphQL request | ||
Then I should receive a JSON response | ||
And This response should contain pattern '/^\{"data":\{"password_reset_tokenUser":\{"username":"([^"]+)"\}\}\}$/' | ||
|
||
@graphql | ||
Scenario: Checking for invalid reset password token availability | ||
Given I prepare password reset request operation for user "[email protected]" | ||
And I send that GraphQL request | ||
And I prepare check reset password token operation for invalid token | ||
And I send that GraphQL request | ||
Then I should receive a JSON response | ||
And This response should contain pattern '/"data":\{"password_reset_tokenUser":null\}/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file has been created by developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* You can find more information about us on https://bitbag.io and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20230612094617 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Create refresh token table'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('CREATE TABLE IF NOT EXISTS bitbag_refresh_token (id INT AUTO_INCREMENT NOT NULL, refresh_token VARCHAR(128) NOT NULL, username VARCHAR(255) NOT NULL, valid DATETIME NOT NULL, remember_me TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_CD7BD0E9C74F2195 (refresh_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('DROP TABLE bitbag_refresh_token'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file has been created by developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* You can find more information about us on https://bitbag.io and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20230612095046 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add index to sylius_product_attribute_value table on `locale_code`'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('CREATE INDEX locale_code ON sylius_product_attribute_value (locale_code)'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('DROP INDEX locale_code ON sylius_product_attribute_value'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
/* | ||
* This file has been created by developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* You can find more information about us on https://bitbag.io and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
|
||
namespace spec\BitBag\SyliusVueStorefront2Plugin\Resolver\Query; | ||
|
||
use BitBag\SyliusVueStorefront2Plugin\Resolver\Query\PasswordResetTokenResolver; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\ShopUserInterface; | ||
use Sylius\Component\User\Repository\UserRepositoryInterface; | ||
|
||
class PasswordResetTokenResolverSpec extends ObjectBehavior | ||
{ | ||
public function let( | ||
UserRepositoryInterface $userRepository | ||
): void { | ||
$this->beConstructedWith( | ||
$userRepository | ||
); | ||
} | ||
|
||
public function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(PasswordResetTokenResolver::class); | ||
} | ||
|
||
public function it_returns_user_on_valid_token( | ||
UserRepositoryInterface $userRepository, | ||
ShopUserInterface $user | ||
): void { | ||
$context = [ | ||
'args' => [ | ||
'passwordResetToken' => "TOKEN", | ||
], | ||
]; | ||
|
||
$token = $context['args']['passwordResetToken']; | ||
|
||
$userRepository->findOneBy(['passwordResetToken' => $token])->willReturn($user); | ||
|
||
$this->__invoke(null, $context)->shouldReturn($user); | ||
} | ||
|
||
public function it_should_return_null_on_invalid_token( | ||
UserRepositoryInterface $userRepository, | ||
): void { | ||
$context = [ | ||
'args' => [ | ||
'passwordResetToken' => "TOKEN", | ||
], | ||
]; | ||
|
||
$token = $context['args']['passwordResetToken']; | ||
|
||
$userRepository->findOneBy(['passwordResetToken' => $token])->willReturn(null); | ||
|
||
$this->shouldThrow(\RuntimeException::class) | ||
->during('__invoke', [null, $context]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file has been created by developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* You can find more information about us on https://bitbag.io and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusVueStorefront2Plugin\Resolver\Query; | ||
|
||
use ApiPlatform\GraphQl\Resolver\QueryItemResolverInterface; | ||
use Sylius\Component\Core\Model\ShopUserInterface; | ||
use Sylius\Component\User\Repository\UserRepositoryInterface; | ||
|
||
class PasswordResetTokenResolver implements QueryItemResolverInterface | ||
{ | ||
private UserRepositoryInterface $userRepository; | ||
|
||
public function __construct(UserRepositoryInterface $userRepository) | ||
{ | ||
$this->userRepository = $userRepository; | ||
} | ||
|
||
public function __invoke($item, array $context): ShopUserInterface | ||
{ | ||
$token = $context['args']['passwordResetToken']; | ||
/** @var ?ShopUserInterface $user */ | ||
$user = $this->userRepository->findOneBy(['passwordResetToken' => $token]); | ||
|
||
if (null !== $user) { | ||
return $user; | ||
} | ||
|
||
throw new \RuntimeException('Token not found'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.