Skip to content

Commit ca67289

Browse files
Convert LockAdminUserWhenEditingUserTest to MFTF
1 parent 4a28abb commit ca67289

File tree

5 files changed

+173
-0
lines changed

5 files changed

+173
-0
lines changed

app/code/Magento/Backend/Test/Mftf/Section/AdminLoginFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<element name="username" type="input" selector="#username"/>
1313
<element name="password" type="input" selector="#login"/>
1414
<element name="signIn" type="button" selector=".actions .action-primary" timeout="30"/>
15+
<element name="error" type="text" selector=".message.message-error.error"/>
1516
</section>
1617
</sections>
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="LockAdminUserWhenEditingUserTest">
12+
<annotations>
13+
<features value="Security"/>
14+
<stories value="Runs Lock admin user when creating new user test."/>
15+
<title value="Lock admin user when creating new user"/>
16+
<description value="Runs Lock admin user when creating new user test."/>
17+
<severity value="MAJOR"/>
18+
<group value="security"/>
19+
<group value="mtf_migrated"/>
20+
</annotations>
21+
<before>
22+
<createData entity="Admin3" stepKey="user"/>
23+
<!-- Log in to Admin Panel -->
24+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
25+
</before>
26+
<after>
27+
<!-- Unlock Admin user -->
28+
<magentoCLI command="admin:user:unlock {{_ENV.MAGENTO_ADMIN_USERNAME}}" stepKey="unlockAdminUser"/>
29+
<!-- TODO Need to create delete operation for data entity="Admin3"
30+
<deleteData createDataKey="user" stepKey="removeAdminUser"/>-->
31+
</after>
32+
33+
<actionGroup ref="AdminEditUserActionGroup" stepKey="editUserFirstAttempt">
34+
<argument name="adminUser" value="$$user.username$$"/>
35+
<argument name="adminFirstname" value="NEW$$user.firstname$$"/>
36+
<argument name="adminLastname" value="NEW$$user.lastname$$"/>
37+
<argument name="adminEmail" value="new$$user.email$$"/>
38+
<argument name="adminPassword" value="NEW$$user.password$$"/>
39+
<argument name="adminPasswordConfirmation" value="NEW$$user.password_confirmation$$"/>
40+
<argument name="adminUserRole" value="1"/>
41+
<argument name="messageSelector" value="{{AdminMessagesSection.error}}" />
42+
<argument name="message" value="The password entered for the current user is invalid. Verify the password and try again." />
43+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID"/>
44+
</actionGroup>
45+
46+
<actionGroup ref="AdminEditUserActionGroup" stepKey="editUserSecondAttempt">
47+
<argument name="adminUser" value="$$user.username$$"/>
48+
<argument name="adminFirstname" value="NEW$$user.firstname$$"/>
49+
<argument name="adminLastname" value="NEW$$user.lastname$$"/>
50+
<argument name="adminEmail" value="new$$user.email$$"/>
51+
<argument name="adminPassword" value="NEW$$user.password$$"/>
52+
<argument name="adminPasswordConfirmation" value="NEW$$user.password_confirmation$$"/>
53+
<argument name="adminUserRole" value="1"/>
54+
<argument name="messageSelector" value="{{AdminMessagesSection.error}}" />
55+
<argument name="message" value="The password entered for the current user is invalid. Verify the password and try again." />
56+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID"/>
57+
</actionGroup>
58+
59+
<actionGroup ref="AdminEditUserActionGroup" stepKey="editUserThirdAttempt">
60+
<argument name="adminUser" value="$$user.username$$"/>
61+
<argument name="adminFirstname" value="NEW$$user.firstname$$"/>
62+
<argument name="adminLastname" value="NEW$$user.lastname$$"/>
63+
<argument name="adminEmail" value="new$$user.email$$"/>
64+
<argument name="adminPassword" value="NEW$$user.password$$"/>
65+
<argument name="adminPasswordConfirmation" value="NEW$$user.password_confirmation$$"/>
66+
<argument name="adminUserRole" value="1"/>
67+
<argument name="messageSelector" value="{{AdminMessagesSection.error}}" />
68+
<argument name="message" value="The password entered for the current user is invalid. Verify the password and try again." />
69+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID"/>
70+
</actionGroup>
71+
72+
<actionGroup ref="AdminEditUserActionGroup" stepKey="editUserFourthAttempt">
73+
<argument name="adminUser" value="$$user.username$$"/>
74+
<argument name="adminFirstname" value="NEW$$user.firstname$$"/>
75+
<argument name="adminLastname" value="NEW$$user.lastname$$"/>
76+
<argument name="adminEmail" value="new$$user.email$$"/>
77+
<argument name="adminPassword" value="NEW$$user.password$$"/>
78+
<argument name="adminPasswordConfirmation" value="NEW$$user.password_confirmation$$"/>
79+
<argument name="adminUserRole" value="1"/>
80+
<argument name="messageSelector" value="{{AdminMessagesSection.error}}" />
81+
<argument name="message" value="The password entered for the current user is invalid. Verify the password and try again." />
82+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID"/>
83+
</actionGroup>
84+
85+
<actionGroup ref="AdminEditUserActionGroup" stepKey="editUserFifthAttempt">
86+
<argument name="adminUser" value="$$user.username$$"/>
87+
<argument name="adminFirstname" value="NEW$$user.firstname$$"/>
88+
<argument name="adminLastname" value="NEW$$user.lastname$$"/>
89+
<argument name="adminEmail" value="new$$user.email$$"/>
90+
<argument name="adminPassword" value="NEW$$user.password$$"/>
91+
<argument name="adminPasswordConfirmation" value="NEW$$user.password_confirmation$$"/>
92+
<argument name="adminUserRole" value="1"/>
93+
<argument name="messageSelector" value="{{AdminMessagesSection.error}}" />
94+
<argument name="message" value="The password entered for the current user is invalid. Verify the password and try again." />
95+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID"/>
96+
</actionGroup>
97+
98+
<actionGroup ref="AdminEditUserActionGroup" stepKey="openEditLastPage">
99+
<argument name="adminUser" value="$$user.username$$"/>
100+
<argument name="adminFirstname" value="NEW$$user.firstname$$"/>
101+
<argument name="adminLastname" value="NEW$$user.lastname$$"/>
102+
<argument name="adminEmail" value="new$$user.email$$"/>
103+
<argument name="adminPassword" value="NEW$$user.password$$"/>
104+
<argument name="adminPasswordConfirmation" value="NEW$$user.password_confirmation$$"/>
105+
<argument name="adminUserRole" value="1"/>
106+
<argument name="messageSelector" value="{{AdminLoginFormSection.error}}" />
107+
<argument name="message" value="Your account is temporarily disabled. Please try again later." />
108+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID"/>
109+
</actionGroup>
110+
111+
<!-- Try to login as admin and check error -->
112+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsLockedAdmin"/>
113+
<waitForPageLoad stepKey="waitForError"/>
114+
<see selector="{{AdminLoginFormSection.error}}" userInput="The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later"
115+
stepKey="seeLoginUserError"/>
116+
</test>
117+
</tests>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminEditUserActionGroup">
11+
<arguments>
12+
<argument name="adminUser" type="string" />
13+
<argument name="adminFirstname" type="string" />
14+
<argument name="adminLastname" type="string" />
15+
<argument name="adminEmail" type="string" />
16+
<argument name="adminPassword" type="string" />
17+
<argument name="adminPasswordConfirmation" type="string" />
18+
<argument name="currentAdminPassword" type="string" />
19+
<argument name="adminUserRole" type="string"/>
20+
<argument name="message" type="string" defaultValue="You saved the user." />
21+
<argument name="messageSelector" type="string" defaultValue="{{AdminMessagesSection.success}}" />
22+
</arguments>
23+
24+
<!-- Navigate to edit user page -->
25+
<amOnPage url="{{AdminUsersPage.url}}" stepKey="openAdminUsersPage"/>
26+
<fillField selector="{{AdminUserGridSection.usernameFilterTextField}}" userInput="{{adminUser}}" stepKey="fillSearchUsernameFilter"/>
27+
<click selector="{{AdminUserGridSection.searchButton}}" stepKey="clickSearch" />
28+
<waitForPageLoad stepKey="waitForGridToLoad"/>
29+
<see selector="{{AdminUserGridSection.usernameInFirstRow}}" userInput="{{adminUser}}" stepKey="seeUser" />
30+
<click selector="{{AdminUserGridSection.searchResultFirstRow}}" stepKey="openUserEdit"/>
31+
<waitForPageLoad stepKey="waitForUserEditPageLoad"/>
32+
33+
<!-- Edit admin User data -->
34+
<fillField selector="{{AdminEditUserSection.usernameTextField}}" userInput="{{adminUser}}" stepKey="fillUser"/>
35+
<fillField selector="{{AdminEditUserSection.firstNameTextField}}" userInput="{{adminFirstname}}" stepKey="fillFirstName"/>
36+
<fillField selector="{{AdminEditUserSection.lastNameTextField}}" userInput="{{adminLastname}}" stepKey="fillLastName"/>
37+
<fillField selector="{{AdminEditUserSection.emailTextField}}" userInput="{{adminEmail}}" stepKey="fillEmail"/>
38+
<fillField selector="{{AdminEditUserSection.passwordTextField}}" userInput="{{adminPassword}}" stepKey="fillPassword"/>
39+
<fillField selector="{{AdminEditUserSection.pwConfirmationTextField}}" userInput="{{adminPasswordConfirmation}}" stepKey="fillPasswordConfirmation"/>
40+
<fillField selector="{{AdminEditUserSection.currentPasswordField}}" userInput="{{currentAdminPassword}}" stepKey="fillCurrentUserPassword"/>
41+
<scrollToTopOfPage stepKey="ScrollToTopOfPage"/>
42+
43+
<!-- Set admin User Role -->
44+
<click selector="{{AdminEditUserSection.userRoleTab}}" stepKey="openUserRoleTab"/>
45+
<click selector="{{AdminEditUserSection.administratorRoleRadio(adminUserRole)}}" stepKey="assignRole"/>
46+
47+
<!-- Save User -->
48+
<click selector="{{AdminEditUserSection.saveButton}}" stepKey="saveUser"/>
49+
<waitForPageLoad stepKey="waitForSaveResultLoad"/>
50+
<see userInput="{{message}}" selector="{{messageSelector}}" stepKey="verifyMessage" />
51+
52+
</actionGroup>
53+
</actionGroups>

