Skip to content

Commit 353ed19

Browse files
author
Dmitry Tsymbal
committed
Admin Reset Password With Enabled Captcha
1 parent 1d1e97f commit 353ed19

File tree

5 files changed

+146
-0
lines changed

5 files changed

+146
-0
lines changed
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminFillCaptchaOnResetPasswordFormActionGroup">
12+
<arguments>
13+
<argument name="captcha" type="string"/>
14+
</arguments>
15+
<fillField userInput="{{captcha}}" selector="{{AdminResetPasswordFormSection.captchaField}}" stepKey="fillCaptchaField"/>
16+
</actionGroup>
17+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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="AssertCaptchaVisibleOnAdminResetPasswordFormActionGroup">
12+
<waitForElementVisible selector="{{AdminResetPasswordFormSection.captchaField}}" stepKey="waitToSeeCaptchaField"/>
13+
<waitForElementVisible selector="{{AdminResetPasswordFormSection.captchaImg}}" stepKey="waitToSeeCaptchaImage"/>
14+
<waitForElementVisible selector="{{AdminResetPasswordFormSection.captchaReload}}" stepKey="waitToSeeCaptchaReloadButton"/>
15+
<reloadPage stepKey="refreshPage"/>
16+
<waitForPageLoad stepKey="waitForPageReloaded"/>
17+
<waitForElementVisible selector="{{AdminResetPasswordFormSection.captchaField}}" stepKey="waitToSeeCaptchaFieldAfterPageReload"/>
18+
<waitForElementVisible selector="{{AdminResetPasswordFormSection.captchaImg}}" stepKey="waitToSeeCaptchaImageAfterPageReload"/>
19+
<waitForElementVisible selector="{{AdminResetPasswordFormSection.captchaReload}}" stepKey="waitToSeeCaptchaReloadButtonAfterPageReload"/>
20+
</actionGroup>
21+
</actionGroups>

