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

Commit 406029b

Browse files
committed
Finished the working draft
1 parent 7323903 commit 406029b

File tree

2 files changed

+67
-66
lines changed

2 files changed

+67
-66
lines changed

mftf/2.3/credentials.md

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33

44
# Credentials
55

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.
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

88
## Define sensitive data in `.credentials`
99

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.
10+
The MFTF creates a sample file for credentials during [initial setup][]: `magento2/dev/tests/acceptance/.credentials.example`.
11+
The file contains an example list of keys for fields that can require credentials.
1212

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:
13+
### Create `.credentials`
14+
15+
To make the MFTF to process the file with credentials, copy `.credentials.example` to `.credentials` while you are at the `magento2/dev/tests/acceptance/` directory:
1416

1517
```bash
1618
cd dev/tests/acceptance/
@@ -20,7 +22,9 @@ cd dev/tests/acceptance/
2022
cp .credentials.example .credentials
2123
```
2224

23-
Verify whether the file is excluded from tracking by `.gitignore` (unless you need this behavior):
25+
### Add `.credentials` to `.gitignore`
26+
27+
Verify that the file is excluded from tracking by `.gitignore` (unless you need this behavior):
2428

2529
```bash
2630
git check-ignore .credentials
@@ -32,65 +36,63 @@ The command outputs the path if the file is excluded:
3236
.credentials
3337
```
3438

39+
### Define sensitive data
40+
3541
Open the file, uncomment the fields you want to use, and add your values:
3642

3743
```config
38-
carriers/usps/userid=test_user
39-
carriers/usps/password=Lmgxvrq89uPwECeV
40-
41-
#carriers_dhl_id_us=
42-
#carriers_dhl_password_us=
44+
...
45+
# Credentials for the USPS service
46+
carriers_usps_userid=test_user
47+
carriers_usps_password=Lmgxvrq89uPwECeV
48+
49+
# Credentials for the DHL service
50+
#carriers/dhl/id_us=
51+
#carriers/dhl/password_us=
4352
....
4453
```
4554

46-
## Use credentials in test
55+
{: .bs-callout .bs-callout-info }
56+
The `/` symbol is not supported in a key name.
4757

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:
58+
You are free to use any other keys you like, as they are merely the keys to reference from your tests.
5059

51-
```xml
52-
<fillField stepKey="FillAPIUsername" selector=".username" userInput="{{_CREDS.PAYMENTUSER}}"/>
53-
<fillField stepKey="FillAPIPassword" selector=".password" userInput="{{_CREDS.PAYMENTPASSWORD}}"/>
54-
```
60+
```conf
61+
# Credentials for the MyAwesome service
62+
my_awesome_service_token=rRVSVnh3cbDsVG39oTMz4A
5563
64+
# Credentials for the USPS service
65+
carriers_usps_userid=test_user
66+
carriers_usps_password=Lmgxvrq89uPwECeV
67+
....
68+
```
5669

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.
70+
## Use credentials in test
5871

59-
The MFTF enables you to store credentials for external services in the `.credentials` file which is
60-
The template file is `.credentials.example`.
72+
<!--{% raw %}-->
73+
Access the data defined in the `.credentials` file using the [`fillField`][] action with the `userInput` attribute.
74+
Define the value as a reference to the corresponding key in the credentials file such as `{{_CREDS.my_data_key}}`:
6175

76+
- `_CREDS` is an environment constant pointing to the `.credentials` file
77+
- `my_data_key` is a key in the the `.credentials` file that contains the value to be used in a test step
6278

79+
For example:
6380

64-
1. When do I need people would need credentials in the MFTF?
65-
- Credentials are used for when you need to input an integration token or other security credential via a `fillField`.
66-
- You shouldn't have security tokens checked in to any repo, so storing it in a DATA.xml file is a bad idea
67-
- Furthermore, if you used data.xml, the Allure Report would show your security token like:
68-
I fill field "SECURITYTOKEN".
69-
- Use of {{_CREDS.TOKEN}} turns a `fillField` action into `fillSecretField` which scrubs the allure report.
81+
```xml
82+
<fillField stepKey="FillApiToken" selector=".api-token" userInput="{{_CREDS.my_data_key}}" />
83+
```
7084

71-
2. What functionality does the MFTF credentials feature cover?
72-
- How to store credentials
73-
- build:project copies over .credentials.example, copy and remove the `.example`
74-
- Store new credentials in a new line as `KEY=VALUE`
75-
- How to use Credentials in test actions
76-
- In fillField actions, you can reference it as {{_CREDS.KEY}}
77-
- data.md has info on this, check out "Sensitive Data"
85+
## Implementations details
7886

79-
3. How to implement credentials in test design?
80-
- Credentials should only every be used if you have the need to connect to some external integration for your test
81-
- 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.
87+
The generated tests does not contain credentials values.
88+
The MFTF dynamically retrieves, encrypts, and decrypts the sensitive data during test execution.
89+
Decrypted credentials do not appear in the console, error logs, or [test reports][].
90+
The decrypted values are only available in the `.credentials` file.
8291

