Skip to content

Commit 9ca1a7b

Browse files
Convert LockAdminUserWhenCreatingNewRoleTest to MFTF
1 parent 4f6c78e commit 9ca1a7b

File tree

7 files changed

+123
-0
lines changed

7 files changed

+123
-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="AdminNewRolePage" url="admin/user_role/editrole/" area="admin" module="Backend">
12+
<section name="AdminNewRoleSection"/>
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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="AdminNewRoleSection">
12+
<element name="roleName" type="input" selector="#role_name"/>
13+
<element name="currentPassword" type="input" selector="#current_password"/>
14+
<element name="pageActionButton" type="button" selector="//div[contains(@class, 'page-actions-buttons')]//button[contains(., '{{button}}')]"
15+
parameterized="true"/>
16+
</section>
17+
</sections>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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="AdminNewRoleInvalidCurrentUserPasswordActionGroup">
11+
<fillField selector="{{AdminNewRoleSection.roleName}}" userInput="{{AdminRoleData.roleName}}" stepKey="fillRoleName"/>
12+
<fillField selector="{{AdminNewRoleSection.currentPassword}}" userInput="PasswordINVALID" stepKey="fillCurrentUserPassword"/>
13+
<click selector="{{AdminNewRoleSection.pageActionButton('Save Role')}}" stepKey="saveNewRole"/>
14+
<waitForPageLoad stepKey="waitForSaveResultLoad"/>
15+
</actionGroup>
16+
</actionGroups>
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="AdminRoleData" type="admin">
12+
<data key="roleName" unique="prefix">role</data>
13+
</entity>
14+
</entities>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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="LockAdminUserWhenCreatingNewRoleTest">
12+
<annotations>
13+
<features value="Security"/>
14+
<stories value="Runs Lock admin user when creating new admin role test."/>
15+
<title value="Lock admin user when creating new admin role"/>
16+
<description value="Runs Lock admin user when creating new admin role 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 Role Page -->
31+
<amOnPage url="{{AdminNewRolePage.url}}" stepKey="amOnNewAdminRolePage"/>
32+
<waitForPageLoad stepKey="waitForNewAdminRolePageLoad"/>
33+
34+
<!-- Perform add new role 6 specified number of times. -->
35+
<actionGroup ref="AdminNewRoleInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveRoleFirstAttempt">
36+
</actionGroup>
37+
<see selector="{{AdminMessagesSection.error}}" userInput="The password entered for the current user is invalid. Verify the password and try again."
38+
stepKey="seeInvalidPasswordError"/>
39+
<actionGroup ref="AdminNewRoleInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveRoleSecondAttempt">
40+
</actionGroup>
41+
<actionGroup ref="AdminNewRoleInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveRoleThirdAttempt">
42+
</actionGroup>
43+
<actionGroup ref="AdminNewRoleInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveRoleFourthAttempt">
44+
</actionGroup>
45+
<actionGroup ref="AdminNewRoleInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveRoleFifthAttempt">
46+
</actionGroup>
47+
<actionGroup ref="AdminNewRoleInvalidCurrentUserPasswordActionGroup" stepKey="failedSaveRoleSixthAttempt">
48+
</actionGroup>
49+
50+
<!-- Check Error that account has been locked -->
51+
<waitForPageLoad stepKey="waitForSaveResultLoad"/>
52+
<see selector="{{AdminLoginFormSection.error}}" userInput="Your account is temporarily disabled. Please try again later." stepKey="seeLockUserError"/>
53+
54+
<!-- Try to login as admin and check error -->
55+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsLockedAdmin"/>
56+
<waitForPageLoad stepKey="waitForError"/>
57+
<see selector="{{AdminLoginFormSection.error}}" userInput="The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later"
58+
stepKey="seeLoginAdminError"/>
59+
</test>
60+
</tests>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<data name="role/data/current_password" xsi:type="string">incorrect password</data>
1616
<data name="role/data/resource_access" xsi:type="string">All</data>
1717
<data name="attempts" xsi:type="string">4</data>
18+
<data name="tag" xsi:type="string">mftf_migrated:yes</data>
1819
<constraint name="Magento\Security\Test\Constraint\AssertUserIsLocked" />
1920
</variation>
2021
</testCase>

0 commit comments

Comments
 (0)