[Rt-commit] r4193 - in rt/branches/CHALDEA-EXPERIMENTAL: . lib/RT
lib/t/regression
jesse at bestpractical.com
jesse at bestpractical.com
Wed Nov 30 16:30:29 EST 2005
Author: jesse
Date: Wed Nov 30 16:30:29 2005
New Revision: 4193
Modified:
rt/branches/CHALDEA-EXPERIMENTAL/ (props changed)
rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Principal_Overlay.pm
rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/07rights.t
Log:
r19610 at truegrounds: jesse | 2005-11-30 16:09:20 -0500
r19567 at truegrounds: jesse | 2005-11-30 15:30:15 -0500
r18897 at truegrounds: jesse | 2005-11-14 13:35:44 -0500
r18896 at truegrounds (orig r4072): alexmv | 2005-11-14 13:33:43 -0500
r7135 at zoq-fot-pik: chmrr | 2005-11-14 13:32:23 -0500
RT-Ticket: 7101
RT-Status: resolved
RT-Update: correspond
* Don't modify EquivObjects arrayref, thanks to Todd Chapman
Modified: rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Principal_Overlay.pm
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Principal_Overlay.pm (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Principal_Overlay.pm Wed Nov 30 16:30:29 2005
@@ -301,6 +301,8 @@
return (undef);
}
+ $args{EquivObjects} = [ @{ $args{EquivObjects} } ] if $args{EquivObjects};
+
if ( $self->Disabled ) {
$RT::Logger->error( "Disabled User: "
. $self->id
Modified: rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/07rights.t
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/07rights.t (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/07rights.t Wed Nov 30 16:30:29 2005
@@ -45,7 +45,7 @@
#
# END BPS TAGGED BLOCK }}}
-use Test::More tests => 14;
+use Test::More tests => 26;
use RT;
RT::LoadConfig();
RT::Init();
@@ -108,3 +108,33 @@
ok( $user->HasRight( Right => 'ReplyToTicket', Object => $ticket ), "user is owner and can reply to ticket" );
+# Testing of EquivObjects
+$group = RT::Group->new( $RT::SystemUser );
+ok( $group->LoadQueueRoleGroup( Queue => $queue_id, Type=> 'AdminCc' ), "load queue AdminCc role group" );
+$ace = RT::ACE->new( $RT::SystemUser );
+my ($ace_id, $msg) = $group->PrincipalObj->GrantRight( Right => 'ModifyTicket', Object => $queue );
+ok( $ace_id, "Granted queue AdminCc role group with ModifyTicket right: $msg" );
+ok( $group->PrincipalObj->HasRight( Right => 'ModifyTicket', Object => $queue ), "role group can modify ticket" );
+ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket ), "user is not AdminCc and can't modify ticket" );
+($status, $msg) = $ticket->AddWatcher(Type => 'AdminCc', PrincipalId => $user->PrincipalId);
+ok( $status, "successfuly added user as AdminCc");
+ok( $user->HasRight( Right => 'ModifyTicket', Object => $ticket ), "user is AdminCc and can modify ticket" );
+
+my $ticket2 = RT::Ticket->new($RT::SystemUser);
+my ($ticket2_id) = $ticket2->Create( Queue => $queue_id, Subject => 'test2');
+ok( $ticket2_id, 'new ticket created' );
+ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket2 ), "user is not AdminCc and can't modify ticket2" );
+
+# now we can finally test EquivObjects
+my $equiv = [ $ticket ];
+ok( $user->HasRight( Right => 'ModifyTicket', Object => $ticket2, EquivObjects => $equiv ),
+ "user is not AdminCc but can modify ticket2 because of EquivObjects" );
+
+# the first a third test below are the same, so they should both pass
+my $equiv2 = [];
+ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket2, EquivObjects => $equiv2 ),
+ "user is not AdminCc and can't modify ticket2" );
+ok( $user->HasRight( Right => 'ModifyTicket', Object => $ticket, EquivObjects => $equiv2 ),
+ "user is AdminCc and can modify ticket" );
+ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket2, EquivObjects => $equiv2 ),
+ "user is not AdminCc and can't modify ticket2 (same question different answer)" );
More information about the Rt-commit
mailing list