Skip to content

Commit b5afedf

Browse files
Convert LockAdminUserWhenCreatingNewIntegrationTest to MFTF
1 parent 4a28abb commit b5afedf

File tree

6 files changed

+155
-0
lines changed

6 files changed

+155
-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: 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="AdminNewIntegrationData" type="admin">
12+
<data key="integrationName" unique="prefix">_Integration</data>
13+
</entity>
14+
</entities>
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="AdminNewIntegrationPage" url="admin/integration/new/" area="admin" module="Magento_Integration">
12+
<section name="AdminNewIntegrationSection"/>
13+
</page>
14+
</pages>
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+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminNewIntegrationSection">
12+
<element name="integrationName" type="input" selector="#integration_properties_name"/>
13+
<element name="currentPassword" type="input" selector="#integration_properties_current_password"/>
14+
<element name="save" type="button" selector="#save-split-button-button"/>
15+
</section>
16+
</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="AdminNewIntegrationRequiredFieldsActionGroup">
11+
<arguments>
12+
<argument name="integrationName" type="string" />
13+
<argument name="currentAdminPassword" type="string" />
14+
<argument name="message" type="string" defaultValue="The integration '{{AdminNewIntegrationData.integrationName}}' has been saved." />
15+
<argument name="messageSelector" type="string" defaultValue="{{AdminMessagesSection.success}}" />
16+
</arguments>
17+
<!-- Fill all Required Fields. -->
18+
<fillField selector="{{AdminNewIntegrationSection.integrationName}}" userInput="{{integrationName}}" stepKey="fillIntegrationName"/>
19+
<fillField selector="{{AdminNewIntegrationSection.currentPassword}}" userInput="{{currentAdminPassword}}" stepKey="fillCurrentUserPassword"/>
20+
<scrollToTopOfPage stepKey="ScrollToTopOfPage"/>
21+
<click selector="{{AdminNewIntegrationSection.save}}" stepKey="saveNewIntegration"/>
22+
<waitForPageLoad stepKey="waitForSaveResultLoad"/>
23+
<see userInput="{{message}}" selector="{{messageSelector}}" stepKey="verifyMessage" />
24+
</actionGroup>
25+
</actionGroups>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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="LockAdminUserWhenCreatingNewIntegrationTest">
12+
<annotations>
13+
<features value="Security"/>
14+
<stories value="Runs Lock admin user when creating new integration test."/>
15+
<title value="Lock admin user when creating new integration"/>
16+
<description value="Runs Lock admin user when creating new integration 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 Integration Page -->
31+
<amOnPage url="{{AdminNewIntegrationPage.url}}" stepKey="amOnNewAdminIntegrationPage"/>
32+
<waitForPageLoad stepKey="waitForNewAdminIntegrationPageLoad"/>
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="AdminNewIntegrationRequiredFieldsActionGroup" stepKey="failedSaveIntegrationFirstAttempt">
37+
<argument name="integrationName" value="{{AdminNewIntegrationData.integrationName}}" />
38+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
39+
<argument name="messageSelector" value="{{AdminMessagesSection.error}}" />
40+
<argument name="message" value="The password entered for the current user is invalid. Verify the password and try again." />
41+
</actionGroup>
42+
43+
<actionGroup ref="AdminNewIntegrationRequiredFieldsActionGroup" stepKey="failedSaveIntegrationSecondAttempt">
44+
<argument name="integrationName" value="{{AdminNewIntegrationData.integrationName}}" />
45+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
46+
<argument name="messageSelector" value="{{AdminMessagesSection.error}}" />
47+
<argument name="message" value="The password entered for the current user is invalid. Verify the password and try again." />
48+
</actionGroup>
49+
50+
<actionGroup ref="AdminNewIntegrationRequiredFieldsActionGroup" stepKey="failedSaveIntegrationThirdAttempt">
51+
<argument name="integrationName" value="{{AdminNewIntegrationData.integrationName}}" />
52+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
53+
<argument name="messageSelector" value="{{AdminMessagesSection.error}}" />
54+
<argument name="message" value="The password entered for the current user is invalid. Verify the password and try again." />
55+
</actionGroup>
56+
57+
<actionGroup ref="AdminNewIntegrationRequiredFieldsActionGroup" stepKey="failedSaveIntegrationFourthAttempt">
58+
<argument name="integrationName" value="{{AdminNewIntegrationData.integrationName}}" />
59+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
60+
<argument name="messageSelector" value="{{AdminMessagesSection.error}}" />
61+
<argument name="message" value="The password entered for the current user is invalid. Verify the password and try again." />
62+
</actionGroup>
63+
64+
<actionGroup ref="AdminNewIntegrationRequiredFieldsActionGroup" stepKey="failedSaveIntegrationFifthAttempt">
65+
<argument name="integrationName" value="{{AdminNewIntegrationData.integrationName}}" />
66+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
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+
</actionGroup>
70+
71+
<!-- Last invalid current password save integration attempt and check logout error -->
72+
<actionGroup ref="AdminNewIntegrationRequiredFieldsActionGroup" stepKey="failedSaveIntegrationLastAttempt">
73+
<argument name="integrationName" value="{{AdminNewIntegrationData.integrationName}}" />
74+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
75+
<argument name="messageSelector" value="{{AdminLoginFormSection.error}}" />
76+
<argument name="message" value="Your account is temporarily disabled. Please try again later." />
77+
</actionGroup>
78+
79+
<!-- Try to login as admin and check error -->
80+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsLockedAdmin"/>
81+
<waitForPageLoad stepKey="waitForError"/>
82+
<see selector="{{AdminLoginFormSection.error}}" userInput="The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later"
83+
stepKey="seeLoginUserError"/>
84+
</test>
85+
</tests>

0 commit comments

Comments
 (0)