X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Ft%2Fmail%2Fgnupg-special.t;h=15aad3489c6b9e2179f0e44cf300bcabb43ac698;hb=72ad2f16955e4593891bb851243f8a6de9c3fb80;hp=7e50819e8824361cc51dba8cf5f861e654efa6fa;hpb=fc6209f398899f0211cfcedeb81a3cd65e04a941;p=freeside.git diff --git a/rt/t/mail/gnupg-special.t b/rt/t/mail/gnupg-special.t index 7e50819e8..15aad3489 100644 --- a/rt/t/mail/gnupg-special.t +++ b/rt/t/mail/gnupg-special.t @@ -1,29 +1,9 @@ -#!/usr/bin/perl use strict; use warnings; -use RT::Test tests => 11; +use RT::Test::GnuPG tests => 25, gnupg_options => { passphrase => 'rt-test' }; -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 File::Temp qw(tempdir); -my $homedir = tempdir( CLEANUP => 1 ); - -# catch any outgoing emails -RT::Test->set_mail_catcher; - -RT->Config->Set( 'GnuPG', - Enable => 1, - OutgoingMessagesFormat => 'RFC' ); - -RT->Config->Set( 'GnuPGOptions', - homedir => $homedir, - 'no-permission-warning' => undef); - -RT->Config->Set( 'MailPlugins' => 'Auth::MailFrom', 'Auth::GnuPG' ); +use Digest::MD5 qw(md5_hex); RT::Test->import_gnupg_key('rt-recipient@example.com'); RT::Test->import_gnupg_key('rt-test@example.com', 'public'); @@ -43,19 +23,14 @@ ok( $m->login, 'we did log in' ); $m->content_like(qr/rt-recipient\@example.com.* - never/, 'has key info.'); } -ok(my $user = RT::User->new($RT::SystemUser)); +ok(my $user = RT::User->new(RT->SystemUser)); ok($user->Load('root'), "Loaded user 'root'"); $user->SetEmailAddress('recipient@example.com'); -RT::Test->set_rights( - Principal => 'Everyone', - Right => ['CreateTicket'], -); - { my $id = send_via_mailgate('quoted_inline_signature.txt'); - my $tick = RT::Ticket->new( $RT::SystemUser ); + my $tick = RT::Ticket->new( RT->SystemUser ); $tick->Load( $id ); ok ($tick->id, "loaded ticket #$id"); @@ -71,6 +46,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(),