Skip to content

Commit d0688f2

Browse files
authored
Merge pull request #547 from magento-jackalopes/Functional-tests-PR
Fixed issues: - MAGETWO-57798 Automate password protection for modifying user Role - MAGETWO-57908 Automate - password protection for modifying user - MAGETWO-57909 Automate - password protection for adding new user - MAGETWO-58022 Automate - password protection for modifying Integration
2 parents 76315a6 + b3d5a9b commit d0688f2

8 files changed

+643
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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+
10+
use Magento\User\Test\Page\Adminhtml\UserEdit;
11+
use Magento\User\Test\Page\Adminhtml\UserIndex;
12+
use Magento\Mtf\TestCase\Injectable;
13+
use Magento\User\Test\Fixture\User;
14+
use Magento\Backend\Test\Page\AdminAuthLogin;
15+
16+
/**
17+
* Preconditions:
18+
* 1. Create admin user.
19+
* 2. Configure 'Maximum Login Failures to Lockout Account'.
20+
*
21+
* Steps:
22+
* 1. Log in to backend as admin user.
23+
* 2. Navigate to System > All Users.
24+
* 3. Click on Add New User.
25+
* 4. Fill in all data according to data set (password is incorrect).
26+
* 5. Perform action 4 specified number of times.
27+
* 6. "You have entered an invalid password for current user." appears after each attempt.
28+
* 7. Perform all assertions.
29+
*
30+
* @ZephyrId MAGETWO-49034
31+
*/
32+
class LockAdminUserWhenCreatingNewUserTest extends Injectable
33+
{
34+
/* tags */
35+
const MVP = 'yes';
36+
const SEVERITY = 'S2';
37+
/* end tags */
38+
39+
/**
40+
* User grid page
41+
*
42+
* @var UserIndex
43+
*/
44+
protected $userIndexPage;
45+
46+
/**
47+
* User new/edit page
48+
*
49+
* @var UserEdit
50+
*/
51+
protected $userEditPage;
52+
53+
/**
54+
* Configuration setting.
55+
*
56+
* @var string
57+
*/
58+
protected $configData;
59+
60+
/**
61+
* @var AdminAuthLogin page
62+
*/
63+
protected $adminAuthLogin;
64+
65+
/**
66+
* Setup data for test.
67+
* @param UserIndex $userIndex
68+
* @param UserEdit $userEdit
69+
* @param AdminAuthLogin $adminAuthLogin
70+
*/
71+
public function __inject(
72+
UserIndex $userIndex,
73+
UserEdit $userEdit,
74+
AdminAuthLogin $adminAuthLogin
75+
) {
76+
$this->userIndexPage = $userIndex;
77+
$this->userEditPage = $userEdit;
78+
$this->adminAuthLogin = $adminAuthLogin;
79+
}
80+
81+
/**
82+
* Runs Lock admin user when creating new user test.
83+
*
84+
* @param int $attempts
85+
* @param User $customAdmin,
86+
* @param User $user,
87+
* @param string $configData
88+
* @return void
89+
*/
90+
public function test(
91+
$attempts,
92+
User $customAdmin,
93+
User $user,
94+
$configData
95+
) {
96+
$this->configData = $configData;
97+
98+
// Preconditions
99+
$this->objectManager->create(
100+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
101+
['configData' => $this->configData]
102+
)->run();
103+
$customAdmin->persist();
104+
105+
// Steps
106+
$this->adminAuthLogin->open();
107+
$this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
108+
$this->adminAuthLogin->getLoginBlock()->submit();
109+
$this->userIndexPage->open();
110+
$this->userIndexPage->getPageActions()->addNew();
111+
for ($i = 0; $i < $attempts; $i++) {
112+
$this->userEditPage->getUserForm()->fill($user);
113+
$this->userEditPage->getPageActions()->save();
114+
}
115+
116+
// Reload
117+
$this->adminAuthLogin->open();
118+
$this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
119+
$this->adminAuthLogin->getLoginBlock()->submit();
120+
}
121+
122+
/**
123+
* Clean data after running test.
124+
*
125+
* @return void
126+
*/
127+
public function tearDown()
128+
{
129+
$this->objectManager->create(
130+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
131+
['configData' => $this->configData, 'rollback' => true]
132+
)->run();
133+
}
134+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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\LockAdminUserWhenCreatingNewUserTest" summary="Lock admin user after entering incorrect password while creating new User">
10+
<variation name="LockAdminUserWhenCreatingNewUserTestVariation1">
11+
<data name="configData" xsi:type="string">user_lockout_failures</data>
12+
<data name="tag" xsi:type="string">severity:S2</data>
13+
<data name="customAdmin/dataset" xsi:type="string">custom_admin_with_default_role</data>
14+
<data name="user/data/username" xsi:type="string">AdminUser%isolation%</data>
15+
<data name="user/data/firstname" xsi:type="string">FirstName%isolation%</data>
16+
<data name="user/data/lastname" xsi:type="string">LastName%isolation%</data>
17+
<data name="user/data/email" xsi:type="string">email%isolation%@example.com</data>
18+
<data name="user/data/password" xsi:type="string">123123q</data>
19+
<data name="user/data/password_confirmation" xsi:type="string">123123q</data>
20+
<data name="user/data/current_password" xsi:type="string">incorrect password</data>
21+
<data name="attempts" xsi:type="string">4</data>
22+
<constraint name="Magento\Security\Test\Constraint\AssertUserIsLocked" />
23+
</variation>
24+
</testCase>
25+
</config>
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+
* Preconditions:
18+
* 1. Create admin user.
19+
* 2. Create integration.
20+
* 3. Configure 'Maximum Login Failures to Lockout Account'.
21+
*
22+
* Steps:
23+
* 1. Log in to backend as admin user.
24+
* 2. Navigate to System > Extensions > Integrations.
25+
* 3. Start to edit existing Integration.
26+
* 4. Fill in all data according to data set (password is incorrect).
27+
* 5. Perform action 4 specified number of times.
28+
* 6. "You have entered an invalid password for current user." appears after each attempt.
29+
* 7. Perform all assertions.
30+
*
31+
* @ZephyrId MAGETWO-49039
32+
*/
33+
class LockAdminUserWhenEditingIntegrationTest extends Injectable
34+
{
35+
/* tags */
36+
const MVP = 'yes';
37+
const SEVERITY = 'S2';
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
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,21 @@
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="tag" xsi:type="string">severity:S2</data>
13+
<data name="customAdmin/dataset" xsi:type="string">custom_admin_with_default_role</data>
14+
<data name="initintegration/dataset" xsi:type="string">default_active</data>
15+
<data name="integration/data/name" xsi:type="string">Integration%isolation%</data>
16+
<data name="integration/data/current_password" xsi:type="string">incorrect password</data>
17+
<data name="attempts" xsi:type="string">4</data>
18+
<constraint name="Magento\Security\Test\Constraint\AssertUserIsLocked" />
19+
</variation>
20+
</testCase>
21+
</config>

0 commit comments

Comments
 (0)