-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 #1654 from magento-engcom/develop-prs
[EngCom] Public Pull Requests - develop - MAGETWO-83154: [2.3-develop] Order grid - Sort by Purchase Date Desc by default #11931 - MAGETWO-83101: [Backport 2.3-develop] #8236 FIX CMS blocks #11805 - MAGETWO-83092: Remove unneeded, also mistyped, saveHandler from CatalogSearch indexer declaration #11626 - MAGETWO-83091: Remove "Undefined fields" from under lib folder #11662 - MAGETWO-83083: 10195: Order relation child is not set during edit operation #11909 - MAGETWO-82998: [2.3-develop] X-Magento-Tags header containing whitespaces causes exception #11849 - MAGETWO-82633: #11409: Too many password reset requests even when disabled in settings #11434
- Loading branch information
Showing
41 changed files
with
339 additions
and
100 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,11 @@ | |
|
||
namespace Magento\Security\Test\Unit\Model\Plugin; | ||
|
||
use Magento\Customer\Model\AccountManagement; | ||
use Magento\Framework\App\Area; | ||
use Magento\Framework\Config\ScopeInterface; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Magento\Security\Model\PasswordResetRequestEvent; | ||
|
||
/** | ||
* Test class for \Magento\Security\Model\Plugin\AccountManagement testing | ||
|
@@ -19,20 +23,25 @@ class AccountManagementTest extends \PHPUnit\Framework\TestCase | |
protected $model; | ||
|
||
/** | ||
* @var \Magento\Framework\App\RequestInterface | ||
* @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $request; | ||
|
||
/** | ||
* @var \Magento\Security\Model\SecurityManager | ||
* @var \Magento\Security\Model\SecurityManager|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $securityManager; | ||
|
||
/** | ||
* @var \Magento\Customer\Model\AccountManagement | ||
* @var AccountManagement|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $accountManagement; | ||
|
||
/** | ||
* @var ScopeInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $scope; | ||
|
||
/** | ||
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager | ||
*/ | ||
|
@@ -53,28 +62,38 @@ public function setUp() | |
['performSecurityCheck'] | ||
); | ||
|
||
$this->accountManagement = $this->createMock(\Magento\Customer\Model\AccountManagement::class); | ||
$this->accountManagement = $this->createMock(AccountManagement::class); | ||
$this->scope = $this->createMock(ScopeInterface::class); | ||
} | ||
|
||
/** | ||
* @param $area | ||
* @param $passwordRequestEvent | ||
* @param $expectedTimes | ||
* @dataProvider beforeInitiatePasswordResetDataProvider | ||
*/ | ||
public function testBeforeInitiatePasswordReset($area, $passwordRequestEvent, $expectedTimes) | ||
{ | ||
$email = '[email protected]'; | ||
$template = AccountManagement::EMAIL_RESET; | ||
|
||
$this->model = $this->objectManager->getObject( | ||
\Magento\Security\Model\Plugin\AccountManagement::class, | ||
[ | ||
'passwordRequestEvent' => $passwordRequestEvent, | ||
'request' => $this->request, | ||
'securityManager' => $this->securityManager | ||
'securityManager' => $this->securityManager, | ||
'scope' => $this->scope | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testBeforeInitiatePasswordReset() | ||
{ | ||
$email = '[email protected]'; | ||
$template = \Magento\Customer\Model\AccountManagement::EMAIL_RESET; | ||
$this->scope->expects($this->once()) | ||
->method('getCurrentScope') | ||
->willReturn($area); | ||
|
||
$this->securityManager->expects($this->once()) | ||
$this->securityManager->expects($this->exactly($expectedTimes)) | ||
->method('performSecurityCheck') | ||
->with(\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, $email) | ||
->with($passwordRequestEvent, $email) | ||
->willReturnSelf(); | ||
|
||
$this->model->beforeInitiatePasswordReset( | ||
|
@@ -83,4 +102,18 @@ public function testBeforeInitiatePasswordReset() | |
$template | ||
); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function beforeInitiatePasswordResetDataProvider() | ||
{ | ||
return [ | ||
[Area::AREA_ADMINHTML, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 0], | ||
[Area::AREA_ADMINHTML, PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, 1], | ||
[Area::AREA_FRONTEND, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 1], | ||
// This should never happen, but let's cover it with tests | ||
[Area::AREA_FRONTEND, PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, 1], | ||
]; | ||
} | ||
} |
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.