Skip to content

Commit bb03bcf

Browse files
Refactoring
1 parent eee6472 commit bb03bcf

File tree

10 files changed

+148
-98
lines changed

10 files changed

+148
-98
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminNotSuccessLoginActionGroup">
12+
<arguments>
13+
<argument name="message" type="string" defaultValue="The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later"/>
14+
</arguments>
15+
<waitForPageLoad stepKey="waitForPageReload"/>
16+
<see selector="{{AdminLoginFormSection.error}}" userInput="{{message}}"
17+
stepKey="seeLoginAdminError"/>
18+
</actionGroup>
19+
</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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertMessageOnBackendActionGroup">
12+
<arguments>
13+
<argument name="message" type="string" defaultValue="The password entered for the current user is invalid. Verify the password and try again." />
14+
<argument name="messageType" type="string" defaultValue="error" />
15+
</arguments>
16+
<see userInput="{{message}}" selector="{{AdminMessagesSection.messageByType(messageType)}}" stepKey="verifyMessage" />
17+
</actionGroup>
18+
</actionGroups>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
<element name="nthSuccess" type="text" selector=".message.message-success.success:nth-of-type({{n}})>div" parameterized="true"/>
1414
<element name="error" type="text" selector="#messages div.message-error"/>
1515
<element name="notice" type="text" selector=".message.message-notice.notice"/>
16+
<element name="messageByType" type="text" selector="#messages div.message-{{messageType}}" parameterized="true" />
1617
</section>
1718
</sections>

app/code/Magento/Security/Test/Mftf/ActionGroup/AdminNewIntegrationRequiredFieldsActionGroup.xml renamed to app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminFillIntegrationRequiredFieldsActionGroup.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,13 @@
77
-->
88
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10-
<actionGroup name="AdminNewIntegrationRequiredFieldsActionGroup">
10+
<actionGroup name="AdminFillIntegrationRequiredFieldsActionGroup">
1111
<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}}" />
12+
<argument name="integrationName" type="string" defaultValue="{{IntegrationData.name}}"/>
13+
<argument name="currentAdminPassword" type="string" defaultValue="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" />
1614
</arguments>
17-
<!-- Fill all Required Fields. -->
1815
<fillField selector="{{AdminNewIntegrationSection.integrationName}}" userInput="{{integrationName}}" stepKey="fillIntegrationName"/>
1916
<fillField selector="{{AdminNewIntegrationSection.currentPassword}}" userInput="{{currentAdminPassword}}" stepKey="fillCurrentUserPassword"/>
2017
<scrollToTopOfPage stepKey="ScrollToTopOfPage"/>
21-
<click selector="{{AdminNewIntegrationSection.save}}" stepKey="saveNewIntegration"/>
22-
<waitForPageLoad stepKey="waitForSaveResultLoad"/>
23-
<see userInput="{{message}}" selector="{{messageSelector}}" stepKey="verifyMessage" />
2418
</actionGroup>
2519
</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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenNewIntegrationPageActionGroup">
11+
<amOnPage url="{{AdminNewIntegrationPage.url}}" stepKey="amOnNewAdminIntegrationPage"/>
12+
<waitForPageLoad stepKey="waitForNewAdminIntegrationPageLoad"/>
13+
</actionGroup>
14+
</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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertSaveIntegrationActionGroup">
11+
<click selector="{{AdminNewIntegrationSection.save}}" stepKey="saveIntegration"/>
12+
<waitForPageLoad stepKey="waitForSaveResultLoad"/>
13+
</actionGroup>
14+
</actionGroups>