app/code/Magento/Captcha/Test/Mftf/Data/CaptchaConfigData.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,31 @@
139139
<data key="label">ABCDEFGHJKMnpqrstuvwxyz23456789</data>
140140
<data key="value">ABCDEFGHJKMnpqrstuvwxyz23456789</data>
141141
</entity>
142+
<entity name="AdminCaptchaForgotPasswordFormConfigData">
143+
<!-- Magento default value -->
144+
<data key="path">admin/captcha/forms</data>
145+
<data key="scope_id">1</data>
146+
<data key="label">Admin Forgot Password</data>
147+
<data key="value">backend_forgotpassword</data>
148+
</entity>
149+
<entity name="AdminCaptchaDisplayModeConfigData">
150+
<data key="path">admin/captcha/mode</data>
151+
<data key="scope_id">1</data>
152+
<data key="label">Always</data>
153+
<data key="value">always</data>
154+
</entity>
155+
<entity name="AdminCaptchaDefaultDisplayModeConfigData">
156+
<!-- Magento default value -->
157+
<data key="path">admin/captcha/mode</data>
158+
<data key="scope_id">0</data>
159+
<data key="label">After number of attempts to login</data>
160+
<data key="value">after_fail</data>
161+
</entity>
162+
<entity name="AdminCaptchaAdminLoginFormConfigData">
163+
<!-- Magento default value -->
164+
<data key="path">admin/captcha/forms</data>
165+
<data key="scope_id">1</data>
166+
<data key="label">AdminLogin</data>
167+
<data key="value">backend_login</data>
168+
</entity>
142169
</entities>
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="AdminResetPasswordFormSection">
12+
<element name="captchaField" type="input" selector="#login-form input[name='captcha[backend_forgotpassword]']"/>
13+
<element name="captchaImg" type="block" selector="#login-form img#backend_forgotpassword"/>
14+
<element name="captchaReload" type="block" selector="#login-form img#captcha-reload.captcha-reload"/>
15+
</section>
16+
</sections>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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="AdminResetUserPasswordWithEnabledCaptchaTest">
12+
<annotations>
13+
<features value="captcha"/>
14+
<stories value="Password Reset procedure for Admin Panel"/>
15+
<title value="Admin user reset password with enabled captcha "/>
16+
<description value="Admin user should be able reset the password with enabled captcha"/>
17+
<severity value="MAJOR"/>
18+
<group value="captcha"/>
19+
</annotations>
20+
<before>
21+
<magentoCLI command="config:set {{AdminCaptchaLength3ConfigData.path}} {{AdminCaptchaLength3ConfigData.value}}" stepKey="setCaptchaLength"/>
22+
<magentoCLI command="config:set {{AdminCaptchaSymbols1ConfigData.path}} {{AdminCaptchaSymbols1ConfigData.value}}" stepKey="setCaptchaSymbols"/>
23+
<magentoCLI command="config:set {{AdminCaptchaForgotPasswordFormConfigData.path}} {{AdminCaptchaForgotPasswordFormConfigData.value}}" stepKey="enableResetPasswordCaptcha"/>
24+
<magentoCLI command="config:set {{AdminCaptchaDisplayModeConfigData.path}} {{AdminCaptchaDisplayModeConfigData.value}}" stepKey="setCaptchaAlwaysVisible"/>
25+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCaches">
26+
<argument name="tags" value="config full_page"/>
27+
</actionGroup>
28+
</before>
29+
30+
<after>
31+
<magentoCLI command="config:set {{AdminCaptchaDefaultLengthConfigData.path}} {{AdminCaptchaDefaultLengthConfigData.value}}" stepKey="setDefaultCaptchaLength"/>
32+
<magentoCLI command="config:set {{AdminCaptchaDefaultSymbolsConfigData.path}} {{AdminCaptchaDefaultSymbolsConfigData.value}}" stepKey="setDefaultCaptchaSymbols"/>
33+
<magentoCLI command="config:set {{AdminCaptchaDefaultDisplayModeConfigData.path}} {{AdminCaptchaDefaultDisplayModeConfigData.value}}" stepKey="setCaptchaDefaultVisibility"/>
34+
<magentoCLI command="config:set {{AdminCaptchaForgotPasswordFormConfigData.path}} {{AdminCaptchaForgotPasswordFormConfigData.value}},{{AdminCaptchaAdminLoginFormConfigData.value}}" stepKey="setDefaultCaptchaValuesOnForms"/>
35+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCaches">
36+
<argument name="tags" value="config full_page"/>
37+
</actionGroup>
38+
</after>
39+
40+
<actionGroup ref="AdminOpenForgotPasswordPageActionGroup" stepKey="openAdminForgotPasswordPage"/>
41+
<actionGroup ref="AssertCaptchaVisibleOnAdminResetPasswordFormActionGroup" stepKey="assertCaptchaVisible"/>
42+
<actionGroup ref="AdminFillForgotPasswordFormActionGroup" stepKey="fillAdminForgotPasswordForm">
43+
<argument name="email" value="{{inactiveAdmin.email}}"/>
44+
</actionGroup>
45+
<actionGroup ref="AdminFillCaptchaOnResetPasswordFormActionGroup" stepKey="fillCaptchaWithInvalidValues">
46+
<argument name="captcha" value="{{WrongCaptcha.value}}"/>
47+
</actionGroup>
48+
<actionGroup ref="AdminSubmitForgotPasswordFormActionGroup" stepKey="submitAdminForgotPasswordForm"/>
49+
<actionGroup ref="AssertMessageOnAdminLoginActionGroup" stepKey="seeErrorMessage">
50+
<argument name="messageType" value="error"/>
51+
<argument name="message" value="Incorrect CAPTCHA"/>
52+
</actionGroup>
53+
<actionGroup ref="AdminFillForgotPasswordFormActionGroup" stepKey="fillEmailOnAdminForgotPasswordForm">
54+
<argument name="email" value="{{inactiveAdmin.email}}"/>
55+
</actionGroup>
56+
<actionGroup ref="AdminFillCaptchaOnResetPasswordFormActionGroup" stepKey="fillCaptchaWithCorrectValues">
57+
<argument name="captcha" value="{{PreconfiguredCaptcha.value}}"/>
58+
</actionGroup>
59+
<actionGroup ref="AdminSubmitForgotPasswordFormActionGroup" stepKey="submitAdminForgotPasswordFormWithCorrectCaptcha"/>
60+
<actionGroup ref="AssertMessageOnAdminLoginActionGroup" stepKey="seeSuccessMessage">
61+
<argument name="messageType" value="success"/>
62+
<argument name="message" value="We'll email you a link to reset your password."/>
63+
</actionGroup>
64+
</test>
65+
</tests>

0 commit comments

Comments
 (0)