Skip to content

Commit 58211e3

Browse files
Convert LockAdminUserWhenCreatingNewUserTest to MFTF
1 parent 4f6c78e commit 58211e3

File tree

6 files changed

+143
-0
lines changed

6 files changed

+143
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
11+
<page name="AdminAddNewUserPage" url="admin/user/new" area="admin" module="Backend">
12+
<section name="AddNewAdminUserSection"/>
13+
</page>
14+
</pages>

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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminNewUserSection">
12+
<element name="username" type="input" selector="#user_username"/>
13+
<element name="firstname" type="input" selector="#user_firstname"/>
14+
<element name="lastname" type="input" selector="#user_lastname"/>
15+
<element name="email" type="input" selector="#user_email"/>
16+
<element name="password" type="input" selector="#user_password"/>
17+
<element name="confirmation" type="input" selector="#user_confirmation"/>
18+
<element name="currentPassword" type="input" selector="#user_current_password"/>
19+
<element name="save" type="button" selector="#save"/>
20+
<element name="userRoleTab" type="button" selector="#page_tabs_roles_section"/>
21+
<element name="administratorRole" type="radio" selector="//*[@id='permissionsUserRolesGrid_table']//td[{{role}}]/input" parameterized="true"/>
22+
</section>
23+
</sections>
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 © 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="AdminNewUserInvalidCurrentUserPasswordActionGroup">
11+
<!-- Fill in all data according to data set (current password is incorrect). -->
12+
<fillField selector="{{AdminNewUserSection.username}}" userInput="{{AdminUserData.username}}" stepKey="fillUser"/>
13+
<fillField selector="{{AdminNewUserSection.firstname}}" userInput="{{AdminUserData.firstname}}" stepKey="fillFirstName"/>
14+
<fillField selector="{{AdminNewUserSection.lastname}}" userInput="{{AdminUserData.lastname}}" stepKey="fillLastName"/>
15+
<fillField selector="{{AdminNewUserSection.email}}" userInput="{{AdminUserData.email}}" stepKey="fillEmail"/>
16+
<fillField selector="{{AdminNewUserSection.password}}" userInput="{{AdminUserData.password}}" stepKey="fillPassword"/>
17+
<fillField selector="{{AdminNewUserSection.confirmation}}" userInput="{{AdminUserData.password}}" stepKey="fillPasswordConfirmation"/>
18+
<fillField selector="{{AdminNewUserSection.currentPassword}}" userInput="{{AdminUserData.password}}INVALID" stepKey="fillCurrentUserPassword"/>
19+
<scrollToTopOfPage stepKey="ScrollToTopOfPage"/>
20+
<click selector="{{AdminNewUserSection.userRoleTab}}" stepKey="openUserRoleTab"/>
21+
<click selector="{{AdminNewUserSection.administratorRole('1')}}" stepKey="assignRole"/>
22+
<click selector="{{AdminNewUserSection.save}}" stepKey="saveNewUser"/>
23+
<waitForPageLoad stepKey="waitForSaveResultLoad"/>
24+
</actionGroup>
25+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="AdminUserData" type="admin">
12+
<data key="email" unique="prefix">John.Doe@example.com</data>
13+
<data key="firstname">John</data>
14+
<data key="username">lockuser</data>
15+
<data key="lastname">Doe</data>
16+
<data key="password">pwdTest123!</data>
17+
</entity>
18+
</entities>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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="LockAdminUserWhenCreatingNewUserTest">
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+
<!-- Log in to Admin Panel -->
23+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
24+
</before>
25+
<after>
26+
<!-- Unlock Admin user -->
27+
<magentoCLI command="admin:user:unlock {{_ENV.MAGENTO_ADMIN_USERNAME}}" stepKey="unlockAdminUser"/>
28+
</after>
29+
30+
<!-- Open Admin New User Page -->
31+
<amOnPage url="{{AdminAddNewUserPage.url}}" stepKey="amOnNewAdminUserPage"/>
32+
<waitForPageLoad stepKey="waitForNewAdminUserPageLoad"/>
33+
34+
<!-- Perform add new admin user 6 specified number of times.
35+
"The password entered for the current user is invalid. Verify the password and try again." appears after each attempt.-->
36+
<actionGroup ref="AdminNewUserInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveUserAttempt1">
37+
</actionGroup>
38+
<waitForPageLoad stepKey="waitForSaveResultLoad"/>
39+
<see selector="{{AdminMessagesSection.error}}" userInput="The password entered for the current user is invalid. Verify the password and try again."
40+
stepKey="seeInvalidPasswordError"/>
41+
<actionGroup ref="AdminNewUserInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveUserAttempt2">
42+
</actionGroup>
43+
<actionGroup ref="AdminNewUserInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveUserAttempt3">
44+
</actionGroup>
45+
<actionGroup ref="AdminNewUserInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveUserAttempt4">
46+
</actionGroup>
47+
<actionGroup ref="AdminNewUserInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveUserAttempt5">
48+
</actionGroup>
49+
<actionGroup ref="AdminNewUserInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveUserAttempt6">
50+
</actionGroup>
51+
52+
<!-- Check Error that account has been locked -->
53+
<waitForPageLoad stepKey="wailtForSaveResultLoad"/>
54+
<see selector="{{AdminLoginFormSection.error}}" userInput="Your account is temporarily disabled. Please try again later." stepKey="seeLockUserError"/>
55+
56+
<!-- Try to login as admin and check error -->
57+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsLockedAdmin"/>
58+
<waitForPageLoad stepKey="waitForError"/>
59+
<see selector="{{AdminLoginFormSection.error}}" userInput="The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later"
60+
stepKey="seeLockUserError2"/>
61+
</test>
62+
</tests>

0 commit comments

Comments
 (0)