Skip to content

Commit

Permalink
#486 added customer account validation in Quote operations
Browse files Browse the repository at this point in the history
  • Loading branch information
vovsky authored and naydav committed Jun 20, 2019
1 parent bfa0fd4 commit f91224e
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace Magento\GraphQl\Quote\Customer;

use Exception;
use Magento\Customer\Model\CustomerAuthUpdate;
use Magento\Customer\Model\CustomerRegistry;
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\TestFramework\Helper\Bootstrap;
Expand All @@ -28,11 +30,23 @@ class GetCartTest extends GraphQlAbstract
*/
private $customerTokenService;

/**
* @var CustomerAuthUpdate
*/
private $customerAuthUpdate;

/**
* @var CustomerRegistry
*/
private $customerRegistry;

protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
$this->customerRegistry = Bootstrap::getObjectManager()->get(CustomerRegistry::class);
$this->customerAuthUpdate = Bootstrap::getObjectManager()->get(CustomerAuthUpdate::class);
}

/**
Expand Down Expand Up @@ -208,6 +222,29 @@ public function testGetCartWithNotExistingStore()
$this->graphQlQuery($query, [], '', $headerMap);
}

/**
* _security
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*/
public function testGetCartForLockedCustomer()
{
/* lock customer */
$customerSecure = $this->customerRegistry->retrieveSecureData(1);
$customerSecure->setLockExpires('2030-12-31 00:00:00');
$this->customerAuthUpdate->saveAuth(1);

$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
$query = $this->getQuery($maskedQuoteId);

$this->expectExceptionMessage(
"The account is locked"
);
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
}

/**
* @param string $maskedQuoteId
* @return string
Expand Down

0 comments on commit f91224e

Please sign in to comment.