Skip to content

Commit 4343cc9

Browse files
committed
MQE-2122: MFTF 2FA documentation
1 parent ce21f48 commit 4343cc9

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

docs/configure-2fa.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# MFTF Configuration for Magento with Two-Factor Authentication (2FA)
2+
3+
## Configure Magento {#config-magento-2fa}
4+
5+
To prepare Magento for MFTF testing when 2FA is enabled, set the following configurations through Magento CLI
6+
7+
### Select `Google Authenticator` as Magento 2FA provider
8+
9+
```bash
10+
bin/magento config:set twofactorauth/general/force_providers google
11+
```
12+
13+
### Set OTP window to `60` seconds
14+
15+
```bash
16+
bin/magento config:set twofactorauth/google/otp_window 60
17+
```
18+
19+
### Set a base32 encoded `secret` for `Google Authenticator` to generate OTP for the default admin user that you set for `MAGENTO_ADMIN_USERNAME` in .env.
20+
21+
```bash
22+
bin/magento security:tfa:google:set-secret <MAGENTO_ADMIN_USERNAME> <OTP_SHARED_SECRET>
23+
```
24+
25+
## Configure MFTF {#config-mftf-2fa}
26+
27+
Save the same base32 encoded `secret` in MFTF Credential Storages, e.g. `.credentials` file, `HashiCorp Vault` or `AWS Secrets Manager`.
28+
More details [here](../credentials.md).
29+
30+
The path of the `secret` should be:
31+
32+
```conf
33+
magento/tfa/OTP_SHARED_SECRET
34+
```
35+
36+
## GetOTP {#getOTP}
37+
38+
One-time password (OTP) is required when an admin user logs in to Magento Admin page.
39+
Use action `getOTP` [Reference](../test/actions.md#getotp) to generate the code and use it for the `Authenticator code` text field in 2FA - Google Auth page.
40+
41+
Note:
42+
You will need to set the `secret` for any non default admin users first before using `getOTP`. For example
43+
44+
```xml
45+
<magentoCLI command="security:tfa:google:set-secret admin2 {{_CREDS.magento/tfa/OTP_SHARED_SECRET}}" stepKey="setSecret"/>
46+
```

docs/getting-started.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ Clean the cache after changing the configuration values:
109109
bin/magento cache:clean config full_page
110110
```
111111

112+
### Testing with Magento Two-Factor Authentication (2FA) extension {#2fa}
113+
If Magento under test has [Magento Two-Factor Authentication (2FA) extension][] installed and enabled, additional configures are needed to run MFTF tests. Learn more in [Configure MFTF for Magento with Two-Factor Authentication (2FA)](../configure-2fa.md).
114+
112115
### Webserver configuration {#web-server-configuration}
113116

114117
The MFTF does not support executing CLI commands if your web server points to `<MAGE_ROOT_DIR>/pub` directory as recommended in the [Installation Guide][Installation Guide docroot]. For the MFTF to execute the CLI commands, the web server must point to the Magento root directory.
@@ -357,3 +360,4 @@ allure serve dev/tests/_output/allure-results/
357360
[test suite]: suite.html
358361
[Find your MFTF version]: introduction.html#find-your-mftf-version
359362
[Installation Guide docroot]: https://devdocs.magento.com/guides/v2.3/install-gde/tutorials/change-docroot-to-pub.html
363+
[Magento Two-Factor Authentication (2FA) extension]: https://devdocs.magento.com/guides/v2.3/security/two-factor-authentication.html

docs/test/actions.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ The following test actions return a variable:
150150
* [grabTextFrom](#grabtextfrom)
151151
* [grabValueFrom](#grabvaluefrom)
152152
* [executeJS](#executejs)
153+
* [getOTP](#getotp)
153154

154155
Learn more in [Using data returned by test actions](../data.md#use-data-returned-by-test-actions).
155156

@@ -1072,6 +1073,25 @@ The `ProductAttributeOptionGetter` entity must be defined in the corresponding [
10721073

10731074
This action can optionally contain one or more [requiredEntity](#requiredentity) child elements.
10741075

1076+
### getOTP
1077+
1078+
Generate one-time password (OTP) based on a saved `secret` at path `magento/tfa/OTP_SHARED_SECRET` in MFTF credential storages.
1079+
The one-time password (OTP) is returned and accessible through the stepkey.
1080+
1081+
MFTF use TOTP from [Spomky-Labs/otphp](https://github.com/Spomky-Labs/otphp).
1082+
1083+
Attribute|Type|Use|Description
1084+
---|---|---|---
1085+
`stepKey`|string|required| A unique identifier of the action.
1086+
`before`|string|optional| `stepKey` of action that must be executed next.
1087+
`after`|string|optional| `stepKey` of preceding action.
1088+
1089+
#### Example
1090+
1091+
```xml
1092+
<getOTP stepKey="getOtp"/>
1093+
```
1094+
10751095
### grabAttributeFrom
10761096

10771097
See [grabAttributeFrom docs on codeception.com](http://codeception.com/docs/modules/WebDriver#grabAttributeFrom).

0 commit comments

Comments
 (0)