-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathuser-application-password.feature
More file actions
303 lines (248 loc) · 10.2 KB
/
user-application-password.feature
File metadata and controls
303 lines (248 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
Feature: Manage user custom fields
# SQLite requires WordPress 6.0+.
@less-than-php-8.0 @require-mysql
Scenario: User application passwords are disabled for WordPress lower than 5.6
Given a WP install
And I try `wp theme install twentytwenty --activate`
And I run `wp core download --version=5.5 --force`
When I try `wp user application-password create 1 myapp`
Then STDERR should contain:
"""
Error: Requires WordPress 5.6 or greater.
"""
When I try `wp user application-password list 1`
Then STDERR should contain:
"""
Error: Requires WordPress 5.6 or greater.
"""
When I try `wp user application-password get 1 123`
Then STDERR should contain:
"""
Error: Requires WordPress 5.6 or greater.
"""
When I try `wp user application-password delete 1 123`
Then STDERR should contain:
"""
Error: Requires WordPress 5.6 or greater.
"""
@require-wp-5.6
Scenario: User application password CRUD
Given a WP install
When I run `wp user application-password create 1 myapp`
Then STDOUT should not be empty
When I run `wp user application-password list 1`
Then STDOUT should contain:
"""
myapp
"""
When I run `wp user application-password list 1 --name=myapp --field=uuid`
And save STDOUT as {UUID}
And I run `wp user application-password get 1 {UUID}`
Then STDOUT should contain:
"""
myapp
"""
When I try `wp user application-password get 2 {UUID}`
Then STDERR should be:
"""
Error: Invalid user ID, email or login: '2'
"""
And the return code should be 1
When I try `wp user application-password get 1 123`
Then STDERR should be:
"""
Error: No application password found for this user ID and UUID.
"""
And the return code should be 1
When I run `wp user application-password update 1 {UUID} --name=anotherapp`
Then STDOUT should not be empty
When I run `wp user application-password get 1 {UUID}`
Then STDOUT should contain:
"""
anotherapp
"""
Then STDOUT should not contain:
"""
myapp
"""
When I run `wp user application-password delete 1 {UUID}`
Then STDOUT should contain:
"""
Success: Deleted 1 of 1 application password.
"""
When I try `wp user application-password get 1 {UUID}`
Then the return code should be 1
When I run `wp user application-password create 1 myapp1`
And I run `wp user application-password create 1 myapp2`
And I run `wp user application-password create 1 myapp3`
And I run `wp user application-password create 1 myapp4`
And I run `wp user application-password create 1 myapp5`
Then STDOUT should not be empty
When I run `wp user application-password list 1 --format=count`
Then STDOUT should be:
"""
5
"""
When I run `wp user application-password list 1 --name=myapp1 --field=uuid`
And save STDOUT as {UUID1}
And I run `wp user application-password list 1 --name=myapp2 --field=uuid`
And save STDOUT as {UUID2}
When I try `wp user application-password delete 1 {UUID1} {UUID2} nonsense`
Then STDERR should contain:
"""
Warning: Failed to delete UUID nonsense
"""
Then STDOUT should contain:
"""
Success: Deleted 2 of 3 application passwords.
"""
When I run `wp user application-password list 1 --format=count`
Then STDOUT should be:
"""
3
"""
When I run `wp user application-password delete 1 --all`
And I run `wp user application-password list 1 --format=count`
Then STDOUT should be:
"""
0
"""
@require-wp-5.6
Scenario: List user application passwords
Given a WP install
When I run `wp user application-password create 1 myapp1`
Then STDOUT should not be empty
When I run `wp user application-password create 1 myapp2 --app-id=42`
Then STDOUT should not be empty
When I run `wp user application-password list 1 --name=myapp1 --field=uuid`
Then save STDOUT as {UUID1}
When I run `wp user application-password list 1 --name=myapp2 --field=uuid`
Then save STDOUT as {UUID2}
When I run `wp user application-password list 1 --name=myapp1 --field=password`
Then save STDOUT as {HASH1}
When I run `wp user application-password list 1 --name=myapp1 --field=password | sed 's#/#\\\/#g'`
Then save STDOUT as {JSONHASH1}
When I run `wp user application-password list 1 --name=myapp2 --field=password`
Then save STDOUT as {HASH2}
When I run `wp user application-password list 1 --name=myapp2 --field=password | sed 's#/#\\\/#g'`
Then save STDOUT as {JSONHASH2}
When I run `wp user application-password list 1 --name=myapp1 --field=created`
Then save STDOUT as {CREATED1}
When I run `wp user application-password list 1 --name=myapp2 --field=created`
Then save STDOUT as {CREATED2}
When I run `wp user application-password list 1 --format=json`
Then STDOUT should contain:
"""
{"uuid":"{UUID1}","app_id":"","name":"myapp1","password":"{JSONHASH1}","created":{CREATED1},"last_used":null,"last_ip":null}
"""
And STDOUT should contain:
"""
{"uuid":"{UUID2}","app_id":"42","name":"myapp2","password":"{JSONHASH2}","created":{CREATED2},"last_used":null,"last_ip":null}
"""
When I run `wp user application-password list 1 --format=json --fields=uuid,name`
Then STDOUT should contain:
"""
{"uuid":"{UUID1}","name":"myapp1"}
"""
And STDOUT should contain:
"""
{"uuid":"{UUID2}","name":"myapp2"}
"""
When I run `wp user application-password list 1`
Then STDOUT should be a table containing rows:
| uuid | app_id | name | password | created | last_used | last_ip |
| {UUID2} | 42 | myapp2 | {HASH2} | {CREATED2} | | |
| {UUID1} | | myapp1 | {HASH1} | {CREATED1} | | |
When I run `wp user application-password list 1 --fields=uuid,app_id,name`
Then STDOUT should be a table containing rows:
| uuid | app_id | name |
| {UUID2} | 42 | myapp2 |
| {UUID1} | | myapp1 |
When I run `wp user application-password list admin`
Then STDOUT should be a table containing rows:
| uuid | app_id | name | password | created | last_used | last_ip |
| {UUID2} | 42 | myapp2 | {HASH2} | {CREATED2} | | |
| {UUID1} | | myapp1 | {HASH1} | {CREATED1} | | |
When I run `wp user application-password list admin --orderby=created --order=asc`
Then STDOUT should be a table containing rows:
| uuid | app_id | name | password | created | last_used | last_ip |
| {UUID1} | | myapp1 | {HASH1} | {CREATED1} | | |
| {UUID2} | 42 | myapp2 | {HASH2} | {CREATED2} | | |
When I run `wp user application-password list admin --orderby=name --order=asc`
Then STDOUT should be a table containing rows:
| uuid | app_id | name | password | created | last_used | last_ip |
| {UUID1} | | myapp1 | {HASH1} | {CREATED1} | | |
| {UUID2} | 42 | myapp2 | {HASH2} | {CREATED2} | | |
When I run `wp user application-password list admin --orderby=name --order=desc`
Then STDOUT should be a table containing rows:
| uuid | app_id | name | password | created | last_used | last_ip |
| {UUID2} | 42 | myapp2 | {HASH2} | {CREATED2} | | |
| {UUID1} | | myapp1 | {HASH1} | {CREATED1} | | |
When I run `wp user application-password list admin --name=myapp2 --format=json`
Then STDOUT should contain:
"""
myapp2
"""
And STDOUT should not contain:
"""
myapp1
"""
When I run `wp user application-password list admin --field=name`
Then STDOUT should contain:
"""
myapp1
"""
And STDOUT should contain:
"""
myapp2
"""
When I run `wp user application-password list 1 --field=name --app-id=42`
Then STDOUT should be:
"""
myapp2
"""
When I run `wp user application-password list 1 --format=ids --orderby=name --order=asc`
Then STDOUT should be:
"""
{UUID1} {UUID2}
"""
# WordPress 6.8 uses BLAKE2b with wp_fast_hash() / wp_verify_fast_hash() for hashing application passwords.
# See https://make.wordpress.org/core/2025/02/17/wordpress-6-8-will-use-bcrypt-for-password-hashing/
@require-wp-5.6 @less-than-wp-6.8
Scenario: Get particular user application password hash
Given a WP install
When I run `wp user create testuser testuser@example.com --porcelain`
Then STDOUT should be a number
And save STDOUT as {USER_ID}
When I try the previous command again
Then the return code should be 1
Given I run `wp user application-password create {USER_ID} someapp --porcelain`
And save STDOUT as {PASSWORD}
And I run `wp user application-password list {USER_ID} --name=someapp --field=uuid`
And save STDOUT as {UUID}
Given I run `wp user application-password get {USER_ID} {UUID} --field=password | sed 's/\$/\\\$/g'`
And save STDOUT as {HASH}
When I run `wp eval "var_export( wp_check_password( '{PASSWORD}', '{HASH}', {USER_ID} ) );"`
Then STDOUT should contain:
"""
true
"""
@require-wp-6.8
Scenario: Get particular user application password hash
Given a WP install
When I run `wp user create testuser testuser@example.com --porcelain`
Then STDOUT should be a number
And save STDOUT as {USER_ID}
When I try the previous command again
Then the return code should be 1
Given I run `wp user application-password create {USER_ID} someapp --porcelain`
And save STDOUT as {PASSWORD}
And I run `wp user application-password list {USER_ID} --name=someapp --field=uuid`
And save STDOUT as {UUID}
Given I run `wp user application-password get {USER_ID} {UUID} --field=password | sed 's/\$/\\\$/g'`
And save STDOUT as {HASH}
When I run `wp eval "var_export( wp_verify_fast_hash( '{PASSWORD}', '{HASH}', {USER_ID} ) );"`
Then STDOUT should contain:
"""
true
"""