X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Ft%2Fmail%2Fgateway.t;fp=rt%2Ft%2Fmail%2Fgateway.t;h=98eabd56ef153a1f839e24014e388a5882988c2f;hb=33beebf4cb42eba3e1dd868ad5e0af102de961da;hp=d57b063a2ef0f8bcdebd39236b2cc02c925084e8;hpb=7ac86daf67b0a95153b736d5811f9050363f6553;p=freeside.git diff --git a/rt/t/mail/gateway.t b/rt/t/mail/gateway.t index d57b063a2..98eabd56e 100644 --- a/rt/t/mail/gateway.t +++ b/rt/t/mail/gateway.t @@ -57,7 +57,7 @@ use strict; use warnings; -use RT::Test config => 'Set( $UnsafeEmailCommands, 1);', tests => 159; +use RT::Test config => 'Set( $UnsafeEmailCommands, 1);', tests => 228, actual_server => 1; my ($baseurl, $m) = RT::Test->started_ok; use RT::Tickets; @@ -70,7 +70,7 @@ use LWP::UserAgent; my $url = $m->rt_base_url; -diag "Make sure that when we call the mailgate without URL, it fails" if $ENV{'TEST_VERBOSE'}; +diag "Make sure that when we call the mailgate without URL, it fails"; { my $text = <send_via_mailgate($text, url => undef); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, url => undef); is ($status >> 8, 1, "The mail gateway exited with a failure"); ok (!$id, "No ticket id") or diag "by mistake ticket #$id"; + $m->no_warnings_ok; } -diag "Make sure that when we call the mailgate with wrong URL, it tempfails" if $ENV{'TEST_VERBOSE'}; +diag "Make sure that when we call the mailgate with wrong URL, it tempfails"; { my $text = <send_via_mailgate($text, url => 'http://this.test.for.non-connection.is.expected.to.generate.an.error'); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, url => 'http://this.test.for.non-connection.is.expected.to.generate.an.error'); is ($status >> 8, 75, "The mail gateway exited with a failure"); ok (!$id, "No ticket id"); + $m->no_warnings_ok; } my $everyone_group; -diag "revoke rights tests depend on" if $ENV{'TEST_VERBOSE'}; +diag "revoke rights tests depend on"; { - $everyone_group = RT::Group->new( $RT::SystemUser ); + $everyone_group = RT::Group->new( RT->SystemUser ); $everyone_group->LoadSystemInternalGroup( 'Everyone' ); ok ($everyone_group->Id, "Found group 'everyone'"); @@ -110,7 +112,7 @@ diag "revoke rights tests depend on" if $ENV{'TEST_VERBOSE'}; } } -diag "Test new ticket creation by root who is privileged and superuser" if $ENV{'TEST_VERBOSE'}; +diag "Test new ticket creation by root who is privileged and superuser"; { my $text = <send_via_mailgate($text); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text); is ($status >> 8, 0, "The mail gateway exited normally"); ok ($id, "Created ticket"); @@ -129,9 +131,10 @@ EOF isa_ok ($tick, 'RT::Ticket'); is ($tick->Id, $id, "correct ticket id"); is ($tick->Subject , 'This is a test of new ticket creation', "Created the ticket"); + $m->no_warnings_ok; } -diag "Test the 'X-RT-Mail-Extension' field in the header of a ticket" if $ENV{'TEST_VERBOSE'}; +diag "Test the 'X-RT-Mail-Extension' field in the header of a ticket"; { my $text = <send_via_mailgate($text); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text); is ($status >> 8, 0, "The mail gateway exited normally"); ok ($id, "Created ticket #$id"); @@ -165,9 +168,10 @@ EOF "bad value with newlines", 'header is in place, without trailing newline char' ); + $m->no_warnings_ok; } -diag "Make sure that not standard --extension is passed" if $ENV{'TEST_VERBOSE'}; +diag "Make sure that not standard --extension is passed"; { my $text = <send_via_mailgate($text, extension => 'some-extension-arg' ); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, extension => 'some-extension-arg' ); is ($status >> 8, 0, "The mail gateway exited normally"); ok ($id, "Created ticket #$id"); @@ -198,9 +202,10 @@ EOF 'some-extension-arg', 'header is in place' ); + $m->no_warnings_ok; } -diag "Test new ticket creation without --action argument" if $ENV{'TEST_VERBOSE'}; +diag "Test new ticket creation without --action argument"; { my $text = <send_via_mailgate($text, extension => 'some-extension-arg' ); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, extension => 'some-extension-arg' ); is ($status >> 8, 0, "The mail gateway exited normally"); ok ($id, "Created ticket #$id"); @@ -218,9 +223,10 @@ EOF isa_ok ($tick, 'RT::Ticket'); is ($tick->Id, $id, "correct ticket id"); is ($tick->Subject, 'using mailgate without --action arg', "using mailgate without --action arg"); + $m->no_warnings_ok; } -diag "This is a test of new ticket creation as an unknown user" if $ENV{'TEST_VERBOSE'}; +diag "This is a test of new ticket creation as an unknown user"; { my $text = <Config->Get('rtname')]} @@ -230,7 +236,7 @@ Subject: This is a test of new ticket creation as an unknown user Blah! Foob! EOF - my ($status, $id) = RT::Test->send_via_mailgate($text); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text); is ($status >> 8, 0, "The mail gateway exited normally"); ok (!$id, "no ticket created"); @@ -239,12 +245,19 @@ EOF ok ($tick->Id, "found ticket ".$tick->Id); isnt ($tick->Subject , 'This is a test of new ticket creation as an unknown user', "failed to create the new ticket from an unprivileged account"); - my $u = RT::User->new($RT::SystemUser); + my $u = RT::User->new(RT->SystemUser); $u->Load("doesnotexist\@@{[RT->Config->Get('rtname')]}"); ok( !$u->Id, "user does not exist and was not created by failed ticket submission"); + + $m->next_warning_like(qr/RT's configuration does not allow\s+for the creation of a new user for this email/); + $m->next_warning_like(qr/RT could not load a valid user/); + TODO: { + local $TODO = "we're a bit noisy for this warning case"; + $m->no_leftover_warnings_ok; + } } -diag "grant everybody with CreateTicket right" if $ENV{'TEST_VERBOSE'}; +diag "grant everybody with CreateTicket right"; { ok( RT::Test->set_rights( { Principal => $everyone_group->PrincipalObj, @@ -254,7 +267,7 @@ diag "grant everybody with CreateTicket right" if $ENV{'TEST_VERBOSE'}; } my $ticket_id; -diag "now everybody can create tickets. can a random unkown user create tickets?" if $ENV{'TEST_VERBOSE'}; +diag "now everybody can create tickets. can a random unkown user create tickets?"; { my $text = <Config->Get('rtname')]} @@ -264,7 +277,7 @@ Subject: This is a test of new ticket creation as an unknown user Blah! Foob! EOF - my ($status, $id) = RT::Test->send_via_mailgate($text); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text); is ($status >> 8, 0, "The mail gateway exited normally"); ok ($id, "ticket created"); @@ -274,13 +287,14 @@ EOF is ($tick->Id, $id, "correct ticket id"); is ($tick->Subject , 'This is a test of new ticket creation as an unknown user', "failed to create the new ticket from an unprivileged account"); - my $u = RT::User->new( $RT::SystemUser ); + my $u = RT::User->new( RT->SystemUser ); $u->Load( "doesnotexist\@@{[RT->Config->Get('rtname')]}" ); ok ($u->Id, "user does not exist and was created by ticket submission"); $ticket_id = $id; + $m->no_warnings_ok; } -diag "can another random reply to a ticket without being granted privs? answer should be no." if $ENV{'TEST_VERBOSE'}; +diag "can another random reply to a ticket without being granted privs? answer should be no."; { my $text = <Config->Get('rtname')]} @@ -290,16 +304,21 @@ Subject: [@{[RT->Config->Get('rtname')]} #$ticket_id] This is a test of a reply Blah! (Should not work.) Foob! EOF - my ($status, $id) = RT::Test->send_via_mailgate($text); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text); is ($status >> 8, 0, "The mail gateway exited normally"); ok (!$id, "no way to reply to the ticket"); - my $u = RT::User->new($RT::SystemUser); + my $u = RT::User->new(RT->SystemUser); $u->Load('doesnotexist-2@'.RT->Config->Get('rtname')); ok( !$u->Id, " user does not exist and was not created by ticket correspondence submission"); + $m->next_warning_like(qr/RT's configuration does not allow\s+for the creation of a new user for this email \(doesnotexist-2\@example\.com\)/); + TODO: { + local $TODO = "we're a bit noisy for this warning case"; + $m->no_leftover_warnings_ok; + } } -diag "grant everyone 'ReplyToTicket' right" if $ENV{'TEST_VERBOSE'}; +diag "grant everyone 'ReplyToTicket' right"; { ok( RT::Test->set_rights( { Principal => $everyone_group->PrincipalObj, @@ -308,7 +327,7 @@ diag "grant everyone 'ReplyToTicket' right" if $ENV{'TEST_VERBOSE'}; ), "Granted everybody the right to reply to tickets" ); } -diag "can another random reply to a ticket after being granted privs? answer should be yes" if $ENV{'TEST_VERBOSE'}; +diag "can another random reply to a ticket after being granted privs? answer should be yes"; { my $text = <Config->Get('rtname')]} @@ -318,16 +337,17 @@ Subject: [@{[RT->Config->Get('rtname')]} #$ticket_id] This is a test of a reply Blah! Foob! EOF - my ($status, $id) = RT::Test->send_via_mailgate($text); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text); is ($status >> 8, 0, "The mail gateway exited normally"); is ($id, $ticket_id, "replied to the ticket"); - my $u = RT::User->new($RT::SystemUser); + my $u = RT::User->new(RT->SystemUser); $u->Load('doesnotexist-2@'.RT->Config->Get('rtname')); ok ($u->Id, "user exists and was created by ticket correspondence submission"); + $m->no_warnings_ok; } -diag "add a reply to the ticket using '--extension ticket' feature" if $ENV{'TEST_VERBOSE'}; +diag "add a reply to the ticket using '--extension ticket' feature"; { my $text = <Config->Get('rtname')]} @@ -338,7 +358,7 @@ Blah! Foob! EOF local $ENV{'EXTENSION'} = $ticket_id; - my ($status, $id) = RT::Test->send_via_mailgate($text, extension => 'ticket'); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, extension => 'ticket'); is ($status >> 8, 0, "The mail gateway exited normally"); is ($id, $ticket_id, "replied to the ticket"); @@ -357,9 +377,10 @@ EOF my $attachment = $txn->Attachments->First; isa_ok ($attachment, 'RT::Attachment'); is ($attachment->GetHeader('X-RT-Mail-Extension'), $id, 'header is in place'); + $m->no_warnings_ok; } -diag "can another random comment on a ticket without being granted privs? answer should be no" if $ENV{'TEST_VERBOSE'}; +diag "can another random comment on a ticket without being granted privs? answer should be no"; { my $text = <Config->Get('rtname')]} @@ -369,17 +390,22 @@ Subject: [@{[RT->Config->Get('rtname')]} #$ticket_id] This is a test of a commen Blah! (Should not work.) Foob! EOF - my ($status, $id) = RT::Test->send_via_mailgate($text, action => 'comment'); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, action => 'comment'); is ($status >> 8, 0, "The mail gateway exited normally"); ok (!$id, "no way to comment on the ticket"); - my $u = RT::User->new($RT::SystemUser); + my $u = RT::User->new(RT->SystemUser); $u->Load('doesnotexist-3@'.RT->Config->Get('rtname')); ok( !$u->Id, " user does not exist and was not created by ticket comment submission"); + $m->next_warning_like(qr/RT's configuration does not allow\s+for the creation of a new user for this email \(doesnotexist-3\@example\.com\)/); + TODO: { + local $TODO = "we're a bit noisy for this warning case"; + $m->no_leftover_warnings_ok; + } } -diag "grant everyone 'CommentOnTicket' right" if $ENV{'TEST_VERBOSE'}; +diag "grant everyone 'CommentOnTicket' right"; { ok( RT::Test->set_rights( { Principal => $everyone_group->PrincipalObj, @@ -388,7 +414,7 @@ diag "grant everyone 'CommentOnTicket' right" if $ENV{'TEST_VERBOSE'}; ), "Granted everybody the right to comment on tickets"); } -diag "can another random reply to a ticket after being granted privs? answer should be yes" if $ENV{'TEST_VERBOSE'}; +diag "can another random reply to a ticket after being granted privs? answer should be yes"; { my $text = <Config->Get('rtname')]} @@ -398,16 +424,17 @@ Subject: [@{[RT->Config->Get('rtname')]} #$ticket_id] This is a test of a commen Blah! Foob! EOF - my ($status, $id) = RT::Test->send_via_mailgate($text, action => 'comment'); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, action => 'comment'); is ($status >> 8, 0, "The mail gateway exited normally"); is ($id, $ticket_id, "replied to the ticket"); - my $u = RT::User->new($RT::SystemUser); + my $u = RT::User->new(RT->SystemUser); $u->Load('doesnotexist-3@'.RT->Config->Get('rtname')); ok ($u->Id, " user exists and was created by ticket comment submission"); + $m->no_warnings_ok; } -diag "add comment to the ticket using '--extension action' feature" if $ENV{'TEST_VERBOSE'}; +diag "add comment to the ticket using '--extension action' feature"; { my $text = <Config->Get('rtname')]} @@ -418,7 +445,7 @@ Blah! Foob! EOF local $ENV{'EXTENSION'} = 'comment'; - my ($status, $id) = RT::Test->send_via_mailgate($text, extension => 'action'); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text, extension => 'action'); is ($status >> 8, 0, "The mail gateway exited normally"); is ($id, $ticket_id, "added comment to the ticket"); @@ -442,12 +469,13 @@ EOF my $attachment = $txn->Attachments->First; isa_ok ($attachment, 'RT::Attachment'); is ($attachment->GetHeader('X-RT-Mail-Extension'), 'comment', 'header is in place'); + $m->no_warnings_ok; } -diag "Testing preservation of binary attachments" if $ENV{'TEST_VERBOSE'}; +diag "Testing preservation of binary attachments"; { # Get a binary blob (Best Practical logo) - my $LOGO_FILE = $RT::MasonComponentRoot .'/NoAuth/images/bplogo.gif'; + my $LOGO_FILE = $RT::MasonComponentRoot .'/NoAuth/images/bpslogo.png'; # Create a mime entity with an attachment my $entity = MIME::Entity->build( @@ -459,11 +487,11 @@ diag "Testing preservation of binary attachments" if $ENV{'TEST_VERBOSE'}; $entity->attach( Path => $LOGO_FILE, - Type => 'image/gif', + Type => 'image/png', Encoding => 'base64', ); # Create a ticket with a binary attachment - my ($status, $id) = RT::Test->send_via_mailgate($entity); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($entity); is ($status >> 8, 0, "The mail gateway exited normally"); ok ($id, "created ticket"); @@ -475,11 +503,11 @@ diag "Testing preservation of binary attachments" if $ENV{'TEST_VERBOSE'}; my $file = `cat $LOGO_FILE`; ok ($file, "Read in the logo image"); - diag "for the raw file the md5 hex is ". Digest::MD5::md5_hex($file) if $ENV{'TEST_VERBOSE'}; + diag "for the raw file the md5 hex is ". Digest::MD5::md5_hex($file); # Verify that the binary attachment is valid in the database - my $attachments = RT::Attachments->new($RT::SystemUser); - $attachments->Limit(FIELD => 'ContentType', VALUE => 'image/gif'); + my $attachments = RT::Attachments->new(RT->SystemUser); + $attachments->Limit(FIELD => 'ContentType', VALUE => 'image/png'); my $txn_alias = $attachments->Join( ALIAS1 => 'main', FIELD1 => 'TransactionId', @@ -488,25 +516,27 @@ diag "Testing preservation of binary attachments" if $ENV{'TEST_VERBOSE'}; ); $attachments->Limit( ALIAS => $txn_alias, FIELD => 'ObjectType', VALUE => 'RT::Ticket' ); $attachments->Limit( ALIAS => $txn_alias, FIELD => 'ObjectId', VALUE => $id ); - is ($attachments->Count, 1, 'Found only one gif attached to the ticket'); + is ($attachments->Count, 1, 'Found only one png attached to the ticket'); my $attachment = $attachments->First; ok ($attachment->Id, 'loaded attachment object'); my $acontent = $attachment->Content; - diag "coming from the database, md5 hex is ".Digest::MD5::md5_hex($acontent) if $ENV{'TEST_VERBOSE'}; + diag "coming from the database, md5 hex is ".Digest::MD5::md5_hex($acontent); is ($acontent, $file, 'The attachment isn\'t screwed up in the database.'); # Grab the binary attachment via the web ui my $ua = new LWP::UserAgent; my $full_url = "$url/Ticket/Attachment/". $attachment->TransactionId - ."/". $attachment->id. "/bplogo.gif?&user=root&pass=password"; + ."/". $attachment->id. "/bpslogo.png?&user=root&pass=password"; my $r = $ua->get( $full_url ); # Verify that the downloaded attachment is the same as what we uploaded. is ($file, $r->content, 'The attachment isn\'t screwed up in download'); + + $m->no_warnings_ok; } -diag "Simple I18N testing" if $ENV{'TEST_VERBOSE'}; +diag "Simple I18N testing"; { my $text = <send_via_mailgate($text); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text); is ($status >> 8, 0, "The mail gateway exited normally"); ok ($id, "created ticket"); @@ -540,9 +570,11 @@ EOF $tick->Transactions->First->Content =~ /$unistring/i, $tick->Id." appears to be unicode ". $tick->Transactions->First->Attachments->First->Id ); + + $m->no_warnings_ok; } -diag "supposedly I18N fails on the second message sent in." if $ENV{'TEST_VERBOSE'}; +diag "supposedly I18N fails on the second message sent in."; { my $text = <send_via_mailgate($text); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text); is ($status >> 8, 0, "The mail gateway exited normally"); ok ($id, "created ticket"); @@ -572,9 +604,40 @@ EOF $tick->Transactions->First->Content =~ $unistring, "It appears to be unicode - ". $tick->Transactions->First->Content ); + + $m->no_warnings_ok; +} + +diag "make sure we check that UTF-8 is really UTF-8"; +{ + my $text = <Config->Get('rtname')]} +Subject: This is test wrong utf-8 chars +Content-Type: text/plain; charset="utf-8" + +utf-8: informaci\303\263n confidencial +latin1: informaci\363n confidencial + +bye +EOF + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text); + is ($status >> 8, 0, "The mail gateway exited normally"); + ok ($id, "created ticket"); + + my $tick = RT::Test->last_ticket; + is ($tick->Id, $id, "correct ticket"); + + my $content = $tick->Transactions->First->Content; + Encode::_utf8_off($content); + + like $content, qr{informaci\303\263n confidencial}; + like $content, qr{informaci\357\277\275n confidencial}; + + $m->no_warnings_ok; } -diag "check that mailgate doesn't suffer from empty Reply-To:" if $ENV{'TEST_VERBOSE'}; +diag "check that mailgate doesn't suffer from empty Reply-To:"; { my $text = <send_via_mailgate($text); + my ($status, $id) = RT::Test->send_via_mailgate_and_http($text); is ($status >> 8, 0, "The mail gateway exited normally"); ok ($id, "created ticket"); @@ -595,6 +658,8 @@ EOF is ($tick->Id, $id, "correct ticket"); like $tick->RequestorAddresses, qr/root\@localhost/, 'correct requestor'; + + $m->no_warnings_ok; } @@ -607,18 +672,17 @@ skip "Advanced mailgate actions require an unsafe configuration", 47 # create new queue to be shure we don't mess with rights use RT::Queue; -my $queue = RT::Queue->new($RT::SystemUser); +my $queue = RT::Queue->new(RT->SystemUser); my ($qid) = $queue->Create( Name => 'ext-mailgate'); ok( $qid, 'queue created for ext-mailgate tests' ); -# {{{ Check take and resolve actions # create ticket that is owned by nobody use RT::Ticket; -my $tick = RT::Ticket->new($RT::SystemUser); +my $tick = RT::Ticket->new(RT->SystemUser); my ($id) = $tick->Create( Queue => 'ext-mailgate', Subject => 'test'); ok( $id, 'new ticket created' ); -is( $tick->Owner, $RT::Nobody->Id, 'owner of the new ticket is nobody' ); +is( $tick->Owner, RT->Nobody->Id, 'owner of the new ticket is nobody' ); $! = 0; ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take"), "Opened the mailgate - $!"); @@ -630,7 +694,7 @@ EOF close (MAIL); is ($? >> 8, 0, "The mail gateway exited normally"); -$tick = RT::Ticket->new($RT::SystemUser); +$tick = RT::Ticket->new(RT->SystemUser); $tick->Load( $id ); is( $tick->Id, $id, 'load correct ticket'); is( $tick->OwnerObj->EmailAddress, 'root@localhost', 'successfuly take ticket via email'); @@ -639,9 +703,11 @@ is( $tick->OwnerObj->EmailAddress, 'root@localhost', 'successfuly take ticket vi is( $tick->Transactions->Count, 2, 'no superfluous transactions'); my $status; -($status, $msg) = $tick->SetOwner( $RT::Nobody->Id, 'Force' ); +($status, $msg) = $tick->SetOwner( RT->Nobody->Id, 'Force' ); ok( $status, 'successfuly changed owner: '. ($msg||'') ); -is( $tick->Owner, $RT::Nobody->Id, 'set owner back to nobody'); +is( $tick->Owner, RT->Nobody->Id, 'set owner back to nobody'); + +$m->no_warnings_ok; $! = 0; @@ -657,7 +723,7 @@ is ($? >> 8, 0, "The mail gateway exited normally"); DBIx::SearchBuilder::Record::Cachable->FlushCache; -$tick = RT::Ticket->new($RT::SystemUser); +$tick = RT::Ticket->new(RT->SystemUser); $tick->Load( $id ); is( $tick->Id, $id, "load correct ticket #$id"); is( $tick->OwnerObj->EmailAddress, 'root@localhost', 'successfuly take ticket via email'); @@ -668,6 +734,9 @@ $txns->OrderBy( FIELD => 'id', ORDER => 'DESC' ); is( $tick->Transactions->Count, 6, 'no superfluous transactions'); is( $txns->First->Subject, "[$RT::rtname \#$id] correspondence", 'successfuly add correspond within take via email' ); +$m->no_warnings_ok; + + $! = 0; ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action resolve"), "Opened the mailgate - $!"); print MAIL <> 8, 0, "The mail gateway exited normally"); DBIx::SearchBuilder::Record::Cachable->FlushCache; -$tick = RT::Ticket->new($RT::SystemUser); +$tick = RT::Ticket->new(RT->SystemUser); $tick->Load( $id ); is( $tick->Id, $id, 'load correct ticket'); is( $tick->Status, 'resolved', 'successfuly resolved ticket via email'); is( $tick->Transactions->Count, 7, 'no superfluous transactions'); use RT::User; -my $user = RT::User->new( $RT::SystemUser ); +my $user = RT::User->new( RT->SystemUser ); my ($uid) = $user->Create( Name => 'ext-mailgate', EmailAddress => 'ext-mailgate@localhost', Privileged => 1, @@ -696,12 +765,14 @@ my ($uid) = $user->Create( Name => 'ext-mailgate', ok( $uid, 'user created for ext-mailgate tests' ); ok( !$user->HasRight( Right => 'OwnTicket', Object => $queue ), "User can't own ticket" ); -$tick = RT::Ticket->new($RT::SystemUser); +$tick = RT::Ticket->new(RT->SystemUser); ($id) = $tick->Create( Queue => $qid, Subject => 'test' ); ok( $id, 'create new ticket' ); my $rtname = RT->Config->Get('rtname'); +$m->no_warnings_ok; + $! = 0; ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take"), "Opened the mailgate - $!"); print MAIL <HasRight( Right => 'ReplyToTicket', Object => $tick ), "User can reply to ticket" ); +$m->next_warning_like(qr/Permission Denied/); +$m->next_warning_like(qr/Could not record email: Ticket not taken/); +$m->no_leftover_warnings_ok; + $! = 0; ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action correspond-take"), "Opened the mailgate - $!"); print MAIL <FlushCache; cmp_ok( $tick->Owner, '!=', $user->id, "we didn't change owner" ); is( $tick->Transactions->Count, 3, "one transactions added" ); +$m->next_warning_like(qr/Permission Denied/); +$m->next_warning_like(qr/Could not record email: Ticket not taken/); +$m->no_leftover_warnings_ok; + $! = 0; ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take-correspond"), "Opened the mailgate - $!"); print MAIL <FlushCache; cmp_ok( $tick->Owner, '!=', $user->id, "we didn't change owner" ); is( $tick->Transactions->Count, 3, "no transactions added, user can't take ticket first" ); +$m->next_warning_like(qr/Permission Denied/); +$m->next_warning_like(qr/Could not record email: Ticket not taken/); +$m->no_leftover_warnings_ok; + # revoke ReplyToTicket right use RT::ACE; -my $ace = RT::ACE->new($RT::SystemUser); +my $ace = RT::ACE->new(RT->SystemUser); $ace->Load( $ace_id ); $ace->Delete; -my $acl = RT::ACL->new($RT::SystemUser); +my $acl = RT::ACL->new(RT->SystemUser); $acl->Limit( FIELD => 'RightName', VALUE => 'ReplyToTicket' ); $acl->LimitToObject( $RT::System ); while( my $ace = $acl->Next ) { @@ -765,9 +848,9 @@ while( my $ace = $acl->Next ) { ok( !$user->HasRight( Right => 'ReplyToTicket', Object => $tick ), "User can't reply to ticket any more" ); -my $group = RT::Group->new( $RT::SystemUser ); +my $group = RT::Group->new( RT->SystemUser ); ok( $group->LoadQueueRoleGroup( Queue => $qid, Type=> 'Owner' ), "load queue owners role group" ); -$ace = RT::ACE->new( $RT::SystemUser ); +$ace = RT::ACE->new( RT->SystemUser ); ($ace_id, $msg) = $group->PrincipalObj->GrantRight( Right => 'ReplyToTicket', Object => $queue ); ok( $ace_id, "Granted queue owners role group with ReplyToTicket right" ); @@ -793,10 +876,7 @@ is( $tick->Owner, $user->id, "we changed owner" ); ok( $user->HasRight( Right => 'ReplyToTicket', Object => $tick ), "owner can reply to ticket" ); is( $tick->Transactions->Count, 5, "transactions added" ); +$m->no_warnings_ok; -# }}} }; - -1; -