app/code/Magento/User/Test/Mftf/Section/AdminEditUserSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<element name="pwConfirmationTextField" type="input" selector="#user_confirmation"/>
2020
<element name="currentPasswordField" type="input" selector="#user_current_password"/>
2121
<element name="userRoleTab" type="button" selector="#page_tabs_roles_section"/>
22+
<element name="administratorRoleRadio" type="radio" selector="//*[@id='permissionsUserRolesGrid_table']//td[{{role}}]/input" parameterized="true"/>
2223
<element name="roleNameFilterTextField" type="input" selector="#permissionsUserRolesGrid_filter_role_name"/>
2324
<element name="searchButton" type="button" selector=".admin__data-grid-header button[title=Search]"/>
2425
<element name="resetButton" type="button" selector="button[title='Reset Filter']"/>

dev/tests/functional/tests/app/Magento/Security/Test/TestCase/LockAdminUserWhenEditingUserTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<data name="user/data/password_confirmation" xsi:type="string">123123qq</data>
2020
<data name="user/data/current_password" xsi:type="string">incorrect password</data>
2121
<data name="attempts" xsi:type="string">4</data>
22+
<data name="tag" xsi:type="string">mftf_migrated:yes</data>
2223
<constraint name="Magento\Security\Test\Constraint\AssertUserIsLocked" />
2324
</variation>
2425
</testCase>

0 commit comments

Comments
 (0)