Skip to content

Commit 8941867

Browse files
committed
ACP2E-3992: Customer password reset through GraphQL doesn't honour the restrictions
1 parent 496a520 commit 8941867

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

app/code/Magento/Security/Test/Unit/Model/Plugin/AccountManagementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ public static function beforeInitiatePasswordResetDataProvider()
117117
[Area::AREA_ADMINHTML, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 0],
118118
[Area::AREA_ADMINHTML, PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, 1],
119119
[Area::AREA_FRONTEND, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 1],
120+
[Area::AREA_GRAPHQL, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 1],
120121
// This should never happen, but let's cover it with tests
121122
[Area::AREA_FRONTEND, PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, 1],
122123
[Area::AREA_WEBAPI_REST, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 1],
123-
[Area::AREA_GRAPHQL, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 1],
124124
];
125125
}
126126
}

dev/tests/integration/framework/Magento/TestFramework/ApplicationStateComparator/_files/state-skip-list.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@
290290
Magento\Framework\Cache\LockGuardedCacheLoader::class => null,
291291
Magento\Framework\View\Asset\PreProcessor\Pool::class => null,
292292
Magento\Framework\App\Area::class => null,
293+
Magento\Security\Model\ResourceModel\PasswordResetRequestEvent::class => null,
293294
Magento\Store\Model\Store\Interceptor::class => null,
294295
Magento\Framework\TestFramework\ApplicationStateComparator\Comparator::class => null, // Yes, our test uses mutable state itself :-)
295296
Magento\Framework\GraphQl\Query\QueryParser::class => null, // reloads as a ReloadProcessor

dev/tests/integration/testsuite/Magento/GraphQl/App/GraphQlCustomerMutationsTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\App\Area;
1313
use Magento\Framework\App\State;
1414
use Magento\Framework\Exception\SecurityViolationException;
15+
use Magento\Security\Model\ResourceModel\PasswordResetRequestEvent\Collection as PasswordResetRequestEventCollection;
1516
use Magento\Customer\Api\CustomerRepositoryInterface;
1617
use Magento\Framework\Exception\NoSuchEntityException;
1718
use Magento\Framework\Registry;
@@ -21,7 +22,7 @@
2122
* Tests the dispatch method in the GraphQl Controller class using a simple product query
2223
*
2324
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
24-
* @magentoDbIsolation enabled
25+
* @magentoDbIsolation disabled
2526
* @magentoAppIsolation enabled
2627
* @magentoAppArea graphql
2728
*/
@@ -50,6 +51,9 @@ protected function setUp(): void
5051
*/
5152
protected function tearDown(): void
5253
{
54+
$this->graphQlStateDiff->getTestObjectManager()
55+
->create(PasswordResetRequestEventCollection::class)
56+
->deleteRecordsOlderThen(time() + 1);
5357
$this->graphQlStateDiff->tearDown();
5458
$this->graphQlStateDiff = null;
5559
parent::tearDown();

dev/tests/integration/testsuite/Magento/GraphQl/App/State/GraphQlStateDiff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2023 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -153,7 +153,7 @@ public function testState(
153153
} elseif ($operationName==='applyCouponToCart') {
154154
$this->removeCouponFromCart($variables);
155155
} elseif ($operationName==='resetPassword') {
156-
$variables2['resetPasswordToken'] = $this->getResetPasswordToken($variables['email']);
156+
$variables2['resetPasswordToken'] = $variables['resetPasswordToken'];
157157
$variables2['email'] = $variables['email'];
158158
$variables2['newPassword'] = $variables['newPassword'];
159159
}

0 commit comments

Comments
 (0)