Skip to content

Commit 3164e9b

Browse files
committed
MAGETWO-57908: Automate - MAGETWO-49035 Password protection for modifying user
- Write functional test for MAGETWO-49035.
1 parent 3a43a25 commit 3164e9b

File tree

2 files changed

+155
-0
lines changed

2 files changed

+155
-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+
7+
namespace Magento\Security\Test\TestCase;
8+
9+
use Magento\User\Test\Page\Adminhtml\UserEdit;
10+
use Magento\User\Test\Page\Adminhtml\UserIndex;
11+
use Magento\Backend\Test\Page\AdminAuthLogin;
12+
use Magento\User\Test\Fixture\User;
13+
use Magento\Mtf\TestCase\Injectable;
14+
15+
/**
16+
* Preconditions:
17+
* 1. Create new admin user.
18+
* 2. Configure 'Maximum Login Failures to Lockout Account'.
19+
*
20+
* Steps:
21+
* 1. Log in to backend as new created admin user.
22+
* 2. Navigate to System > All Users.
23+
* 3. Start editing existing User.
24+
* 4. Fill in all data according to data set (password is incorrect).
25+
* 5. Perform action 4 specified number of times.
26+
* 6. Admin account is locked.
27+
* 7. Perform all assertions.
28+
*
29+
* @ZephyrId MAGETWO-49035
30+
*/
31+
class LockAdminUserWhenEditingUserTest extends Injectable
32+
{
33+
/* tags */
34+
const MVP = 'yes';
35+
const DOMAIN = 'PS';
36+
/* end tags */
37+
38+
/**
39+
* User grid page
40+
*
41+
* @var UserIndex
42+
*/
43+
protected $userIndexPage;
44+
45+
/**
46+
* User edit page
47+
*
48+
* @var UserEdit
49+
*/
50+
protected $userEditPage;
51+
52+
/**
53+
* @var $configData
54+
*/
55+
protected $configData;
56+
57+
/**
58+
* @var AdminAuthLogin page
59+
*/
60+
protected $adminAuthLogin;
61+
62+
/**
63+
* Setup data for test.
64+
* @param UserIndex $userIndex
65+
* @param UserEdit $userEdit
66+
* @param AdminAuthLogin $adminAuthLogin
67+
*/
68+
public function __inject(
69+
UserIndex $userIndex,
70+
UserEdit $userEdit,
71+
AdminAuthLogin $adminAuthLogin
72+
) {
73+
$this->userIndexPage = $userIndex;
74+
$this->userEditPage = $userEdit;
75+
$this->adminAuthLogin = $adminAuthLogin;
76+
}
77+
/**
78+
* Runs Lock admin user when editing existing role test.
79+
*
80+
* @param User $user
81+
* @param int $attempts
82+
* @param User $customAdmin
83+
* @param string $configData
84+
* @return void
85+
*/
86+
public function test(
87+
$attempts,
88+
User $customAdmin,
89+
User $user,
90+
$configData = null
91+
) {
92+
$this->configData = $configData;
93+
94+
// Preconditions
95+
$this->objectManager->create(
96+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
97+
['configData' => $this->configData]
98+
)->run();
99+
$customAdmin->persist();
100+
101+
// Steps login to backend with new user
102+
$this->adminAuthLogin->open();
103+
$this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
104+
$this->adminAuthLogin->getLoginBlock()->submit();
105+
// Select user to edit.
106+
$filter = ['username' => $customAdmin->getUsername()];
107+
$this->userIndexPage->open();
108+
$this->userIndexPage->getUserGrid()->searchAndOpen($filter);
109+
// Edit user with wrong password
110+
for ($i = 0; $i < $attempts; $i++) {
111+
$this->userEditPage->getUserForm()->fill($user);
112+
$this->userEditPage->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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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\LockAdminUserWhenEditingUserTest" summary="Lock admin user after entering incorrect password while editing existing user">
10+
<variation name="LockAdminUserWhenEditingUseruserTestVariation1">
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="user/data/username" xsi:type="string">AdminUser%isolation%</data>
14+
<data name="user/data/firstname" xsi:type="string">FirstName%isolation%</data>
15+
<data name="user/data/lastname" xsi:type="string">LastName%isolation%</data>
16+
<data name="user/data/email" xsi:type="string">email%isolation%@example.com</data>
17+
<data name="user/data/password" xsi:type="string">123123qq</data>
18+
<data name="user/data/password_confirmation" xsi:type="string">123123qq</data>
19+
<data name="user/data/current_password" xsi:type="string">incorrect password</data>
20+
<data name="attempts" xsi:type="string">4</data>
21+
<constraint name="Magento\Security\Test\Constraint\AssertUserIsLocked" />
22+
</variation>
23+
</testCase>
24+
</config>

0 commit comments

Comments
 (0)