-
-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adding an integration test for the account deletion feature (#8723
) adding a test for the user deletion feature in which : - a common user is created - the user adds a product then deletes his account - an admin user is created and checks if the user account is well deleted (checking the edit preferences page and contributor page) - the admin also checks if the product added by the user is anonymized (the product should display "anonymous" as creator) - checking that no one can log in with the user logs --------- Co-authored-by: Stéphane Gigandet <[email protected]> Co-authored-by: Alex Garel <[email protected]>
- Loading branch information
1 parent
878d48c
commit 33602a8
Showing
9 changed files
with
207 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use ProductOpener::PerlStandards; | ||
|
||
use Test::More; | ||
use ProductOpener::APITest qw/:all/; | ||
use ProductOpener::Test qw/:all/; | ||
use ProductOpener::TestDefaults qw/:all/; | ||
use ProductOpener::Users qw/:all/; | ||
use ProductOpener::Producers qw/:all/; | ||
|
||
remove_all_users(); | ||
wait_application_ready(); | ||
|
||
#new common user agent | ||
my $ua = new_client(); | ||
my %create_client_args = (%default_user_form, (email => '[email protected]')); | ||
create_user($ua, \%create_client_args); | ||
|
||
#new admin user agent | ||
my $admin = new_client(); | ||
create_user($admin, \%admin_user_form); | ||
|
||
#common ua add a new product then delete the account while being still logged in | ||
edit_product($ua, \%default_product); | ||
|
||
my $url_userid = construct_test_url("/cgi/user.pl?type=edit&userid=tests", "world"); | ||
my $url_delete = construct_test_url("/cgi/user.pl", "world"); | ||
my $response_edit = $ua->get($url_userid); | ||
|
||
my %delete_form = ( | ||
name => 'Test', | ||
email => '[email protected]', | ||
password => '', | ||
confirm_password => '', | ||
delete => 'on', | ||
action => 'process', | ||
type => 'edit', | ||
userid => 'tests' | ||
); | ||
|
||
#checking if the delete button exist | ||
like($response_edit->content, qr/Delete the user/, "the delete button does exist"); | ||
|
||
#deleting the account | ||
my $before_delete_ts = time(); | ||
my $response_delete = $ua->post($url_delete, \%delete_form); | ||
#checking if we are redirected to the account deleted page | ||
like($response_delete->content, qr/User is being deleted\. This may take a few minutes\./, "the account was deleted"); | ||
|
||
#waiting the deletion task to be done (weirdly enough it is not useful anymore..) | ||
my $max_time = 60; | ||
my $jobs_ref = get_minion_jobs("delete_user", $before_delete_ts, $max_time); | ||
|
||
is(scalar @{$jobs_ref}, 1, "One delete_user was triggered"); | ||
my $delete_job_state = $jobs_ref->[0]->info->{state}; | ||
is($delete_job_state, "finished", "delete_user finished without errors"); | ||
|
||
#user sign out of its account | ||
my %signout_form = ( | ||
length => "logout", | ||
".submit" => "Sign out" | ||
); | ||
my $url_signout = construct_test_url("/cgi/session.pl", "world"); | ||
my $response_signout = $ua->post($url_signout, \%signout_form); | ||
|
||
like($response_signout->content, qr/See you soon\!/, "the user signed out"); | ||
|
||
#admin ua checking if the account is well deleted | ||
my $response_userid = $admin->get($url_userid); | ||
#checking if the edit page of the common ua is well deleted | ||
like($response_userid->content, qr/Invalid user\./, "the userid edit page is well deleted"); | ||
|
||
my $url_email = construct_test_url('/cgi/user.pl?type=edit&[email protected]', "world"); | ||
my $response_email = $admin->get($url_email); | ||
#checking if the edit page of the common ua is well deleted | ||
like($response_email->content, qr/Invalid user\./, "the email edit page is well deleted"); | ||
|
||
my $url_contributor = construct_test_url("/contributor/tests", "world"); | ||
my $response_contributor = $admin->get($url_contributor); | ||
#checking if the edit page of the common ua is well deleted | ||
like($response_contributor->content, qr/Unknown user\./, "the contributor page of the ua is well deleted"); | ||
|
||
#checking if an ua can reconnect with the deleted account ids | ||
my $url_login = construct_test_url("/cgi/login.pl", "world"); | ||
my %login_form = ( | ||
user_id => "tests", | ||
password => "testtest", | ||
submit => "Sign in" | ||
); | ||
my $response_login = $ua->post($url_login, \%login_form); | ||
like( | ||
$response_login->content, | ||
qr/Incorrect user name or password\./, | ||
"an user can't login with the deleted account ids" | ||
); | ||
|
||
#checking if the added product has been anonymized | ||
my $url_product = construct_test_url("/cgi/product.pl?type=edit&code=2000000000001", "world"); | ||
my $response_product = $admin->get($url_product); | ||
like($response_product->content, qr/\/editor\/anonymous/, "the product has been anonymized"); | ||
|
||
done_testing(); |