You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: mftf/2.3/credentials.md
+51-49Lines changed: 51 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,16 @@
3
3
4
4
# Credentials
5
5
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.
7
7
8
8
## Define sensitive data in `.credentials`
9
9
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.
12
12
13
-
To make the file with credentials visible for the MFTF, copy the `.credentials.example` to ``.credentials` while you are in the `<magentoroot>/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:
14
16
15
17
```bash
16
18
cd dev/tests/acceptance/
@@ -20,7 +22,9 @@ cd dev/tests/acceptance/
20
22
cp .credentials.example .credentials
21
23
```
22
24
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):
24
28
25
29
```bash
26
30
git check-ignore .credentials
@@ -32,65 +36,63 @@ The command outputs the path if the file is excluded:
32
36
.credentials
33
37
```
34
38
39
+
### Define sensitive data
40
+
35
41
Open the file, uncomment the fields you want to use, and add your values:
36
42
37
43
```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=
43
52
....
44
53
```
45
54
46
-
## Use credentials in test
55
+
{: .bs-callout .bs-callout-info }
56
+
The `/` symbol is not supported in a key name.
47
57
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.
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
78
86
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.
82
91
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 %}-->
90
93
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:
_This topic was updated due to the {{page.mftf-release}} MFTF release._
9
9
{: style="text-align: right"}
10
10
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.
15
12
The following diagram shows the XML structure of an MFTF data object:
16
13
17
14
{%include_relative img/data-dia.svg%}
18
15
19
-
### Supply data to test by reference to a data entity
16
+
## Supply data to test by reference to a data entity
17
+
20
18
{%raw%}
21
19
Test steps requiring `<data>` input in an action, like filling a field with a string, may reference an attribute from a data entity:
22
20
@@ -29,8 +27,7 @@ In this example:
29
27
*`SimpleSubCategory` is an entity name.
30
28
*`name` is a `<data>` key of the entity. The corresponding value will be assigned to `userInput` as a result.
31
29
32
-
****
33
-
#### Environmental data
30
+
### Environmental data
34
31
35
32
```xml
36
33
userInput="{{_ENV.MAGENTO_ADMIN_USERNAME}}"
@@ -40,23 +37,24 @@ In this example:
40
37
41
38
*`_ENV` is a reference to the `dev/tests/acceptance/.env` file, where basic environment variables are set.
42
39
*`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.
44
41
45
-
####Sensitive data
42
+
### Sensitive data
46
43
47
44
```xml
48
-
userInput="{{_CREDS.MY_SECRET_TOKEN}}"
45
+
userInput="{{_CREDS.my_secret_token}}"
49
46
```
50
47
51
48
In this example:
52
49
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.
54
51
*`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.
58
54
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
60
58
61
59
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.
62
60
@@ -84,7 +82,8 @@ The current scope is preferred, then widening to _test > hook > suite_ or _hook
84
82
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.'
85
83
%}
86
84
87
-
### Use data returned by test actions
85
+
## Use data returned by test actions
86
+
88
87
{%raw%}
89
88
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>`.
90
89
@@ -97,7 +96,7 @@ The following example shows the usage of `grabValueFrom` in testing, where the r
0 commit comments