diff options
author | ivan <ivan> | 2011-04-18 23:15:19 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-04-18 23:15:19 +0000 |
commit | 75162bb14b3e38d66617077843f4dfdcaf09d5c4 (patch) | |
tree | d89dd49a476cf2f0859ed6a0adc2992ea6d69d04 /rt/t/mail | |
parent | fc6209f398899f0211cfcedeb81a3cd65e04a941 (diff) |
import rt 3.8.10
Diffstat (limited to 'rt/t/mail')
-rw-r--r-- | rt/t/mail/charsets-outgoing.t | 9 | ||||
-rw-r--r-- | rt/t/mail/crypt-gnupg.t | 2 | ||||
-rw-r--r-- | rt/t/mail/extractsubjecttag.t | 8 | ||||
-rw-r--r-- | rt/t/mail/gateway.t | 14 | ||||
-rw-r--r-- | rt/t/mail/multipart.t | 96 |
5 files changed, 104 insertions, 25 deletions
diff --git a/rt/t/mail/charsets-outgoing.t b/rt/t/mail/charsets-outgoing.t index e8f78cc1a..e3f13fb6c 100644 --- a/rt/t/mail/charsets-outgoing.t +++ b/rt/t/mail/charsets-outgoing.t @@ -320,12 +320,3 @@ foreach my $set ( 'ru', 'latin1' ) { } } # subject tag set - -sub parse_mail { - my $mail = shift; - require RT::EmailParser; - my $parser = new RT::EmailParser; - $parser->ParseMIMEEntityFromScalar( $mail ); - return $parser->Entity; -} - diff --git a/rt/t/mail/crypt-gnupg.t b/rt/t/mail/crypt-gnupg.t index f33fbab1c..cc52dd631 100644 --- a/rt/t/mail/crypt-gnupg.t +++ b/rt/t/mail/crypt-gnupg.t @@ -285,7 +285,7 @@ diag 'wrong signed/encrypted parts: wrong proto' if $ENV{'TEST_VERBOSE'}; diag 'verify inline and in attachment signatures' if $ENV{'TEST_VERBOSE'}; { - open my $fh, "$homedir/signed_old_style_with_attachment.eml"; + open( my $fh, '<', "$homedir/signed_old_style_with_attachment.eml" ) or die $!; my $parser = new MIME::Parser; my $entity = $parser->parse( $fh ); diff --git a/rt/t/mail/extractsubjecttag.t b/rt/t/mail/extractsubjecttag.t index 5a2548883..fcaba8c98 100644 --- a/rt/t/mail/extractsubjecttag.t +++ b/rt/t/mail/extractsubjecttag.t @@ -88,11 +88,3 @@ EOF unlike($freshticket->Subject,qr/\[\Q$subject_tag\E #$ticketid\]/,'Stripped Queue Subject Tag correctly'); } - -sub parse_mail { - my $mail = shift; - require RT::EmailParser; - my $parser = new RT::EmailParser; - $parser->ParseMIMEEntityFromScalar( $mail ); - return $parser->Entity; -} diff --git a/rt/t/mail/gateway.t b/rt/t/mail/gateway.t index 00de1ec7f..d57b063a2 100644 --- a/rt/t/mail/gateway.t +++ b/rt/t/mail/gateway.t @@ -621,7 +621,7 @@ ok( $id, 'new ticket created' ); 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 - $!"); +ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take"), "Opened the mailgate - $!"); print MAIL <<EOF; From: root\@localhost Subject: [@{[RT->Config->Get('rtname')]} \#$id] test @@ -645,7 +645,7 @@ is( $tick->Owner, $RT::Nobody->Id, 'set owner back to nobody'); $! = 0; -ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take-correspond"), "Opened the mailgate - $@"); +ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take-correspond"), "Opened the mailgate - $@"); print MAIL <<EOF; From: root\@localhost Subject: [@{[RT->Config->Get('rtname')]} \#$id] correspondence @@ -669,7 +669,7 @@ is( $tick->Transactions->Count, 6, 'no superfluous transactions'); is( $txns->First->Subject, "[$RT::rtname \#$id] correspondence", 'successfuly add correspond within take via email' ); $! = 0; -ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action resolve"), "Opened the mailgate - $!"); +ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action resolve"), "Opened the mailgate - $!"); print MAIL <<EOF; From: root\@localhost Subject: [@{[RT->Config->Get('rtname')]} \#$id] test @@ -703,7 +703,7 @@ ok( $id, 'create new ticket' ); my $rtname = RT->Config->Get('rtname'); $! = 0; -ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take"), "Opened the mailgate - $!"); +ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take"), "Opened the mailgate - $!"); print MAIL <<EOF; From: ext-mailgate\@localhost Subject: [$rtname \#$id] test @@ -721,7 +721,7 @@ my $ace_id = $status; ok( $user->HasRight( Right => 'ReplyToTicket', Object => $tick ), "User can reply to ticket" ); $! = 0; -ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action correspond-take"), "Opened the mailgate - $!"); +ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action correspond-take"), "Opened the mailgate - $!"); print MAIL <<EOF; From: ext-mailgate\@localhost Subject: [$rtname \#$id] test @@ -736,7 +736,7 @@ cmp_ok( $tick->Owner, '!=', $user->id, "we didn't change owner" ); is( $tick->Transactions->Count, 3, "one transactions added" ); $! = 0; -ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take-correspond"), "Opened the mailgate - $!"); +ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take-correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; From: ext-mailgate\@localhost Subject: [$rtname \#$id] test @@ -777,7 +777,7 @@ ok( $status, "successfuly granted right: $msg" ); ok( $status, "successfuly granted right: $msg" ); $! = 0; -ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take-correspond"), "Opened the mailgate - $!"); +ok(open(MAIL, '|-', "$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take-correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; From: ext-mailgate\@localhost Subject: [$rtname \#$id] test diff --git a/rt/t/mail/multipart.t b/rt/t/mail/multipart.t new file mode 100644 index 000000000..dc97b266f --- /dev/null +++ b/rt/t/mail/multipart.t @@ -0,0 +1,96 @@ +#!/usr/bin/perl -w +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# <jesse.com> +# +# (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; + +use RT::Test tests => 5; +use RT::Test::Email; +my ($baseurl, $m) = RT::Test->started_ok; + +my $queue = RT::Test->load_or_create_queue( Name => 'General' ); +my $user = RT::Test->load_or_create_user( Name => 'bob', EmailAddress => 'bob@example.com' ); +$queue->AddWatcher( Type => 'AdminCc', PrincipalId => $user->PrincipalObj->Id ); + +my $text = <<EOF; +Subject: Badly handled multipart email +From: root\@localhost +To: rt\@@{[RT->Config->Get('rtname')]} +Content-Type: multipart/alternative; boundary=20cf3071cac0cb9772049eb22371 + +--20cf3071cac0cb9772049eb22371 +Content-Type: text/plain; charset=ISO-8859-1 + +Hi + +--20cf3071cac0cb9772049eb22371 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable + +<div>Hi</div> + +--20cf3071cac0cb9772049eb22371-- +EOF + +my ( $status, $id ) = RT::Test->send_via_mailgate($text); +is( $status >> 8, 0, "The mail gateway exited normally" ); +ok( $id, "Created ticket" ); + +my @msgs = RT::Test->fetch_caught_mails; +is(@msgs,2,"sent 2 emails"); +diag("We're skipping any testing of the autoreply"); + +my $entity = parse_mail($msgs[1]); +is($entity->parts, 0, "only one entity"); |