Skip to content

Commit 2964389

Browse files
committed
Merge remote-tracking branch 'remotes/origin/MAGETWO-57798-Automate-Password-protection-for-modifying-user-Role' into Functional-tests-PR
2 parents 5d7f6a9 + 8370697 commit 2964389

File tree

2 files changed

+153
-0
lines changed

2 files changed

+153
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Security\Test\TestCase;
7+
use Magento\User\Test\Page\Adminhtml\UserRoleEditRole;
8+
use Magento\User\Test\Page\Adminhtml\UserRoleIndex;
9+
use Magento\Mtf\TestCase\Injectable;
10+
use Magento\User\Test\Fixture\User;
11+
use Magento\User\Test\Fixture\Role;
12+
use Magento\Backend\Test\Page\AdminAuthLogin;
13+
/**
14+
* Preconditions:
15+
* 1. Create new admin user and assign it to new role.
16+
* 2. Configure 'Maximum Login Failures to Lockout Account'.
17+
*
18+
* Steps:
19+
* 1. Log in to backend as new created admin user.
20+
* 2. Navigate to System > User Roles.
21+
* 3. Start editing existing User Role.
22+
* 4. Fill in all data according to data set (password is incorrect).
23+
* 5. Perform action 4 specified number of times.
24+
* 6. Admin account is locked.
25+
* 7. Perform all assertions.
26+
*
27+
* @ZephyrId MAGETWO-49037
28+
* @Group Security
29+
*
30+
*/
31+
class LockAdminUserWhenEditingRoleTest extends Injectable
32+
{
33+
/* tags */
34+
const MVP = 'yes';
35+
const SEVERITY = 'S2';
36+
/* end tags */
37+
/**
38+
* UserRoleIndex page.
39+
*
40+
* @var UserRoleIndex
41+
*/
42+
protected $userRoleIndex;
43+
/**
44+
* UserRoleEditRole page.
45+
*
46+
* @var UserRoleEditRole
47+
*/
48+
protected $userRoleEditRole;
49+
/**
50+
* Configuration setting.
51+
*
52+
* @var string
53+
*/
54+
protected $configData;
55+
/**
56+
* Admin login Page.
57+
*
58+
* @var AdminAuthLogin
59+
*/
60+
protected $adminAuthLogin;
61+
/**
62+
* Setup data for test.
63+
*
64+
* @param UserRoleIndex $userRoleIndex
65+
* @param UserRoleEditRole $userRoleEditRole
66+
* @param AdminAuthLogin $adminAuthLogin
67+
* @return void
68+
*/
69+
public function __inject(
70+
UserRoleIndex $userRoleIndex,
71+
UserRoleEditRole $userRoleEditRole,
72+
AdminAuthLogin $adminAuthLogin
73+
) {
74+
$this->userRoleIndex = $userRoleIndex;
75+
$this->userRoleEditRole = $userRoleEditRole;
76+
$this->adminAuthLogin = $adminAuthLogin;
77+
}
78+
/**
79+
* Runs Lock admin user when editing existing role test.
80+
*
81+
* @param Role $role
82+
* @param Role $initrole
83+
* @param int $attempts
84+
* @param User $customAdmin
85+
* @param string $configData
86+
* @return void
87+
*/
88+
public function test(
89+
Role $role,
90+
Role $initrole,
91+
$attempts,
92+
User $customAdmin,
93+
$configData
94+
) {
95+
$this->configData = $configData;
96+
// Preconditions
97+
$this->objectManager->create(
98+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
99+
['configData' => $this->configData]
100+
)->run();
101+
$customAdmin->persist();
102+
$initrole->persist();
103+
// Steps login to backend with new user
104+
$this->adminAuthLogin->open();
105+
$this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
106+
$this->adminAuthLogin->getLoginBlock()->submit();
107+
$filter = ['rolename' => $initrole->getRolename()];
108+
$this->userRoleIndex->open();
109+
$this->userRoleIndex->getRoleGrid()->searchAndOpen($filter);
110+
for ($i = 0; $i < $attempts; $i++) {
111+
$this->userRoleEditRole->getRoleFormTabs()->fill($role);
112+
$this->userRoleEditRole->getPageActions()->save();
113+
}
114+
// Reload
115+
$this->adminAuthLogin->open();
116+
$this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
117+
$this->adminAuthLogin->getLoginBlock()->submit();
118+
}
119+
/**
120+
* Clean data after running test.
121+
*
122+
* @return void
123+
*/
124+
public function tearDown()
125+
{
126+
$this->objectManager->create(
127+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
128+
['configData' => $this->configData, 'rollback' => true]
129+
)->run();
130+
}
131+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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\LockAdminUserWhenEditingRoleTest" summary="Lock admin user after entering incorrect password while editing existing role">
10+
<variation name="LockAdminUserWhenEditingUserRoleTestVariation1">
11+
<data name="configData" xsi:type="string">user_lockout_failures</data>
12+
<data name="tag" xsi:type="string">severity:S2</data>
13+
<data name="initrole/dataset" xsi:type="string">default</data>
14+
<data name="customAdmin/dataset" xsi:type="string">custom_admin_with_default_role</data>
15+
<data name="role/data/rolename" xsi:type="string">NewAdminRole%isolation%</data>
16+
<data name="role/data/current_password" xsi:type="string">incorrect password</data>
17+
<data name="role/data/resource_access" xsi:type="string">All</data>
18+
<data name="attempts" xsi:type="string">4</data>
19+
<constraint name="Magento\Security\Test\Constraint\AssertUserIsLocked" />
20+
</variation>
21+
</testCase>
22+
</config>

0 commit comments

Comments
 (0)