5 use RT::Test nodata => 1, tests => 18;
11 my $tester = RT::Test->load_or_create_user(
12 EmailAddress => 'tester@localhost',
14 ok $tester && $tester->id, 'loaded or created user';
16 my $queue = RT::Test->load_or_create_queue( Name => 'General' );
17 ok $queue && $queue->id, 'loaded or created queue';
19 my $owner_role_group = RT::Group->new( RT->SystemUser );
20 $owner_role_group->LoadQueueRoleGroup( Type => 'Owner', Queue => $queue->id );
21 ok $owner_role_group->id, 'loaded owners role group of the queue';
23 diag "check that deffering owner doesn't regress";
26 { Principal => $tester->PrincipalObj,
27 Right => [qw(SeeQueue ShowTicket CreateTicket OwnTicket)],
29 { Principal => $owner_role_group->PrincipalObj,
31 Right => [qw(ModifyTicket)],
34 my $ticket = RT::Ticket->new( $tester );
35 # tester is owner, owner has right to modify owned tickets,
36 # this right is required to set somebody as AdminCc
37 my ($tid, $txn_id, $msg) = $ticket->Create(
40 AdminCc => 'root@localhost',
43 ok $tid, "created a ticket";
44 is $ticket->Owner, $tester->id, 'correct owner';
45 like $ticket->AdminCcAddresses, qr/root\@localhost/, 'root is there';
48 diag "check that previous trick doesn't work without sufficient rights";
51 { Principal => $tester->PrincipalObj,
52 Right => [qw(SeeQueue ShowTicket CreateTicket OwnTicket)],
55 my $ticket = RT::Ticket->new( $tester );
56 # tester is owner, owner has right to modify owned tickets,
57 # this right is required to set somebody as AdminCc
58 my ($tid, $txn_id, $msg) = $ticket->Create(
61 AdminCc => 'root@localhost',
64 ok $tid, "created a ticket";
65 is $ticket->Owner, $tester->id, 'correct owner';
66 unlike $ticket->AdminCcAddresses, qr/root\@localhost/, 'root is there';
69 diag "check that deffering owner really works";
72 { Principal => $tester->PrincipalObj,
73 Right => [qw(SeeQueue ShowTicket CreateTicket)],
75 { Principal => $queue->Cc->PrincipalObj,
77 Right => [qw(OwnTicket TakeTicket)],
80 my $ticket = RT::Ticket->new( $tester );
81 # set tester as Cc, Cc role group has right to own and take tickets
82 my ($tid, $txn_id, $msg) = $ticket->Create(
85 Cc => 'tester@localhost',
88 ok $tid, "created a ticket";
89 like $ticket->CcAddresses, qr/tester\@localhost/, 'tester is in the cc list';
90 is $ticket->Owner, $tester->id, 'tester is also owner';
93 diag "check that deffering doesn't work without correct rights";
96 { Principal => $tester->PrincipalObj,
97 Right => [qw(SeeQueue ShowTicket CreateTicket)],
101 my $ticket = RT::Ticket->new( $tester );
102 # set tester as Cc, Cc role group has right to own and take tickets
103 my ($tid, $txn_id, $msg);
105 ($tid, $txn_id, $msg) = $ticket->Create(
107 Owner => $tester->id,
108 Cc => 'tester@localhost',
110 } qr/User .* was proposed as a ticket owner but has no rights to own tickets in General/;
113 ok $tid, "created a ticket";
114 like $ticket->CcAddresses, qr/tester\@localhost/, 'tester is in the cc list';
115 isnt $ticket->Owner, $tester->id, 'tester is also owner';