Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@
"user meta patch",
"user meta pluck",
"user meta update",
"user privacy-request",
"user privacy-request complete",
"user privacy-request create",
"user privacy-request delete",
"user privacy-request erase",
"user privacy-request export",
"user privacy-request list",
"user remove-cap",
"user remove-role",
"user reset-password",
Expand Down
11 changes: 11 additions & 0 deletions entity-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@
)
);
WP_CLI::add_command( 'user meta', 'User_Meta_Command' );
WP_CLI::add_command(
'user privacy-request',
'User_Privacy_Request_Command',
array(
'before_invoke' => function () {
if ( Utils\wp_version_compare( '4.9.6', '<' ) ) {
WP_CLI::error( 'Requires WordPress 4.9.6 or greater.' );
}
},
)
);
WP_CLI::add_command( 'user session', 'User_Session_Command' );
WP_CLI::add_command( 'user term', 'User_Term_Command' );

Expand Down
240 changes: 240 additions & 0 deletions features/user-privacy-request.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
Feature: Manage user privacy requests

@require-wp-4.9.6
Scenario: Create and list privacy requests
Given a WP install

When I run `wp user privacy-request create admin@example.com export_personal_data --porcelain`
Then STDOUT should be a number
And save STDOUT as {REQUEST_ID}

When I run `wp user privacy-request list --format=csv --fields=ID,user_email,action_name,status`
Then STDOUT should contain:
"""
{REQUEST_ID},admin@example.com,export_personal_data,request-pending
"""

When I run `wp user privacy-request list --format=ids`
Then STDOUT should contain:
"""
{REQUEST_ID}
"""

When I run `wp user privacy-request list --format=count`
Then STDOUT should be:
"""
1
"""

@require-wp-4.9.6
Scenario: Create requests with confirmed status
Given a WP install

When I run `wp user privacy-request create admin@example.com export_personal_data --status=confirmed --porcelain`
Then STDOUT should be a number
And save STDOUT as {REQUEST_ID}

When I run `wp user privacy-request list --format=csv --fields=ID,status`
Then STDOUT should contain:
"""
{REQUEST_ID},request-confirmed
"""

@require-wp-4.9.6
Scenario: Filter privacy request list by action type
Given a WP install

When I run `wp user privacy-request create admin@example.com export_personal_data --porcelain`
Then save STDOUT as {EXPORT_ID}

When I run `wp user privacy-request create admin@example.com remove_personal_data --porcelain`
Then save STDOUT as {ERASE_ID}

When I run `wp user privacy-request list --action-type=export_personal_data --format=ids`
Then STDOUT should contain:
"""
{EXPORT_ID}
"""
And STDOUT should not contain:
"""
{ERASE_ID}
"""

When I run `wp user privacy-request list --action-type=remove_personal_data --format=ids`
Then STDOUT should contain:
"""
{ERASE_ID}
"""
And STDOUT should not contain:
"""
{EXPORT_ID}
"""

@require-wp-4.9.6
Scenario: Filter privacy request list by status
Given a WP install

When I run `wp user privacy-request create admin@example.com export_personal_data --status=confirmed --porcelain`
Then save STDOUT as {CONFIRMED_ID}

When I run `wp user privacy-request create admin@example.com remove_personal_data --porcelain`
Then save STDOUT as {PENDING_ID}

When I run `wp user privacy-request list --status=request-confirmed --format=ids`
Then STDOUT should contain:
"""
{CONFIRMED_ID}
"""
And STDOUT should not contain:
"""
{PENDING_ID}
"""

When I run `wp user privacy-request list --status=request-pending --format=ids`
Then STDOUT should contain:
"""
{PENDING_ID}
"""
And STDOUT should not contain:
"""
{CONFIRMED_ID}
"""

@require-wp-4.9.6
Scenario: Delete privacy requests
Given a WP install

When I run `wp user privacy-request create admin@example.com export_personal_data --porcelain`
Then save STDOUT as {REQUEST_ID}

