Skip to content

Commit a4665e3

Browse files
committed
feat: add scenarios for verifying core checksums with various format parameters
1 parent 37e7679 commit a4665e3

1 file changed

Lines changed: 119 additions & 0 deletions

File tree

features/checksum-core.feature

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,122 @@ Feature: Validate checksums for WordPress install
260260
Error: WordPress installation doesn't verify against checksums.
261261
"""
262262
And the return code should be 1
263+
264+
Scenario: Core checksums verify with format parameter
265+
Given a WP install
266+
And "WordPress" replaced with "Modified WordPress" in the wp-includes/version.php file
267+
And a wp-includes/extra-file.txt file:
268+
"""
269+
This is an extra file
270+
"""
271+
And "WordPress" replaced with "PressWord" in the readme.html file
272+
273+
When I try `wp core verify-checksums --format=json`
274+
Then STDOUT should be:
275+
"""
276+
[{"file":"readme.html","message":"File doesn't verify against checksum"},{"file":"wp-includes\/version.php","message":"File doesn't verify against checksum"},{"file":"wp-includes\/extra-file.txt","message":"File should not exist"}]
277+
"""
278+
And STDERR should be:
279+
"""
280+
Error: WordPress installation doesn't verify against checksums.
281+
"""
282+
And the return code should be 1
283+
284+
Scenario: Core checksums verify with table format
285+
Given a WP install
286+
And "WordPress" replaced with "Modified" in the wp-includes/functions.php file
287+
288+
When I try `wp core verify-checksums --format=table`
289+
Then STDOUT should be a table containing rows:
290+
| file | message |
291+
| wp-includes/functions.php | File doesn't verify against checksum |
292+
And the return code should be 1
293+
294+
Scenario: Core checksums verify with csv format
295+
Given a WP install
296+
And a wp-includes/test.php file:
297+
"""
298+
<?php echo 'test'; ?>
299+
"""
300+
301+
When I try `wp core verify-checksums --format=csv`
302+
Then STDOUT should be:
303+
"""
304+
file,message
305+
wp-includes/test.php,"File should not exist"
306+
Success: WordPress installation verifies against checksums.
307+
"""
308+
And the return code should be 0
309+
310+
Scenario: Core checksums verify format parameter with missing core files
311+
Given a WP install
312+
When I run `rm wp-includes/widgets.php wp-includes/rest-api.php`
313+
And I try `wp core verify-checksums --format=json`
314+
Then STDOUT should contain:
315+
"""
316+
[{"file":"wp-includes\/rest-api.php","message":"File doesn't exist"},{"file":"wp-includes\/widgets.php","message":"File doesn't exist"}]
317+
"""
318+
And STDERR should be:
319+
"""
320+
Error: WordPress installation doesn't verify against checksums.
321+
"""
322+
And the return code should be 1
323+
324+
Scenario: Core checksums verify format parameter with multiple file types
325+
Given a WP install
326+
And "Version" replaced with "v" in the wp-includes/version.php file
327+
And I run `rm wp-includes/nav-menu.php`
328+
And a wp-includes/extra.txt file:
329+
"""
330+
test file
331+
"""
332+
333+
When I try `wp core verify-checksums --format=json`
334+
Then STDOUT should contain:
335+
"""
336+
[{"file":"wp-includes\/nav-menu.php","message":"File doesn't exist"},{"file":"wp-includes\/version.php","message":"File doesn't verify against checksum"},{"file":"wp-includes\/extra.txt","message":"File should not exist"}]
337+
"""
338+
And the return code should be 1
339+
340+
Scenario: Core checksums verify with count format
341+
Given a WP install
342+
And "WordPress" replaced with "Modified" in the wp-includes/post.php file
343+
And I run `rm wp-includes/comment.php`
344+
And a wp-includes/test.txt file:
345+
"""
346+
test content
347+
"""
348+
349+
When I try `wp core verify-checksums --format=count`
350+
Then STDOUT should be:
351+
"""
352+
3
353+
"""
354+
And the return code should be 1
355+
356+
Scenario: Core checksums verify with format parameter and excluded files
357+
Given a WP install
358+
And "WordPress" replaced with "Modified" in the wp-includes/update.php file
359+
And "WordPress" replaced with "Changed" in the wp-includes/meta.php file
360+
And a wp-includes/test.log file:
361+
"""
362+
log content
363+
"""
364+
365+
When I try `wp core verify-checksums --format=json --exclude=wp-includes/meta.php,wp-includes/test.log`
366+
Then STDOUT should contain:
367+
"""
368+
[{"file":"wp-includes\/update.php","message":"File doesn't verify against checksum"}]
369+
"""
370+
And the return code should be 1
371+
372+
Scenario: Core checksums verify format parameter with empty result after exclusion
373+
Given a WP install
374+
And "WordPress" replaced with "Changed" in the wp-includes/cache.php file
375+
376+
When I try `wp core verify-checksums --format=json --exclude=wp-includes/cache.php`
377+
Then STDOUT should be:
378+
"""
379+
Success: WordPress installation verifies against checksums.
380+
"""
381+
And the return code should be 0

0 commit comments

Comments
 (0)