summaryrefslogtreecommitdiff
path: root/rt/t/mail
diff options
context:
space:
mode:
Diffstat (limited to 'rt/t/mail')
-rw-r--r--rt/t/mail/gnupg-special.t45
-rw-r--r--rt/t/mail/wrong_mime_charset.t10
2 files changed, 52 insertions, 3 deletions
diff --git a/rt/t/mail/gnupg-special.t b/rt/t/mail/gnupg-special.t
index 7e50819e8..6a31ef131 100644
--- a/rt/t/mail/gnupg-special.t
+++ b/rt/t/mail/gnupg-special.t
@@ -2,13 +2,15 @@
use strict;
use warnings;
-use RT::Test tests => 11;
+use RT::Test tests => 23;
plan skip_all => 'GnuPG required.'
unless eval 'use GnuPG::Interface; 1';
plan skip_all => 'gpg executable is required.'
unless RT::Test->find_executable('gpg');
+use Digest::MD5 qw(md5_hex);
+
use File::Temp qw(tempdir);
my $homedir = tempdir( CLEANUP => 1 );
@@ -21,6 +23,7 @@ RT->Config->Set( 'GnuPG',
RT->Config->Set( 'GnuPGOptions',
homedir => $homedir,
+ 'passphrase' => 'rt-test',
'no-permission-warning' => undef);
RT->Config->Set( 'MailPlugins' => 'Auth::MailFrom', 'Auth::GnuPG' );
@@ -71,6 +74,46 @@ RT::Test->set_rights(
is(scalar @mail, 1, "autoreply only");
}
+{
+ my $id = send_via_mailgate('binary-asc-attach-marked-plain-text.txt');
+
+ my $tick = RT::Ticket->new( $RT::SystemUser );
+ $tick->Load( $id );
+ ok ($tick->id, "loaded ticket #$id");
+
+ my $txn = $tick->Transactions->First;
+ my ($msg, @attachs) = @{$txn->Attachments->ItemsArrayRef};
+
+ is (scalar @attachs, 3, 'text, attachment and original');
+ my $bin = $attachs[1];
+ is(
+ (split /;/, $bin->GetHeader('Content-Type'))[0],
+ 'application/octet-stream',
+ 'binary attachment'
+ );
+ is(md5_hex($bin->Content), '1e35f1aa90c98ca2bab85c26ae3e1ba7', "correct png");
+}
+
+{
+ my $id = send_via_mailgate('inline-binary-attachment-with-wrap.txt');
+
+ my $tick = RT::Ticket->new( $RT::SystemUser );
+ $tick->Load( $id );
+ ok ($tick->id, "loaded ticket #$id");
+
+ my $txn = $tick->Transactions->First;
+ my ($msg, @attachs) = @{$txn->Attachments->ItemsArrayRef};
+
+ is (scalar @attachs, 3, 'text, attachment and original');
+ my $bin = $attachs[1];
+ is(
+ (split /;/, $bin->GetHeader('Content-Type'))[0],
+ 'application/octet-stream',
+ 'binary attachment'
+ );
+ is(md5_hex($bin->Content), '1e35f1aa90c98ca2bab85c26ae3e1ba7', "correct png");
+}
+
sub send_via_mailgate {
my $fname = shift;
my $emaildatadir = RT::Test::get_relocatable_dir(File::Spec->updir(),
diff --git a/rt/t/mail/wrong_mime_charset.t b/rt/t/mail/wrong_mime_charset.t
index f53c872e5..71a574f26 100644
--- a/rt/t/mail/wrong_mime_charset.t
+++ b/rt/t/mail/wrong_mime_charset.t
@@ -9,17 +9,23 @@ use Encode;
my $test_string = 'À';
my $encoded_string = encode( 'iso-8859-1', $test_string );
my $mime = MIME::Entity->build(
- Subject => $encoded_string,
- Data => [$encoded_string],
+ "Subject" => $encoded_string,
+ "Data" => [$encoded_string],
);
# set the wrong charset mime in purpose
$mime->head->mime_attr( "Content-Type.charset" => 'utf8' );
RT::I18N::SetMIMEEntityToEncoding( $mime, 'iso-8859-1' );
+
+TODO: {
+ local $TODO =
+'need a better approach of encoding converter, should be fixed in 4.2';
+
my $subject = decode( 'iso-8859-1', $mime->head->get('Subject') );
chomp $subject;
is( $subject, $test_string, 'subject is set to iso-8859-1' );
my $body = decode( 'iso-8859-1', $mime->stringify_body );
chomp $body;
is( $body, $test_string, 'body is set to iso-8859-1' );
+}