X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Ft%2Fmail%2Fgateway.t;h=89b1b60ab3eabebb70ac5fa7f9f8493a92d72634;hb=84bc64eeaa9650333fbbb79ecb03a1aff4a347fd;hp=98eabd56ef153a1f839e24014e388a5882988c2f;hpb=3185fe4edea62dd3fa9818cf80902e96fe2a2d21;p=freeside.git diff --git a/rt/t/mail/gateway.t b/rt/t/mail/gateway.t index 98eabd56e..89b1b60ab 100644 --- a/rt/t/mail/gateway.t +++ b/rt/t/mail/gateway.t @@ -1,58 +1,3 @@ -#!/usr/bin/perl -w -# BEGIN BPS TAGGED BLOCK {{{ -# -# COPYRIGHT: -# -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC -# -# -# (Except where explicitly superseded by other copyright notices) -# -# -# LICENSE: -# -# This work is made available to you under the terms of Version 2 of -# the GNU General Public License. A copy of that license should have -# been provided with this software, but in any event can be snarfed -# from www.gnu.org. -# -# This work is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301 or visit their web page on the internet at -# http://www.gnu.org/copyleft/gpl.html. -# -# -# CONTRIBUTION SUBMISSION POLICY: -# -# (The following paragraph is not intended to limit the rights granted -# to you to modify and distribute this software under the terms of -# the GNU General Public License and is only of importance to you if -# you choose to contribute your changes and enhancements to the -# community by submitting them to Best Practical Solutions, LLC.) -# -# By intentionally submitting any modifications, corrections or -# derivatives to this work, or any other work intended for use with -# Request Tracker, to Best Practical Solutions, LLC, you confirm that -# you are the copyright holder for those contributions and you grant -# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, -# royalty-free, perpetual, license to use, copy, create derivative -# works based on those contributions, and sublicense and distribute -# those contributions and any derivatives thereof. -# -# END BPS TAGGED BLOCK }}} - -=head1 NAME - -rt-mailgate - Mail interface to RT3. - -=cut - use strict; use warnings; @@ -475,7 +420,7 @@ EOF diag "Testing preservation of binary attachments"; { # Get a binary blob (Best Practical logo) - my $LOGO_FILE = $RT::MasonComponentRoot .'/NoAuth/images/bpslogo.png'; + my $LOGO_FILE = $RT::StaticPath .'/images/bpslogo.png'; # Create a mime entity with an attachment my $entity = MIME::Entity->build( @@ -559,8 +504,7 @@ EOF is ($tick->Id, $id, "correct ticket"); is ($tick->Subject , 'This is a test of I18N ticket creation', "Created the ticket - ". $tick->Subject); - my $unistring = "\303\241\303\251\303\255\303\263\303\272"; - Encode::_utf8_on($unistring); + my $unistring = Encode::decode("UTF-8","\303\241\303\251\303\255\303\263\303\272"); is ( $tick->Transactions->First->Content, $tick->Transactions->First->Attachments->First->Content, @@ -597,8 +541,7 @@ EOF is ($tick->Id, $id, "correct ticket"); is ($tick->Subject , 'This is a test of I18N ticket creation', "Created the ticket"); - my $unistring = "\303\241\303\251\303\255\303\263\303\272"; - Encode::_utf8_on($unistring); + my $unistring = Encode::decode("UTF-8","\303\241\303\251\303\255\303\263\303\272"); ok ( $tick->Transactions->First->Content =~ $unistring, @@ -628,8 +571,7 @@ EOF my $tick = RT::Test->last_ticket; is ($tick->Id, $id, "correct ticket"); - my $content = $tick->Transactions->First->Content; - Encode::_utf8_off($content); + my $content = Encode::encode("UTF-8",$tick->Transactions->First->Content); like $content, qr{informaci\303\263n confidencial}; like $content, qr{informaci\357\277\275n confidencial}; @@ -694,13 +636,15 @@ EOF close (MAIL); is ($? >> 8, 0, "The mail gateway exited normally"); +DBIx::SearchBuilder::Record::Cachable->FlushCache; + $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'); -# check that there is no text transactions writen -is( $tick->Transactions->Count, 2, 'no superfluous transactions'); +# check that there is no text transactions writen (create + 2 for take) +is( $tick->Transactions->Count, 3, 'no superfluous transactions'); my $status; ($status, $msg) = $tick->SetOwner( RT->Nobody->Id, 'Force' ); @@ -730,8 +674,8 @@ is( $tick->OwnerObj->EmailAddress, 'root@localhost', 'successfuly take ticket vi my $txns = $tick->Transactions; $txns->Limit( FIELD => 'Type', VALUE => 'Correspond'); $txns->OrderBy( FIELD => 'id', ORDER => 'DESC' ); -# +1 because of auto open -is( $tick->Transactions->Count, 6, 'no superfluous transactions'); +# +2 from owner to nobody, +1 because of auto open, +2 from take, +1 from correspond +is( $tick->Transactions->Count, 9, 'no superfluous transactions'); is( $txns->First->Subject, "[$RT::rtname \#$id] correspondence", 'successfuly add correspond within take via email' ); $m->no_warnings_ok; @@ -753,15 +697,16 @@ $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'); +# +1 from resolve +is( $tick->Transactions->Count, 10, 'no superfluous transactions'); use RT::User; my $user = RT::User->new( RT->SystemUser ); my ($uid) = $user->Create( Name => 'ext-mailgate', - EmailAddress => 'ext-mailgate@localhost', - Privileged => 1, - Password => 'qwe123', - ); + EmailAddress => 'ext-mailgate@localhost', + Privileged => 1, + Password => 'qwe123', + ); ok( $uid, 'user created for ext-mailgate tests' ); ok( !$user->HasRight( Right => 'OwnTicket', Object => $queue ), "User can't own ticket" ); @@ -791,7 +736,7 @@ ok( $status, "successfuly granted right: $msg" ); my $ace_id = $status; ok( $user->HasRight( Right => 'ReplyToTicket', Object => $tick ), "User can reply to ticket" ); -$m->next_warning_like(qr/Permission Denied/); +$m->next_warning_like(qr/That user may not own tickets in that queue/); $m->next_warning_like(qr/Could not record email: Ticket not taken/); $m->no_leftover_warnings_ok; @@ -810,7 +755,7 @@ DBIx::SearchBuilder::Record::Cachable->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/That user may not own tickets in that queue/); $m->next_warning_like(qr/Could not record email: Ticket not taken/); $m->no_leftover_warnings_ok; @@ -829,7 +774,7 @@ DBIx::SearchBuilder::Record::Cachable->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/That user may not own tickets in that queue/); $m->next_warning_like(qr/Could not record email: Ticket not taken/); $m->no_leftover_warnings_ok; @@ -842,14 +787,14 @@ my $acl = RT::ACL->new(RT->SystemUser); $acl->Limit( FIELD => 'RightName', VALUE => 'ReplyToTicket' ); $acl->LimitToObject( $RT::System ); while( my $ace = $acl->Next ) { - $ace->Delete; + $ace->Delete; } ok( !$user->HasRight( Right => 'ReplyToTicket', Object => $tick ), "User can't reply to ticket any more" ); -my $group = RT::Group->new( RT->SystemUser ); -ok( $group->LoadQueueRoleGroup( Queue => $qid, Type=> 'Owner' ), "load queue owners role group" ); +my $group = $queue->RoleGroup( 'Owner' ); +ok( $group->Id, "load queue owners role group" ); $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" ); @@ -874,7 +819,8 @@ DBIx::SearchBuilder::Record::Cachable->FlushCache; $tick->Load( $id ); 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" ); +# +2 from take, +1 from correspond +is( $tick->Transactions->Count, 6, "transactions added" ); $m->no_warnings_ok;