83-
4. How to setup credentials?
84-
- build:project copies over .credentials.example, copy and remove the `.example`
85-
- Store new credentials in a new line as
86-
- KEY=VALUE
87-
- You CANNOT check in the .credentials file
88-
- For Magneto Devs, DevOps is still working on the solution of how to store credentials to be used in a build enviroment
89-
- For outside Devs, they can store the credentials and build their own .credentials file as part of build steps
92+
<!--{% endraw %}-->
9093

91-
5. Examples of daily routine tasks using credentials in the MFTF.
92-
- 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.
93-
- I need to use the credentials to my Sandbox Environment, but I don't want those visible in the Allure Report:
94-
- <fillField stepKey="FillAPIUsername" selector=".username" userInput="{{_CREDS.PAYMENTUSER}}"/>
95-
- <fillField stepKey="FillAPIPassword" selector=".password" userInput="{{_CREDS.PAYMENTPASSWORD}}"/>
96-
94+
<!-- Link definitions -->
95+
[`fillField`]: test/actions.html#fillfield
96+
[data]: data.html
97+
[initial setup]: getting-started.html
98+
[test reports]: reporting.html

mftf/2.3/data.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ redirect_from: /guides/v2.3/magento-functional-testing-framework/2.3/data.html
88
_This topic was updated due to the {{page.mftf-release}} MFTF release._
99
{: style="text-align: right"}
1010

11-
Tests require data to function properly.
12-
13-
The MFTF allows you to specify and use `<data>` entities defined in XML. Default `<data>` entities are provided for use and as templates for entity creation and manipulation.
14-
11+
The MFTF enables you to specify and use `<data>` entities defined in XML. Default `<data>` entities are provided for use and as templates for entity creation and manipulation.
1512
The following diagram shows the XML structure of an MFTF data object:
1613

1714
{%include_relative img/data-dia.svg%}
1815

19-
### Supply data to test by reference to a data entity
16+
## Supply data to test by reference to a data entity
17+
2018
{%raw%}
2119
Test steps requiring `<data>` input in an action, like filling a field with a string, may reference an attribute from a data entity:
2220

@@ -29,8 +27,7 @@ In this example:
2927
* `SimpleSubCategory` is an entity name.
3028
* `name` is a `<data>` key of the entity. The corresponding value will be assigned to `userInput` as a result.
3129

32-
****
33-
#### Environmental data
30+
### Environmental data
3431

3532
```xml
3633
userInput="{{_ENV.MAGENTO_ADMIN_USERNAME}}"
@@ -40,23 +37,24 @@ In this example:
4037

4138
* `_ENV` is a reference to the `dev/tests/acceptance/.env` file, where basic environment variables are set.
4239
* `MAGENTO_ADMIN_USERNAME` is a name of an environment variable.
43-
The corresponding value will be assigned to `userInput` as a result.
40+
The corresponding value will be assigned to `userInput` as a result.
4441

45-
#### Sensitive data
42+
### Sensitive data
4643

4744
```xml
48-
userInput="{{_CREDS.MY_SECRET_TOKEN}}"
45+
userInput="{{_CREDS.my_secret_token}}"
4946
```
5047

5148
In this example:
5249

53-
* `_CREDS` is a reference to the `dev/tests/acceptance/.credentials` file, where sensitive data and secrets are stored for use in a test.
50+
* `_CREDS` is a constant to reference to the `dev/tests/acceptance/.credentials` file, where sensitive data and secrets are stored for use in a test.
5451
* `MY_SECRET_TOKEN` is the name of a key in the credentials variable.
55-
The corresponding value of the credential will be assigned to `userInput` as a result.
56-
* Credential values are not generated into a test. Instead, they are dynamically retrieved, encrypted and decrypted when used by a specific action during the test's execution.
57-
* References to credentials do not appear decrypted in the console, error logs or test reports, their values can only be seen decrypted in the .credentials file in which they are stored.
52+
The corresponding value of the credential will be assigned to `userInput` as a result.
53+
* The decrypted values are only available in the `.credentials` file in which they are stored.
5854

59-
### Persist a data entity as a prerequisite of a test
55+
Learn more in [Credentials][].
56+
57+
## Persist a data entity as a prerequisite of a test
6058

6159
A test can specify an entity to be persisted (created in the database) so that the test actions could operate on the existing known data.
6260

@@ -84,7 +82,8 @@ The current scope is preferred, then widening to _test > hook > suite_ or _hook
8482
This emphasizes the practice for the `stepKey` of `createData` to be descriptive and unique, as a duplicated `stepKey` in both a `<test>` and `<before>` prefers the `<test>` data.'
8583
%}
8684

87-
### Use data returned by test actions
85+
## Use data returned by test actions
86+
8887
{%raw%}
8988
A test can also reference data that was returned as a result of [test actions](./test/actions.html#actions-returning-a-variable), like the action `<grabValueFrom selector="someSelector" stepKey="grabStepKey>`.
9089

@@ -97,7 +96,7 @@ The following example shows the usage of `grabValueFrom` in testing, where the r
9796
<fillField selector=".functionalTestSelector" userInput="{$grabStepKey}" stepKey="fillFieldKey1"/>
9897
```
9998

100-
### Hard-coded data input
99+
## Hard-coded data input
101100

102101
The data to operate against can be included as literals in a test. Hard-coded data input can be useful in assertions.
103102

0 commit comments

Comments
 (0)