Privacy: Use relative paths for exported personal data.

Ensures back-compat while moving to paths off of the /exports directory.

Fixes: #44038.

Props: allendav, mrTall, desrosj, garrett-eclipse, cameronamcintyre, nmenescardi, xkon, whyisjake, davidbaumwald.


git-svn-id: https://develop.svn.wordpress.org/trunk@48127 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock
2020-06-22 22:38:11 +00:00
parent 8216e5019a
commit 800cfa8a82
3 changed files with 73 additions and 15 deletions

View File

@@ -44,9 +44,27 @@ class Tests_Privacy_WpPrivacyProcessPersonalDataExportPage extends WP_UnitTestCa
protected static $response_last_page;
/**
* Export File Url.
* Export Url.
*
* @since 5.2.0
* @since 5.5.0
*
* @var string $export_url
*/
protected static $export_url;
/**
* Export File Name.
*
* @since 5.5.0
*
* @var string $export_file_name
*/
protected static $export_file_name;
/**
* Export File URL.
*
* @since 5.5.0
*
* @var string $export_file_url
*/
@@ -131,7 +149,9 @@ class Tests_Privacy_WpPrivacyProcessPersonalDataExportPage extends WP_UnitTestCa
*/
public static function wpSetUpBeforeClass( $factory ) {
self::$requester_email = 'requester@example.com';
self::$export_file_url = wp_privacy_exports_url() . 'wp-personal-data-file-Wv0RfMnGIkl4CFEDEEkSeIdfLmaUrLsl.zip';
self::$export_url = wp_privacy_exports_url();
self::$export_file_name = 'wp-personal-data-file-Wv0RfMnGIkl4CFEDEEkSeIdfLmaUrLsl.zip';
self::$export_file_url = self::$export_url . self::$export_file_name;
self::$request_id = wp_create_user_request( self::$requester_email, 'export_personal_data' );
self::$page_index_first = 1;
self::$page_index_last = 2;
@@ -502,7 +522,7 @@ class Tests_Privacy_WpPrivacyProcessPersonalDataExportPage extends WP_UnitTestCa
* @ticket 44233
*/
public function test_return_response_with_export_file_url_when_not_sent_as_email_for_last_exporter_on_last_page() {
update_post_meta( self::$request_id, '_export_file_url', self::$export_file_url );
update_post_meta( self::$request_id, '_export_file_name', self::$export_file_name );
// Process data, given the last exporter, on the last page and not send as email.
$actual_response = wp_privacy_process_personal_data_export_page(
@@ -528,7 +548,7 @@ class Tests_Privacy_WpPrivacyProcessPersonalDataExportPage extends WP_UnitTestCa
* @ticket 44233
*/
public function test_return_response_without_export_file_url_when_sent_as_email_for_last_exporter_on_last_page() {
update_post_meta( self::$request_id, '_export_file_url', self::$export_file_url );
update_post_meta( self::$request_id, '_export_file_name', self::$export_file_name );
// Process data, given the last exporter, on the last page and send as email.
$actual_response = wp_privacy_process_personal_data_export_page(

View File

@@ -104,8 +104,10 @@ class Tests_Privacy_WpPrivacySendPersonalDataExportEmail extends WP_UnitTestCase
* The function should send an export link to the requester when the user request is confirmed.
*/
public function test_function_should_send_export_link_to_requester() {
$archive_url = wp_privacy_exports_url() . 'wp-personal-data-file-Wv0RfMnGIkl4CFEDEEkSeIdfLmaUrLsl.zip';
update_post_meta( self::$request_id, '_export_file_url', $archive_url );
$archive_url = wp_privacy_exports_url();
$archive_file_name = 'wp-personal-data-file-Wv0RfMnGIkl4CFEDEEkSeIdfLmaUrLsl.zip';
$archive_file_url = $archive_url . $archive_file_name;
update_post_meta( self::$request_id, '_export_file_name', $archive_file_name );
$email_sent = wp_privacy_send_personal_data_export_email( self::$request_id );
$mailer = tests_retrieve_phpmailer_instance();
@@ -113,7 +115,7 @@ class Tests_Privacy_WpPrivacySendPersonalDataExportEmail extends WP_UnitTestCase
$this->assertSame( 'request-confirmed', get_post_status( self::$request_id ) );
$this->assertSame( self::$requester_email, $mailer->get_recipient( 'to' )->address );
$this->assertContains( 'Personal Data Export', $mailer->get_sent()->subject );
$this->assertContains( $archive_url, $mailer->get_sent()->body );
$this->assertContains( $archive_file_url, $mailer->get_sent()->body );
$this->assertContains( 'please download it', $mailer->get_sent()->body );
$this->assertTrue( $email_sent );
}