app/code/Magento/Integration/Test/Mftf/Data/AdminNewIntegrationData.xml renamed to app/code/Magento/Integration/Test/Mftf/Data/IntegrationData.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11-
<entity name="AdminNewIntegrationData" type="admin">
12-
<data key="integrationName" unique="prefix">_Integration</data>
11+
<entity name="IntegrationData" type="admin">
12+
<data key="name" unique="prefix">_Integration</data>
1313
</entity>
1414
</entities>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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="AdminLockAdminUserWhenCreatingNewIntegrationTest">
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+
<actionGroup ref="AdminOpenNewIntegrationPageActionGroup" stepKey="openNewIntegrationPage"/>
31+
<!-- Perform add new admin user 6 specified number of times.
32+
"The password entered for the current user is invalid. Verify the password and try again." appears after each attempt.-->
33+
<actionGroup ref="AdminFillIntegrationRequiredFieldsActionGroup" stepKey="fillFieldFirstAttempt">
34+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
35+
</actionGroup>
36+
<actionGroup ref="AssertSaveIntegrationActionGroup" stepKey="saveIntegrationFirstAttempt"/>
37+
<actionGroup ref="AssertMessageOnBackendActionGroup" stepKey="checkFirstSaveIntegrationError"/>
38+
39+
<actionGroup ref="AdminFillIntegrationRequiredFieldsActionGroup" stepKey="fillFieldSecondAttempt">
40+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
41+
</actionGroup>
42+
<actionGroup ref="AssertSaveIntegrationActionGroup" stepKey="saveIntegrationSecondAttempt"/>
43+
<actionGroup ref="AssertMessageOnBackendActionGroup" stepKey="checkSecondSaveIntegrationError"/>
44+
45+
<actionGroup ref="AdminFillIntegrationRequiredFieldsActionGroup" stepKey="fillFieldThirdAttempt">
46+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
47+
</actionGroup>
48+
<actionGroup ref="AssertSaveIntegrationActionGroup" stepKey="saveIntegrationThirdAttempt"/>
49+
<actionGroup ref="AssertMessageOnBackendActionGroup" stepKey="checkThirdSaveIntegrationError"/>
50+
51+
<actionGroup ref="AdminFillIntegrationRequiredFieldsActionGroup" stepKey="fillFieldFourthAttempt">
52+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
53+
</actionGroup>
54+
<actionGroup ref="AssertSaveIntegrationActionGroup" stepKey="saveIntegrationFourthAttempt"/>
55+
<actionGroup ref="AssertMessageOnBackendActionGroup" stepKey="checkFourthSaveIntegrationError"/>
56+
57+
<actionGroup ref="AdminFillIntegrationRequiredFieldsActionGroup" stepKey="fillFieldFifthAttempt">
58+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
59+
</actionGroup>
60+
<actionGroup ref="AssertSaveIntegrationActionGroup" stepKey="saveIntegrationFifthAttempt"/>
61+
<actionGroup ref="AssertMessageOnBackendActionGroup" stepKey="checkFifthSaveIntegrationError"/>
62+
63+
<!-- Last invalid current password save integration attempt and check logout error -->
64+
<actionGroup ref="AdminFillIntegrationRequiredFieldsActionGroup" stepKey="fillFieldLastAttempt">
65+
<argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID" />
66+
</actionGroup>
67+
<actionGroup ref="AssertSaveIntegrationActionGroup" stepKey="saveIntegrationLastAttempt"/>
68+
<actionGroup ref="AssertAdminNotSuccessLoginActionGroup" stepKey="checkFifthError">
69+
<argument name="message" value="Your account is temporarily disabled. Please try again later."/>
70+
</actionGroup>
71+
72+
<!-- Try to login as admin and check error -->
73+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsLockedAdmin"/>
74+
<actionGroup ref="AssertAdminNotSuccessLoginActionGroup" stepKey="checkLoginError"/>
75+
</test>
76+
</tests>

app/code/Magento/Security/Test/Mftf/Test/LockAdminUserWhenCreatingNewIntegrationTest.xml

Lines changed: 0 additions & 85 deletions
This file was deleted.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
99
<testCase name="Magento\Security\Test\TestCase\LockAdminUserWhenCreatingNewIntegrationTest" summary="Lock admin user after entering incorrect password while creating new integration">
1010
<variation name="LockAdminUserWhenCreatingNewIntegrationTestVariation1">
11-
<data name="tag" xsi:type="string">severity:S2</data>
11+
<data name="tag" xsi:type="string">severity:S2, mftf_migrated:yes</data>
1212
<data name="configData" xsi:type="string">user_lockout_failures</data>
1313
<data name="customAdmin/dataset" xsi:type="string">custom_admin_with_default_role</data>
1414
<data name="integration/data/name" xsi:type="string">Integration%isolation%</data>
@@ -18,7 +18,6 @@
1818
<data name="integration/data/current_password" xsi:type="string">incorrect password</data>
1919
<data name="integration/data/resource_access" xsi:type="string">All</data>
2020
<data name="attempts" xsi:type="string">4</data>
21-
<data name="tag" xsi:type="string">mftf_migrated:yes</data>
2221
<constraint name="Magento\Security\Test\Constraint\AssertUserIsLocked" />
2322
</variation>
2423
</testCase>

0 commit comments

Comments
 (0)