Skip to content

Commit 3fc2286

Browse files
author
Oleksandr Karpenko
committed
MAGETWO-52338: Csrf delete the customer addresses
1 parent 7d9c73d commit 3fc2286

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
*/
66
namespace Magento\Customer\Controller;
77

8+
use Magento\Customer\Api\AccountManagementInterface;
9+
use Magento\Framework\Data\Form\FormKey;
810
use Magento\TestFramework\Helper\Bootstrap;
911

1012
class AddressTest extends \Magento\TestFramework\TestCase\AbstractController
1113
{
12-
/** @var \Magento\Customer\Api\AccountManagementInterface */
14+
/** @var AccountManagementInterface */
1315
private $accountManagement;
1416

17+
/** @var FormKey */
18+
private $formKey;
19+
1520
protected function setUp()
1621
{
1722
parent::setUp();
@@ -20,9 +25,8 @@ protected function setUp()
2025
'Magento\Customer\Model\Session',
2126
[$logger]
2227
);
23-
$this->accountManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
24-
'Magento\Customer\Api\AccountManagementInterface'
25-
);
28+
$this->accountManagement = Bootstrap::getObjectManager()->create(AccountManagementInterface::class);
29+
$this->formKey = Bootstrap::getObjectManager()->create(FormKey::class);
2630
$customer = $this->accountManagement->authenticate('customer@example.com', 'password');
2731
$session->setCustomerDataAsLoggedIn($customer);
2832
}
@@ -152,6 +156,7 @@ public function testFailedFormPostAction()
152156
public function testDeleteAction()
153157
{
154158
$this->getRequest()->setParam('id', 1);
159+
$this->getRequest()->setParam('form_key', $this->formKey->getFormKey());
155160
// we are overwriting the address coming from the fixture
156161
$this->dispatch('customer/address/delete');
157162

@@ -169,6 +174,7 @@ public function testDeleteAction()
169174
public function testWrongAddressDeleteAction()
170175
{
171176
$this->getRequest()->setParam('id', 555);
177+
$this->getRequest()->setParam('form_key', $this->formKey->getFormKey());
172178
// we are overwriting the address coming from the fixture
173179
$this->dispatch('customer/address/delete');
174180

0 commit comments

Comments
 (0)