When I run `wp user privacy-request delete {REQUEST_ID}`
Then STDOUT should contain:
"""
Success: Deleted 1 of 1 privacy requests.
"""

When I run `wp user privacy-request list --format=count`
Then STDOUT should be:
"""
0
"""

When I try `wp user privacy-request delete 9999`
Then STDERR should contain:
"""
Warning: Could not find privacy request with ID 9999.
"""

@require-wp-4.9.6
Scenario: Complete privacy requests
Given a WP install

When I run `wp user privacy-request create admin@example.com export_personal_data --status=confirmed --porcelain`
Then save STDOUT as {REQUEST_ID}

When I run `wp user privacy-request complete {REQUEST_ID}`
Then STDOUT should contain:
"""
Success: Completed 1 of 1 privacy requests.
"""

When I run `wp user privacy-request list --status=request-completed --format=ids`
Then STDOUT should contain:
"""
{REQUEST_ID}
"""

When I try `wp user privacy-request complete 9999`
Then STDERR should contain:
"""
Warning: Could not find privacy request with ID 9999.
"""

@require-wp-4.9.6
Scenario: Erase personal data for a request
Given a WP install

When I run `wp user privacy-request create admin@example.com remove_personal_data --status=confirmed --porcelain`
Then save STDOUT as {REQUEST_ID}

When I run `wp user privacy-request erase {REQUEST_ID}`
Then STDOUT should contain:
"""
Success: Erased personal data for request {REQUEST_ID}.
"""

When I run `wp user privacy-request list --status=request-completed --format=ids`
Then STDOUT should contain:
"""
{REQUEST_ID}
"""

@require-wp-4.9.6
Scenario: Erase command fails for non-erasure requests
Given a WP install

When I run `wp user privacy-request create admin@example.com export_personal_data --status=confirmed --porcelain`
Then save STDOUT as {REQUEST_ID}

When I try `wp user privacy-request erase {REQUEST_ID}`
Then STDERR should contain:
"""
Error: Request {REQUEST_ID} is not a 'remove_personal_data' request.
"""

@require-wp-4.9.6
Scenario: Export personal data for a request
Given a WP install

When I run `wp user privacy-request create admin@example.com export_personal_data --status=confirmed --porcelain`
Then save STDOUT as {REQUEST_ID}

When I run `wp user privacy-request export {REQUEST_ID}`
Then STDOUT should contain:
"""
Success: Exported personal data to:
"""
And STDOUT should contain:
"""
.zip
"""

When I run `wp user privacy-request list --status=request-completed --format=ids`
Then STDOUT should contain:
"""
{REQUEST_ID}
"""

@require-wp-4.9.6
Scenario: Export command fails for non-export requests
Given a WP install

When I run `wp user privacy-request create admin@example.com remove_personal_data --status=confirmed --porcelain`
Then save STDOUT as {REQUEST_ID}

When I try `wp user privacy-request export {REQUEST_ID}`
Then STDERR should contain:
"""
Error: Request {REQUEST_ID} is not an 'export_personal_data' request.
"""

@require-wp-4.9.6
Scenario: Create request with invalid action type
Given a WP install

When I try `wp user privacy-request create admin@example.com invalid_action`
Then STDERR should contain:
"""
Error: Invalid value specified for positional arg.
"""

@require-wp-4.9.6
Scenario: Create request with invalid status
Given a WP install

When I try `wp user privacy-request create admin@example.com export_personal_data --status=invalid`
Then STDERR should contain:
"""
Error: Parameter errors:
Invalid value specified for 'status' (The initial status of the request.)
"""
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<exclude-pattern>*/src/Signup_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Site(_Meta|_Option)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/Term(_Meta)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/User(_Application_Password|_Meta|_Session|_Term)?_Command\.php$</exclude-pattern>
<exclude-pattern>*/src/User(_Application_Password|_Meta|_Privacy_Request|_Session|_Term)?_Command\.php$</exclude-pattern>
</rule>

<!-- Whitelisting to provide backward compatibility to classes possibly extending this class. -->
Expand Down
Loading