Skip to content

Commit b9aa7cc

Browse files
authored
ENGCOM-4611: magento/graphql-ce#: Add missed rollback #495
2 parents 419106a + 035481d commit b9aa7cc

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Integration\Model\Oauth\Token\RequestThrottler;
8+
9+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
10+
11+
/** @var \Magento\Framework\Registry $registry */
12+
$registry = $objectManager->get(\Magento\Framework\Registry::class);
13+
$registry->unregister('isSecureArea');
14+
$registry->register('isSecureArea', true);
15+
16+
$customersToRemove = [
17+
'customer@search.example.com',
18+
'customer2@search.example.com',
19+
'customer3@search.example.com',
20+
];
21+
22+
/**
23+
* @var Magento\Customer\Api\CustomerRepositoryInterface
24+
*/
25+
$customerRepository = $objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class);
26+
/**
27+
* @var RequestThrottler $throttler
28+
*/
29+
$throttler = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(RequestThrottler::class);
30+
foreach ($customersToRemove as $customerEmail) {
31+
try {
32+
$customer = $customerRepository->get($customerEmail);
33+
$customerRepository->delete($customer);
34+
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
35+
// not found
36+
}
37+
38+
/* Unlock account if it was locked for tokens retrieval */
39+
$throttler->resetAuthenticationFailuresCount($customerEmail, RequestThrottler::USER_TYPE_CUSTOMER);
40+
}
41+
42+
$registry->unregister('isSecureArea');
43+
$registry->register('isSecureArea', false);

0 commit comments

Comments
 (0)