Skip to content

Commit 875db02

Browse files
committed
MAGETWO-58022: Automate MAGETWO-49039 - Password protection for modifying Integration
- Write functional test for MAGETWO-49039
1 parent 3a43a25 commit 875db02

File tree

2 files changed

+163
-0
lines changed

2 files changed

+163
-0
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Security\Test\TestCase;
8+
9+
use Magento\Integration\Test\Fixture\Integration;
10+
use Magento\User\Test\Fixture\User;
11+
use Magento\Integration\Test\Page\Adminhtml\IntegrationIndex;
12+
use Magento\Integration\Test\Page\Adminhtml\IntegrationNew;
13+
use Magento\Mtf\TestCase\Injectable;
14+
use Magento\Backend\Test\Page\AdminAuthLogin;
15+
16+
17+
/**
18+
* Preconditions:
19+
* 1. Create admin user.
20+
* 2. Create integration.
21+
* 3. Configure 'Maximum Login Failures to Lockout Account'.
22+
*
23+
* Steps:
24+
* 1. Log in to backend as admin user.
25+
* 2. Navigate to System > Extensions > Integrations.
26+
* 3. Start to edit existing Integration.
27+
* 4. Fill in all data according to data set (password is incorrect).
28+
* 5. Perform action 4 specified number of times.
29+
* 6. "You have entered an invalid password for current user." appears after each attempt.
30+
* 7. Perform all assertions.
31+
*
32+
* @ZephyrId MAGETWO-49039
33+
*/
34+
class LockAdminUserWhenEditingIntegrationTest extends Injectable
35+
{
36+
/* tags */
37+
const MVP = 'yes';
38+
/* end tags */
39+
40+
/**
41+
* Integration grid page.
42+
*
43+
* @var IntegrationIndex
44+
*/
45+
protected $integrationIndexPage;
46+
47+
/**
48+
* Integration new page.
49+
*
50+
* @var IntegrationNew
51+
*/
52+
protected $integrationNewPage;
53+
54+
/**
55+
* Configuration setting.
56+
*
57+
* @var string
58+
*/
59+
protected $configData;
60+
61+
/**
62+
* @var AdminAuthLogin
63+
*/
64+
protected $adminAuthLogin;
65+
66+
/**
67+
* Preparing pages for test.
68+
*
69+
* @param IntegrationIndex $integrationIndex
70+
* @param IntegrationNew $integrationNew
71+
* @param AdminAuthLogin $adminAuthLogin
72+
* @return void
73+
*/
74+
public function __inject(
75+
IntegrationIndex $integrationIndex,
76+
IntegrationNew $integrationNew,
77+
AdminAuthLogin $adminAuthLogin
78+
) {
79+
$this->integrationIndexPage = $integrationIndex;
80+
$this->integrationNewPage = $integrationNew;
81+
$this->adminAuthLogin = $adminAuthLogin;
82+
}
83+
84+
/**
85+
* Run Lock user when creating new integration test.
86+
*
87+
* @param Integration $initintegration
88+
* @param Integration $integration
89+
* @param int $attempts
90+
* @param User $customAdmin
91+
* @param string $configData
92+
* @return void
93+
*/
94+
public function test(
95+
Integration $initintegration,
96+
Integration $integration,
97+
$attempts,
98+
User $customAdmin,
99+
$configData = null
100+
) {
101+
$this->configData = $configData;
102+
103+
// Preconditions
104+
$this->objectManager->create(
105+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
106+
['configData' => $this->configData]
107+
)->run();
108+
$customAdmin->persist();
109+
$initintegration->persist();
110+
111+
// login to backend with new user
112+
$this->adminAuthLogin->open();
113+
$this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
114+
$this->adminAuthLogin->getLoginBlock()->submit();
115+
116+
// Steps
117+
$filter = ['name' => $initintegration->getName()];
118+
$this->integrationIndexPage->open();
119+
$this->integrationIndexPage->getIntegrationGrid()->searchAndOpen($filter);
120+
for ($i = 0; $i < $attempts; $i++) {
121+
$this->integrationNewPage->getIntegrationForm()->fill($integration);
122+
$this->integrationNewPage->getFormPageActions()->save();
123+
}
124+
125+
// Reload page
126+
$this->adminAuthLogin->open();
127+
$this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
128+
$this->adminAuthLogin->getLoginBlock()->submit();
129+
}
130+
131+
/**
132+
* Clean data after running test.
133+
*
134+
* @return void
135+
*/
136+
public function tearDown()
137+
{
138+
$this->objectManager->create(
139+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
140+
['configData' => $this->configData, 'rollback' => true]
141+
)->run();
142+
}
143+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Security\Test\TestCase\LockAdminUserWhenEditingIntegrationTest" summary="Lock admin user after entering incorrect password while editing integration">
10+
<variation name="LockAdminUserWhenCreatingNewIntegrationTestVariation1">
11+
<data name="configData" xsi:type="string">user_lockout_failures</data>
12+
<data name="customAdmin/dataset" xsi:type="string">custom_admin_with_default_role</data>
13+
<data name="initintegration/dataset" xsi:type="string">default_active</data>
14+
<data name="integration/data/name" xsi:type="string">Integration%isolation%</data>
15+
<data name="integration/data/current_password" xsi:type="string">incorrect password</data>
16+
<data name="attempts" xsi:type="string">4</data>
17+
<constraint name="Magento\Security\Test\Constraint\AssertUserIsLocked" />
18+
</variation>
19+
</testCase>
20+
</config>

0 commit comments

Comments
 (0)