Skip to content

Commit ac3ebec

Browse files
Merge branch '6.0/shredder-authtokens' into 6.0-trunk
2 parents c381c81 + e6224dd commit ac3ebec

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

lib/RT/Shredder.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ our @SUPPORTED_OBJECTS = qw(
261261
Dashboard
262262
DashboardSubscription
263263
ObjectContent
264+
AuthToken
265+
Configuration
266+
Shortener
264267
);
265268

266269
=head3 GENERIC

lib/RT/Shredder/Plugin/Users.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ sub SetResolvers
292292
my $resolver = sub {
293293
my %args = (@_);
294294
my $t = $args{'TargetObject'};
295-
foreach my $method ( qw(Creator LastUpdatedBy) ) {
295+
foreach my $method ( qw(Creator LastUpdatedBy LastAccessedBy) ) {
296296
next unless $t->_Accessible( $method => 'read' );
297297
if ( $t->__Value($method) == $args{BaseObject}->Id ) {
298298
$t->__Set( Field => $method, Value => $uid );

lib/RT/User.pm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3162,6 +3162,11 @@ sub __DependsOn {
31623162
$objs->Limit( FIELD => 'Field', VALUE => $self->PrincipalObj->id, ENTRYAGGREGATOR => 'AND' );
31633163
push( @$list, $objs );
31643164

3165+
# Cleanup user's auth tokens
3166+
$objs = RT::AuthTokens->new( $self->CurrentUser );
3167+
$objs->LimitOwner( VALUE => $self->Id );
3168+
push( @$list, $objs );
3169+
31653170
$deps->_PushDependencies(
31663171
BaseObject => $self,
31673172
Flags => RT::Shredder::Constants::DEPENDS_ON,
@@ -3196,11 +3201,14 @@ sub __DependsOn {
31963201
Tickets
31973202
Transactions
31983203
Users
3204+
AuthTokens
3205+
Configurations
3206+
Shorteners
31993207
);
32003208
my @var_objs;
32013209
foreach( @OBJECTS ) {
32023210
my $class = "RT::$_";
3203-
foreach my $method ( qw(Creator LastUpdatedBy) ) {
3211+
foreach my $method ( qw(Creator LastUpdatedBy LastAccessedBy) ) {
32043212
my $objs = $class->new( $self->CurrentUser );
32053213
next unless $objs->RecordClass->_Accessible( $method => 'read' );
32063214
$objs->Limit( FIELD => $method, VALUE => $self->id );

t/shredder/02user.t

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use strict;
33
use warnings;
44

55
use Test::Deep;
6-
use RT::Test::Shredder tests => 10;
6+
use RT::Test::Shredder tests => undef;
77
my $test = "RT::Test::Shredder";
88

99
$test->create_savepoint('clean');
@@ -16,21 +16,34 @@ my $ticket = RT::Ticket->new( RT->SystemUser );
1616
my ($tid) = $ticket->Create( Queue => $qid, Subject => 'test' );
1717
ok( $tid, "ticket created" );
1818

19+
my $config = RT::Configuration->new( RT->SystemUser );
20+
ok( $config->Create( Name => 'RememberDefaultQueue', Content => 1 ) );
21+
22+
my $auth_token = RT::AuthToken->new( RT->SystemUser );
23+
ok( $auth_token->Create( Owner => RT->SystemUser->Id, Description => 'test' ) );
24+
25+
my $shortener = RT::Shortener->new( RT->SystemUser );
26+
ok( $shortener->Create( Content => 'Query=id>1' ) );
27+
1928
$test->create_savepoint('bucreate'); # berfore user create
2029
my $user = RT::User->new( RT->SystemUser );
2130
my ($uid, $msg) = $user->Create( Name => 'new user', Privileged => 1, Disabled => 0 );
2231
ok( $uid, "created new user" ) or diag "error: $msg";
2332
is( $user->id, $uid, "id is correct" );
24-
# HACK: set ticket props to enable VARIABLE dependencies
33+
# HACK: set props to enable VARIABLE dependencies
2534
$ticket->__Set( Field => 'LastUpdatedBy', Value => $uid );
35+
$config->__Set( Field => $_, Value => $uid ) for qw/Creator LastUpdatedBy/;
36+
$auth_token->__Set( Field => $_, Value => $uid ) for qw/Creator LastUpdatedBy/;
37+
$shortener->__Set( Field => $_, Value => $uid ) for qw/Creator LastUpdatedBy LastAccessedBy/;
38+
2639
$test->create_savepoint('aucreate'); # after user create
2740

2841
{
2942
my $resolver = sub {
3043
my %args = (@_);
3144
my $t = $args{'TargetObject'};
3245
my $resolver_uid = RT->SystemUser->id;
33-
foreach my $method ( qw(Creator LastUpdatedBy) ) {
46+
foreach my $method ( qw(Creator LastUpdatedBy LastAccessedBy) ) {
3447
next unless $t->_Accessible( $method => 'read' );
3548
$t->__Set( Field => $method, Value => $resolver_uid );
3649
}
@@ -53,3 +66,5 @@ $test->create_savepoint('aucreate'); # after user create
5366
$test->db_is_valid;
5467
cmp_deeply( $test->dump_current_and_savepoint('aucreate'), "current DB equal to savepoint");
5568
}
69+
70+
done_testing;

0 commit comments

Comments
 (0)