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
When you test functionality that involves external services such as UPS, FedEx, PayPal, or SignifyD, use the MFTF credentials feature to hide sensitive [data][] like integration tokens and API keys.
3
+
When you test functionality that involves external services such as UPS, FedEx, PayPal, or SignifyD,
4
+
use the MFTF credentials feature to hide sensitive [data][] like integration tokens and API keys.
4
5
5
-
## Define sensitive data in `.credentials`
6
+
Currently the MFTF supports two types of credential storage:
7
+
8
+
-**.credentials file**
9
+
-**HashiCorp vault**
10
+
11
+
## Configure File Storage
6
12
7
13
The MFTF creates a sample file for credentials during [initial setup][]: `magento2/dev/tests/acceptance/.credentials.example`.
8
14
The file contains an example list of keys for fields that can require credentials.
9
15
10
16
### Create `.credentials`
11
17
12
-
To make the MFTF process the file with credentials, change directories to `magento2/dev/tests/acceptance/` and copy`.credentials.example` to `.credentials`.
18
+
To make the MFTF process the file with credentials, in the command line, navigate to `magento2/dev/tests/acceptance/` and rename`.credentials.example` to `.credentials`.
13
19
14
20
```bash
15
21
cd dev/tests/acceptance/
@@ -33,49 +39,119 @@ The command outputs the path if the file is excluded:
33
39
.credentials
34
40
```
35
41
36
-
### Define sensitive data
42
+
### Define sensitive data in the `.credentials` file
37
43
38
-
Open the `.credentials` file, uncomment the fields you want to use, and add your values:
44
+
Open the `.credentials` file and, for Magento core credentials, uncomment the fields you want to use and add your values:
39
45
40
-
```config
46
+
```conf
41
47
...
42
48
# Credentials for the USPS service
43
-
carriers_usps_userid=test_user
44
-
carriers_usps_password=Lmgxvrq89uPwECeV
49
+
magento/carriers_usps_userid=usps_test_user
50
+
magento/carriers_usps_password=Lmgxvrq89uPwECeV
45
51
46
52
# Credentials for the DHL service
47
-
#carriers/dhl/id_us=
48
-
#carriers/dhl/password_us=
53
+
#magento/carriers_dhl_id_us=dhl_test_user
54
+
#magento/carriers_dhl_password_us=Mlgxv3dsagVeG
49
55
....
56
+
```
57
+
58
+
Or add new key & value pairs for your own credentials. The keys use the following format:
Hashicorp vault secures, stores, and tightly controls access to data in modern computing.
78
+
It provides advanced data protection for your testing credentials.
79
+
80
+
The MFTF works with both `vault enterprise` and `vault open source` that use `KV Version 2` secret engine.
81
+
82
+
### Install vault CLI
83
+
84
+
Download and install vault CLI tool if you want to run or develop MFTF tests locally. [Download Vault][Download Vault]
85
+
86
+
### Authenticate to vault via vault CLI
87
+
88
+
Authenticate to vault server via the vault CLI tool: [Login Vault][Login Vault].
89
+
90
+
```bash
91
+
vault login -method -path
92
+
```
93
+
94
+
**Do not** use `-no-store` command option, as the MFTF will rely on the persisted token in the token helper (usually the local filesystem) for future API requests.
95
+
96
+
### Store secrets in vault
97
+
98
+
The MFTF uses the `KV Version 2` secret engine for secret storage.
99
+
More information for working with `KV Version 2` can be found in [Vault KV2][Vault KV2].
100
+
101
+
#### Secrets path and key convention
102
+
103
+
The path and key for secret data must follow the format:
104
+
105
+
```conf
106
+
<SECRETS_BASE_PATH>/mftf/<VENDOR>/<SECRET_KEY>
107
+
```
108
+
109
+
```conf
110
+
# Secret path and key for carriers_usps_userid
111
+
secret/mftf/magento/carriers_usps_userid
112
+
113
+
# Secret path and key for carriers_usps_password
114
+
secret/mftf/magento/carriers_usps_password
115
+
```
116
+
117
+
#### Write secrets to vault
118
+
119
+
You can use vault CLI or API to write secret data (credentials, etc) to vault. Here is a CLI example:
120
+
121
+
```bash
122
+
vault kv put secret/mftf/magento/carriers_usps_userid carriers_usps_userid=usps_test_user
123
+
vault kv put secret/mftf/magento/carriers_usps_password carriers_usps_password=Lmgxvrq89uPwECeV
66
124
```
67
125
126
+
### Setup MFTF to use vault
127
+
128
+
Add vault configuration environment variables [`CREDENTIAL_VAULT_ADDRESS`][] and [`CREDENTIAL_VAULT_SECRET_BASE_PATH`][]
129
+
from `etc/config/.env.example` in `.env`.
130
+
Set values according to your vault server configuration.
131
+
132
+
```conf
133
+
# Default vault dev server
134
+
CREDENTIAL_VAULT_ADDRESS=http://127.0.0.1:8200
135
+
CREDENTIAL_VAULT_SECRET_BASE_PATH=secret
136
+
```
137
+
138
+
## Configure both File Storage and Vault Storage
139
+
140
+
It is possible and sometimes useful to setup and use both `.credentials` file and vault for secret storage at the same time.
141
+
In this case, the MFTF tests are able to read secret data at runtime from both storage options, but the local `.credentials` file will take precedence.
142
+
68
143
<!-- {% raw %} -->
69
144
70
145
## Use credentials in a test
71
146
72
-
Access the data defined in the `.credentials` file using the [`fillField`][] action with the `userInput` attribute.
73
-
Define the value as a reference to the corresponding key in the credentials file such as `{{_CREDS.my_data_key}}`:
147
+
Credentials can be used in actions: [`fillField`][], [`magentoCLI`][], and [`createData`][].
148
+
149
+
Define the value as a reference to the corresponding key in the credentials file or vault such as `{{_CREDS.my_data_key}}`:
74
150
75
151
-`_CREDS` is an environment constant pointing to the `.credentials` file
76
-
-`my_data_key` is a key in the the `.credentials` file that contains the value to be used in a test step
152
+
-`my_data_key` is a key in the the `.credentials` file or vault that contains the value to be used in a test step
77
153
78
-
For example:
154
+
For example, reference secret data in the [`fillField`][] action with the `userInput` attribute.
0 commit comments