[Rt-commit] rt branch, 4.4/fix-shredder-uid-check, created. rt-4.4.3beta1-2-ge40c64340
Craig Kaiser
craig at bestpractical.com
Thu Jun 14 17:50:10 EDT 2018
The branch, 4.4/fix-shredder-uid-check has been created
at e40c643408125e8d754656b254a27c949cf2659f (commit)
- Log -----------------------------------------------------------------
commit 670c345892a7c8a5e8c84551774cf446a4f433bd
Author: Craig Kaiser <craig at bestpractical.com>
Date: Tue May 22 11:02:34 2018 -0400
Add test to hit shredder web UI
Test shredder through the web UI, delete a user and a ticket object
diff --git a/t/web/shredder.t b/t/web/shredder.t
new file mode 100644
index 000000000..fd722fd1a
--- /dev/null
+++ b/t/web/shredder.t
@@ -0,0 +1,88 @@
+use strict;
+use warnings;
+
+use RT::Test;
+
+RT::Config->Set('ShredderStoragePath', RT::Test->temp_directory . '');
+
+my ( $baseurl, $agent ) = RT::Test->started_ok;
+
+diag("Test server running at $baseurl");
+
+$agent->login('root' => 'password');
+
+my $ticket_id;
+# Ticket created in block to avoid scope error on destroy
+{
+ my $ticket = RT::Test->create_ticket( Subject => 'test shredder', Queue => 1, );
+ ok( $ticket->Id, "created new ticket" );
+
+ $ticket_id = $ticket->id;
+}
+
+{
+ $agent->get_ok($baseurl . '/Admin/Tools/Shredder/');
+ $agent->submit_form_ok({
+ form_id => 'shredder-search-form',
+ fields => { Plugin => 'Tickets'},
+ }, "Select Tickets shredder plugin");
+
+ $agent->submit_form_ok({
+ form_id => 'shredder-search-form',
+ fields => {
+ 'Tickets:query' => 'id=' . $ticket_id,
+ },
+ button => 'Search',
+ }, "Search for ticket object");
+
+ $agent->submit_form_ok({
+ form_id => 'shredder-search-form',
+ fields => {
+ 'WipeoutObject' => 'RT::Ticket-example.com-1',
+ },
+ button => 'Wipeout',
+ }, "Select and destroy ticket object");
+
+ my $ticket = RT::Ticket->new(RT->SystemUser);
+ my ($ret, $msg) = $ticket->Load($ticket_id);
+
+ ok !$ret, 'Ticket successfully shredded';
+}
+
+# Shred RT::User
+{
+ my $user = RT::User->new(RT->SystemUser);
+ my ($ret, $msg) = $user->LoadOrCreateByEmail('test at example.com');
+ ok $ret;
+
+ my $id = $user->id;
+ ok $id;
+
+ $agent->get_ok($baseurl . '/Admin/Tools/Shredder/');
+ $agent->submit_form_ok({
+ form_id => 'shredder-search-form',
+ fields => { Plugin => 'Users'},
+ }, "Select Users shredder plugin");
+
+ $agent->submit_form_ok({
+ form_id => 'shredder-search-form',
+ fields => {
+ 'Users:email' => 'test at example.com',
+ 'Users:status' => 'Enabled',
+ },
+ button => 'Search',
+ }, "Search for user");
+
+ $agent->submit_form_ok({
+ form_id => 'shredder-search-form',
+ fields => {
+ 'WipeoutObject' => 'RT::User-test at example.com',
+ },
+ button => 'Wipeout',
+ }, "Select and destroy searched user");
+
+ ($ret, $msg) = $user->Load($id);
+ ok !$ret, 'User successfully shredded';
+}
+
+done_testing();
commit e40c643408125e8d754656b254a27c949cf2659f
Author: Craig Kaiser <craig at bestpractical.com>
Date: Tue May 22 11:03:14 2018 -0400
Restrict Name checks to objects with Name and only when id is not numeric
92dc904 updated the id check in Shredder to handle the case where $id is actually a Name.
However, it breaks the case where $id is not a Name, which could produce errors like:
error: RT::Ticket::Name Unimplemented in RT::Shredder
This commit fixes it to:
* Not check Name if $id is numeric.
* Not check Name if object doesn't have it.
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index 8d99326b6..6f92204cf 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -364,11 +364,15 @@ sub CastObjectsToRecords
RT::Shredder::Exception::Info->throw( 'CouldntLoadObject' );
}
- if ( $id =~ /^\d+$/ && $id ne $obj->Id ){
- die 'Loaded object id ' . $obj->Id . " is different from passed id $id";
+ if ( $id =~ /^\d+$/ ) {
+ if ( $id ne $obj->Id ) {
+ die 'Loaded object id ' . $obj->Id . " is different from passed id $id";
+ }
}
- elsif ( $id ne $obj->Name ){
- die 'Loaded object name ' . $obj->Name . " is different from passed name $id";
+ else {
+ if ( $obj->_Accessible( 'Name', 'read' ) && $id ne $obj->Name ) {
+ die 'Loaded object name ' . $obj->Name . " is different from passed name $id";
+ }
}
push @res, $obj;
} else {
-----------------------------------------------------------------------
More information about the rt-commit
mailing list