1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
|
use strict;
use warnings;
use RT::Test tests => undef;
# having this set overrides checking against individual configured addresses,
# and the Test default value can't match something that also looks like an email address
RT->Config->Set('RTAddressRegexp', undef);
is( RT->Config->Get('RTAddressRegexp'), undef, 'global RTAddressRegexp is not set');
RT->Config->Set('CommentAddress', 'rt-comment@example.com');
is( RT->Config->Get('CommentAddress'), 'rt-comment@example.com', 'global comment address set');
my ( $baseurl, $m ) = RT::Test->started_ok;
ok $m->login, 'logged in as root';
my $root = RT::User->new( RT->SystemUser );
ok( $root->Load( 'root' ), 'load root user' );
my $alice = RT::Test->load_or_create_user( Name => 'alice', EmailAddress => 'alice@example.com' );
ok( $alice->id, 'created user alice' );
ok( $alice->PrincipalObj->GrantRight( Object => RT->System, Right => 'OwnTicket' ) );
my $bob = RT::Test->load_or_create_user( Name => 'bob', EmailAddress => 'bob@example.com' );
ok( $bob->id, 'created user bob' );
my $richard = RT::Test->load_or_create_user( Name => 'richard', EmailAddress => 'richard@example.com' );
ok( $richard->id, 'created user richard' );
my $group_foo = RT::Test->load_or_create_group( 'foo' );
ok( $group_foo->id, 'created group foo' );
my $group_admin_user = RT::Test->load_or_create_group( 'admin user' );
ok( $group_admin_user->id, 'created group admin user' );
my $queue = RT::Test->load_or_create_queue( Name => 'General' );
ok $queue->id, 'loaded queue General';
# test the success cases
diag "Test ticket create page";
{
$m->goto_create_ticket( $queue );
$m->submit_form_ok(
{
form_name => 'TicketCreate',
fields => {
Subject => 'test inputs on create',
Content => 'test content',
Requestors => 'alice, root@localhost, group:' . $group_foo->id,
Cc => 'richard@example.com, ' . $alice->id,
AdminCc => 'group:admin user, bob',
},
button => 'SubmitTicket',
},
'submit form TicketCreate'
);
$m->content_like( qr/Ticket \d+ created/, 'created ticket' );
my $ticket = RT::Test->last_ticket;
for my $member ( $root, $alice, $group_foo ) {
ok( $ticket->Requestor->HasMember( $member->PrincipalObj ), 'Requestor has member ' . $member->Name );
}
for my $member ( $alice, $richard ) {
ok( $ticket->Cc->HasMember( $member->PrincipalObj ), 'Cc has member ' . $member->Name );
}
for my $member ( $bob, $group_admin_user ) {
ok( $ticket->AdminCc->HasMember( $member->PrincipalObj ), 'AdminCc has member ' . $member->Name );
}
}
diag "Test ticket people page";
{
my $ticket = RT::Test->create_ticket(
Queue => $queue,
Subject => 'test inputs on people',
Content => 'test content',
);
$m->goto_ticket( $ticket->id, 'ModifyPeople' );
$m->submit_form_ok(
{
form_name => 'TicketPeople',
fields => {
WatcherTypeEmail1 => 'Requestor',
WatcherAddressEmail1 => 'alice',
WatcherTypeEmail2 => 'AdminCc',
WatcherAddressEmail2 => 'group: foo',
},
button => 'SubmitTicket',
},
'submit form TicketPeople'
);
$m->text_contains( 'Added alice as Requestor for this ticket' );
$m->text_contains( 'Added foo as AdminCc for this ticket' );
ok( $ticket->Requestor->HasMember( $alice->PrincipalObj ), 'Requestor has member ' . $alice->Name );
ok( $ticket->AdminCc->HasMember( $group_foo->PrincipalObj ), 'AdminCc has member ' . $group_foo->Name );
}
diag "Test ticket update page";
{
my $ticket = RT::Test->create_ticket(
Queue => $queue,
Subject => 'test inputs on update',
Content => 'test content',
);
$m->goto_ticket( $ticket->id, 'Update' );
$m->submit_form_ok(
{
form_name => 'TicketUpdate',
fields => {
UpdateContent => 'test content',
UpdateCc => 'alice, bob@example.com',
UpdateBcc => 'richard',
},
button => 'SubmitTicket',
},
'submit form TicketUpdate'
);
$m->content_contains('Comments added');
$m->follow_link_ok( { url_regex => qr/ShowEmailRecord/ }, 'get the outgoing email page' );
$m->content_contains( 'CC: alice@example.com, bob@example.com' );
$m->content_contains( 'BCC: richard@example.com' );
}
diag "Test checkboxes for One-time Cc/Bcc on ticket update page";
{
my $ticket = RT::Test->create_ticket(
Queue => $queue,
Subject => 'test inputs on update',
Content => 'test content',
Requestor => 'foo@example.com',
Cc => 'richard@example.com',
AdminCc => 'bob',
);
$m->goto_ticket( $ticket->id, 'Update' );
is( $m->dom->find('.ticket-update-suggested-cc input')->size, 0, 'No one-time checkboxes' );
$m->submit_form_ok(
{
form_name => 'TicketUpdate',
fields => {
UpdateContent => 'test content',
UpdateCc => 'alice@example.com, foo@example.com',
UpdateBcc => 'richard@example.com, bob@example.com',
},
button => 'SubmitTicket',
},
'submit form TicketUpdate'
);
$m->content_contains('Comments added');
$m->goto_ticket( $ticket->id, 'Update' );
is( $m->dom->find('.ticket-update-suggested-cc input')->size, 2, 'Two one-time checkboxes' );
ok( $m->dom->at('.ticket-update-suggested-cc input[name="UpdateCc-alice@example.com"]'),
'One-time Cc checkbox for alice@example.com' );
ok( $m->dom->at('.ticket-update-suggested-cc input[name="UpdateBcc-alice@example.com"]'),
'One-time Bcc checkbox for alice@example.com' );
ok( $ticket->SetOwner( $alice->Id ) );
$m->goto_ticket( $ticket->id, 'Update' );
is( $m->dom->find('.ticket-update-suggested-cc input')->size, 0, 'No one-time checkboxes' );
}
diag "Test ticket bulk update page";
{
my @tickets = RT::Test->create_tickets(
{
Queue => $queue,
Subject => 'test role inputs on bulk update',
Content => 'test content',
},
( {} ) x 3
);
$m->get_ok( '/Search/Bulk.html?Rows=10&Query=Subject="test role inputs on bulk update"' );
$m->submit_form_ok(
{
form_name => 'BulkUpdate',
fields => {
AddRequestor => 'alice',
AddAdminCc => 'group: admin user',
},
},
'submit form BulkUpdate'
);
$m->text_contains( 'Added alice as Requestor for this ticket' );
$m->text_contains( 'Added admin user as AdminCc for this ticket' );
for my $ticket ( @tickets ) {
ok( $ticket->Requestor->HasMember( $alice->PrincipalObj ), 'Requestor has member ' . $alice->Name );
ok( $ticket->AdminCc->HasMember( $group_admin_user->PrincipalObj ),
'AdminCc has member ' . $group_admin_user->Name );
}
$m->get_ok( '/Search/Bulk.html?Rows=10&Query=Subject="test role inputs on bulk update"' );
$m->submit_form_ok(
{
form_name => 'BulkUpdate',
fields => {
DeleteRequestor => $alice->id,
DeleteAdminCc => 'group: ' . $group_admin_user->id,
},
},
'submit form BulkUpdate'
);
$m->text_contains( 'admin user is no longer AdminCc for this ticket' );
for my $ticket ( @tickets ) {
ok( !$ticket->AdminCc->HasMember( $group_admin_user->PrincipalObj ),
'AdminCc has no member ' . $group_admin_user->Name );
}
}
# make sure that any warnings from the preceeding (which shouldn't happen) don't affect the tests that follow
$m->no_warnings_ok;
# test the failure cases
ok( $queue->SetCorrespondAddress('rt-general@example.com'), 'Set queue correspond address' );
diag "Test ticket create page (failures)";
{
$m->goto_create_ticket( $queue );
$m->submit_form_ok(
{
form_name => 'TicketCreate',
fields => {
Subject => 'test input errors on create',
Content => 'test content',
Requestors => 'sybil, group:think, rt-general@example.com, rt-comment@example.com',
Cc => 'sybil, group:think, rt-general@example.com, rt-comment@example.com',
AdminCc => 'sybil, group:think, rt-general@example.com, rt-comment@example.com',
},
button => 'SubmitTicket',
},
'submit form TicketCreate'
);
$m->next_warning_like( qr/^Couldn't load (?:user from value sybil|group from value group:think), Couldn't find row$/, 'found expected warning' ) for 1 .. 6;
foreach my $role (qw(Requestor Cc AdminCc)) {
$m->text_like( qr/Couldn't add 'sybil' as $role/, "expected user warning: sybil $role" );
$m->text_like( qr/Couldn't add 'group:think' as $role/, "expected user warning: group:think $role" );
$m->text_like( qr/rt-general\@example.com is an address RT receives mail at. Adding it as a '$role' would create a mail loop/, "expected user warning: rt-general\@example.com $role" );
$m->text_like( qr/rt-comment\@example.com is an address RT receives mail at. Adding it as a '$role' would create a mail loop/, "expected user warning: rt-comment\@example.com $role" );
}
}
diag "Test ticket update page (failures)";
{
my $ticket = RT::Test->create_ticket(
Queue => $queue,
Subject => 'test inputs on update',
Content => 'test content',
);
$m->goto_ticket( $ticket->id, 'Update' );
$m->submit_form_ok(
{
form_name => 'TicketUpdate',
fields => {
UpdateContent => 'test content',
UpdateCc => 'sybil, group:think, rt-general@example.com, rt-comment@example.com',
UpdateBcc => 'sybil, group:think, rt-general@example.com, rt-comment@example.com',
},
button => 'SubmitTicket',
},
'submit form TicketCreate'
);
$m->next_warning_like( qr/^Couldn't load (?:user from value sybil|group from value group:think), Couldn't find row$/, 'found expected warning' ) for 1 .. 4;
foreach my $role (qw(Cc Bcc)) {
$m->text_like( qr/Couldn't add 'sybil' to 'One-time $role'/, "expected user warning: sybil $role" );
$m->text_like( qr/Couldn't add 'group:think' to 'One-time $role'/, "expected user warning: group:think $role" );
$m->text_like( qr/rt-general\@example.com is an address RT receives mail at. Adding it as a 'One-time $role' would create a mail loop/, "expected user warning: rt-general\@example.com $role" );
$m->text_like( qr/rt-comment\@example.com is an address RT receives mail at. Adding it as a 'One-time $role' would create a mail loop/, "expected user warning: rt-comment\@example.com $role" );
}
}
done_testing;
|