Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 7323903

Browse files
committed
Working draft
1 parent d4bc496 commit 7323903

File tree

1 file changed

+60
-10
lines changed

1 file changed

+60
-10
lines changed

mftf/2.3/credentials.md

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,72 @@
33

44
# Credentials
55

6-
When you need to use credentials in your tests such as an integration token, you can do it whithout exposing the sensitive data in your XML tests.
6+
When you test functionality that involves external services such as UPS, FedEx, PayPal, SignifyD, use the MFTF credentials feature to hide sensitive data like integration tokens, API keys, etc.
77

8+
## Define sensitive data in `.credentials`
89

10+
The MFTF creates a sample file for credentials during [initial setup]: `magento2/dev/tests/acceptance/.credentials.example`.
11+
The file contains a list of fields for credentials you may need.
912

10-
1. Why people would need credentials in the MFTF?
13+
To make the file with credentials visible for the MFTF, copy the `.credentials.example` to ``.credentials` while you are in the `<magento root>/dev/tests/acceptance/` directory:
14+
15+
```bash
16+
cd dev/tests/acceptance/
17+
```
18+
19+
```bash
20+
cp .credentials.example .credentials
21+
```
22+
23+
Verify whether the file is excluded from tracking by `.gitignore` (unless you need this behavior):
24+
25+
```bash
26+
git check-ignore .credentials
27+
```
28+
29+
The command outputs the path if the file is excluded:
30+
31+
```terminal
32+
.credentials
33+
```
34+
35+
Open the file, uncomment the fields you want to use, and add your values:
36+
37+
```config
38+
carriers/usps/userid=test_user
39+
carriers/usps/password=Lmgxvrq89uPwECeV
40+
41+
#carriers_dhl_id_us=
42+
#carriers_dhl_password_us=
43+
....
44+
```
45+
46+
## Use credentials in test
47+
48+
Access data defined in the `.credentials` file using the [`fillField` ][] action with the `userInput` attribute defined in the `{{_CREDS.<your data key>}}` format.
49+
For example:
50+
51+
```xml
52+
<fillField stepKey="FillAPIUsername" selector=".username" userInput="{{_CREDS.PAYMENTUSER}}"/>
53+
<fillField stepKey="FillAPIPassword" selector=".password" userInput="{{_CREDS.PAYMENTPASSWORD}}"/>
54+
```
55+
56+
57+
When you need to use credentials in your tests such as integration token, you can do it without exposing the sensitive data in your XML tests.
58+
59+
The MFTF enables you to store credentials for external services in the `.credentials` file which is
60+
The template file is `.credentials.example`.
61+
62+
63+
64+
1. When do I need people would need credentials in the MFTF?
1165
- Credentials are used for when you need to input an integration token or other security credential via a `fillField`.
1266
- You shouldn't have security tokens checked in to any repo, so storing it in a DATA.xml file is a bad idea
1367
- Furthermore, if you used data.xml, the Allure Report would show your security token like:
1468
I fill field "SECURITYTOKEN".
1569
- Use of {{_CREDS.TOKEN}} turns a `fillField` action into `fillSecretField` which scrubs the allure report.
1670

17-
2. What functionality does the MFTF credentials feauture cover?
71+
2. What functionality does the MFTF credentials feature cover?
1872
- How to store credentials
1973
- build:project copies over .credentials.example, copy and remove the `.example`
2074
- Store new credentials in a new line as `KEY=VALUE`
@@ -26,21 +80,17 @@ When you need to use credentials in your tests such as an integration token, you
2680
- Credentials should only every be used if you have the need to connect to some external integration for your test
2781
- Credentials should NOT be used to store stuff like Username/Password in your sandbox test environment; should be limited to tokens and passwords that would propose a security risk.
2882

29-
3. How to setup cerdentials?
83+
4. How to setup credentials?
3084
- build:project copies over .credentials.example, copy and remove the `.example`
3185
- Store new credentials in a new line as
3286
- KEY=VALUE
3387
- You CANNOT check in the .credentials file
3488
- For Magneto Devs, DevOps is still working on the solution of how to store credentials to be used in a build enviroment
3589
- For outside Devs, they can store the credentials and build their own .credentials file as part of build steps
3690

37-
4. Examples of daily routine tasks using credentials in the MFTF.
91+
5. Examples of daily routine tasks using credentials in the MFTF.
3892
- In my test, I am wanting to test a Payment Method integration. This requires me to add a Payment via the Configuration page in the admin backend.
3993
- I need to use the credentials to my Sandbox Environment, but I don't want those visible in the Allure Report:
4094
- <fillField stepKey="FillAPIUsername" selector=".username" userInput="{{_CREDS.PAYMENTUSER}}"/>
4195
- <fillField stepKey="FillAPIPassword" selector=".password" userInput="{{_CREDS.PAYMENTPASSWORD}}"/>
42-
43-
5. DevOps specific examples.
44-
- DevOps still doesn't have a full integration for adding your own .credentials.
45-
46-
6. Reference documentation like in https://devdocs.magento.com/guides/v2.2/magento-functional-testing-framework/2.3/configuration.html
96+

0 commit comments

Comments
 (0)