@@ -52,3 +52,217 @@ Feature: Refresh the salts in the wp-config.php file
52
52
"""
53
53
{LOGGED_IN_SALT_ORIG}
54
54
"""
55
+
56
+ Scenario : Shuffle specific salts only
57
+ Given a WP install
58
+ When I run `wp config shuffle-salts`
59
+ Then STDOUT should contain:
60
+ """
61
+ Shuffled the salt keys.
62
+ """
63
+ And the wp-config.php file should contain:
64
+ """
65
+ define( 'AUTH_KEY'
66
+ """
67
+ And the wp-config.php file should contain:
68
+ """
69
+ define( 'LOGGED_IN_SALT'
70
+ """
71
+ And the wp-config.php file should contain:
72
+ """
73
+ define( 'NONCE_KEY'
74
+ """
75
+
76
+ When I run `wp config get AUTH_KEY --type=constant`
77
+ Then save STDOUT as {AUTH_KEY_ORIG}
78
+ When I run `wp config get LOGGED_IN_SALT --type=constant`
79
+ Then save STDOUT as {LOGGED_IN_SALT_ORIG}
80
+ When I run `wp config get NONCE_KEY --type=constant`
81
+ Then save STDOUT as {NONCE_KEY_ORIG}
82
+
83
+ When I run `wp config shuffle-salts AUTH_KEY NONCE_KEY`
84
+ Then STDOUT should contain:
85
+ """
86
+ Shuffled the salt keys.
87
+ """
88
+ And the wp-config.php file should not contain:
89
+ """
90
+ {AUTH_KEY_ORIG}
91
+ """
92
+ And the wp-config.php file should contain:
93
+ """
94
+ {LOGGED_IN_SALT_ORIG}
95
+ """
96
+ And the wp-config.php file should not contain:
97
+ """
98
+ {NONCE_KEY_ORIG}
99
+ """
100
+
101
+ @require-php-7.0
102
+ Scenario : Force adding missing salts to shuffle
103
+ Given a WP install
104
+ When I run `wp config shuffle-salts`
105
+ Then STDOUT should contain:
106
+ """
107
+ Shuffled the salt keys.
108
+ """
109
+ And the wp-config.php file should contain:
110
+ """
111
+ define( 'AUTH_KEY'
112
+ """
113
+ And the wp-config.php file should contain:
114
+ """
115
+ define( 'LOGGED_IN_SALT'
116
+ """
117
+ And the wp-config.php file should not contain:
118
+ """
119
+ define( 'NEW_KEY'
120
+ """
121
+
122
+ When I run `wp config get AUTH_KEY --type=constant`
123
+ Then save STDOUT as {AUTH_KEY_ORIG}
124
+ When I run `wp config get LOGGED_IN_SALT --type=constant`
125
+ Then save STDOUT as {LOGGED_IN_SALT_ORIG}
126
+
127
+ When I try `wp config shuffle-salts AUTH_KEY NEW_KEY`
128
+ Then STDOUT should contain:
129
+ """
130
+ Shuffled the salt keys.
131
+ """
132
+ And STDERR should contain:
133
+ """
134
+ Warning: Could not shuffle the unknown key 'NEW_KEY'.
135
+ """
136
+ And the wp-config.php file should not contain:
137
+ """
138
+ {AUTH_KEY_ORIG}
139
+ """
140
+ And the wp-config.php file should contain:
141
+ """
142
+ {LOGGED_IN_SALT_ORIG}
143
+ """
144
+ And the wp-config.php file should not contain:
145
+ """
146
+ define( 'NEW_KEY'
147
+ """
148
+
149
+ When I run `wp config get AUTH_KEY --type=constant`
150
+ Then save STDOUT as {AUTH_KEY_ORIG}
151
+
152
+ When I run `wp config shuffle-salts AUTH_KEY NEW_KEY --force`
153
+ Then STDOUT should contain:
154
+ """
155
+ Shuffled the salt keys.
156
+ """
157
+ And the wp-config.php file should not contain:
158
+ """
159
+ {AUTH_KEY_ORIG}
160
+ """
161
+ And the wp-config.php file should contain:
162
+ """
163
+ {LOGGED_IN_SALT_ORIG}
164
+ """
165
+ And the wp-config.php file should contain:
166
+ """
167
+ define( 'NEW_KEY'
168
+ """
169
+
170
+ When I run `wp config get AUTH_KEY --type=constant`
171
+ Then save STDOUT as {AUTH_KEY_ORIG}
172
+ When I run `wp config get NEW_KEY --type=constant`
173
+ Then save STDOUT as {NEW_KEY_ORIG}
174
+
175
+ When I run `wp config shuffle-salts AUTH_KEY NEW_KEY --force`
176
+ Then STDOUT should contain:
177
+ """
178
+ Shuffled the salt keys.
179
+ """
180
+ And the wp-config.php file should not contain:
181
+ """
182
+ {AUTH_KEY_ORIG}
183
+ """
184
+ And the wp-config.php file should contain:
185
+ """
186
+ {LOGGED_IN_SALT_ORIG}
187
+ """
188
+ And the wp-config.php file should contain:
189
+ """
190
+ define( 'NEW_KEY'
191
+ """
192
+ And the wp-config.php file should not contain:
193
+ """
194
+ {NEW_KEY_ORIG}
195
+ """
196
+
197
+ @less-than-php-7.0
198
+ Scenario : Force adding missing salts to shuffle fails on PHP < 7.0
199
+ Given a WP install
200
+ When I run `wp config shuffle-salts`
201
+ Then STDOUT should contain:
202
+ """
203
+ Shuffled the salt keys.
204
+ """
205
+ And the wp-config.php file should contain:
206
+ """
207
+ define( 'AUTH_KEY'
208
+ """
209
+ And the wp-config.php file should contain:
210
+ """
211
+ define( 'LOGGED_IN_SALT'
212
+ """
213
+ And the wp-config.php file should not contain:
214
+ """
215
+ define( 'NEW_KEY'
216
+ """
217
+
218
+ When I run `wp config get AUTH_KEY --type=constant`
219
+ Then save STDOUT as {AUTH_KEY_ORIG}
220
+ When I run `wp config get LOGGED_IN_SALT --type=constant`
221
+ Then save STDOUT as {LOGGED_IN_SALT_ORIG}
222
+
223
+ When I try `wp config shuffle-salts AUTH_KEY NEW_KEY`
224
+ Then STDOUT should contain:
225
+ """
226
+ Shuffled the salt keys.
227
+ """
228
+ And STDERR should contain:
229
+ """
230
+ Warning: Could not shuffle the unknown key 'NEW_KEY'.
231
+ """
232
+ And the wp-config.php file should not contain:
233
+ """
234
+ {AUTH_KEY_ORIG}
235
+ """
236
+ And the wp-config.php file should contain:
237
+ """
238
+ {LOGGED_IN_SALT_ORIG}
239
+ """
240
+ And the wp-config.php file should not contain:
241
+ """
242
+ define( 'NEW_KEY'
243
+ """
244
+
245
+ When I run `wp config get AUTH_KEY --type=constant`
246
+ Then save STDOUT as {AUTH_KEY_ORIG}
247
+
248
+ When I try `wp config shuffle-salts AUTH_KEY NEW_KEY --force`
249
+ Then STDOUT should contain:
250
+ """
251
+ Shuffled the salt keys.
252
+ """
253
+ And STDERR should contain:
254
+ """
255
+ Warning: Could not add the key 'NEW_KEY' because 'random_int()' is not supported.
256
+ """
257
+ And the wp-config.php file should not contain:
258
+ """
259
+ {AUTH_KEY_ORIG}
260
+ """
261
+ And the wp-config.php file should contain:
262
+ """
263
+ {LOGGED_IN_SALT_ORIG}
264
+ """
265
+ And the wp-config.php file should not contain:
266
+ """
267
+ define( 'NEW_KEY'
268
+ """
0 commit comments