[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.4-232-g6aac8b0

? sunnavy sunnavy at bestpractical.com
Fri Oct 29 04:57:32 EDT 2010


The branch, 3.9-trunk has been updated
       via  6aac8b0bf613c44fe75f348f62a93006ef9a890e (commit)
       via  a457d6323d496f324ec80b9d38ad8dc2fd898dbd (commit)
      from  c7b7e947e2049bcdd1664ef79af6f355337b2d0d (commit)

Summary of changes:
 lib/RT/Test/GnuPG.pm    |   66 ++++++++++++++++++++++++++++++++-
 t/mail/gnupg-outgoing.t |   95 ++---------------------------------------------
 2 files changed, 69 insertions(+), 92 deletions(-)

- Log -----------------------------------------------------------------
commit a457d6323d496f324ec80b9d38ad8dc2fd898dbd
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 29 16:44:34 2010 +0800

    abstract send_email_and_check_transaction

diff --git a/lib/RT/Test/GnuPG.pm b/lib/RT/Test/GnuPG.pm
index 387d010..6520d40 100644
--- a/lib/RT/Test/GnuPG.pm
+++ b/lib/RT/Test/GnuPG.pm
@@ -5,7 +5,9 @@ use base qw(RT::Test);
 use File::Temp qw(tempdir);
 use RT::Crypt::GnuPG;
 
-our @EXPORT = qw(create_a_ticket update_ticket cleanup_headers set_queue_crypt_options check_text_emails);
+our @EXPORT =
+  qw(create_a_ticket update_ticket cleanup_headers set_queue_crypt_options 
+          check_text_emails send_email_and_check_transaction);
 
 sub import {
     my $class = shift;
@@ -174,3 +176,65 @@ sub set_queue_crypt_options {
     $queue->SetSign($args{'Sign'});
 }
 
+sub send_email_and_check_transaction {
+    my $mail = shift;
+    my $type = shift;
+
+    my ( $status, $id ) = RT::Test->send_via_mailgate($mail);
+    is( $status >> 8, 0, "The mail gateway exited normally" );
+    ok( $id, "got id of a newly created ticket - $id" );
+
+    my $tick = RT::Ticket->new( RT->SystemUser );
+    $tick->Load($id);
+    ok( $tick->id, "loaded ticket #$id" );
+
+    my $txn = $tick->Transactions->First;
+    my ( $msg, @attachments ) = @{ $txn->Attachments->ItemsArrayRef };
+
+    if ( $attachments[0] ) {
+        like $attachments[0]->Content, qr/Some content/,
+          "RT's mail includes copy of ticket text";
+    }
+    else {
+        like $msg->Content, qr/Some content/,
+          "RT's mail includes copy of ticket text";
+    }
+
+    if ( $type eq 'plain' ) {
+        ok !$msg->GetHeader('X-RT-Privacy'), "RT's outgoing mail has no crypto";
+        is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Not encrypted',
+          "RT's outgoing mail looks not encrypted";
+        ok !$msg->GetHeader('X-RT-Incoming-Signature'),
+          "RT's outgoing mail looks not signed";
+    }
+    elsif ( $type eq 'signed' ) {
+        is $msg->GetHeader('X-RT-Privacy'), 'PGP',
+          "RT's outgoing mail has crypto";
+        is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Not encrypted',
+          "RT's outgoing mail looks not encrypted";
+        like $msg->GetHeader('X-RT-Incoming-Signature'),
+          qr/<rt-recipient\@example.com>/,
+          "RT's outgoing mail looks signed";
+    }
+    elsif ( $type eq 'encrypted' ) {
+        is $msg->GetHeader('X-RT-Privacy'), 'PGP',
+          "RT's outgoing mail has crypto";
+        is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Success',
+          "RT's outgoing mail looks encrypted";
+        ok !$msg->GetHeader('X-RT-Incoming-Signature'),
+          "RT's outgoing mail looks not signed";
+
+    }
+    elsif ( $type eq 'signed_encrypted' ) {
+        is $msg->GetHeader('X-RT-Privacy'), 'PGP',
+          "RT's outgoing mail has crypto";
+        is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Success',
+          "RT's outgoing mail looks encrypted";
+        like $msg->GetHeader('X-RT-Incoming-Signature'),
+          qr/<rt-recipient\@example.com>/,
+          "RT's outgoing mail looks signed";
+    }
+    else {
+        die "unknown type: $type";
+    }
+}
diff --git a/t/mail/gnupg-outgoing.t b/t/mail/gnupg-outgoing.t
index 9c75121..ef8a2b1 100644
--- a/t/mail/gnupg-outgoing.t
+++ b/t/mail/gnupg-outgoing.t
@@ -84,94 +84,9 @@ $queue = RT::Test->load_or_create_queue(
 );
 ok $queue && $queue->id, 'changed props of the queue';
 
-foreach my $mail ( map cleanup_headers($_), @{ $mail{'plain'} } ) {
-    my ($status, $id) = RT::Test->send_via_mailgate($mail);
-    is ($status >> 8, 0, "The mail gateway exited normally");
-    ok ($id, "got id of a newly created ticket - $id");
-
-    my $tick = RT::Ticket->new( RT->SystemUser );
-    $tick->Load( $id );
-    ok ($tick->id, "loaded ticket #$id");
-
-    my $txn = $tick->Transactions->First;
-    my ($msg, @attachments) = @{$txn->Attachments->ItemsArrayRef};
-
-    ok !$msg->GetHeader('X-RT-Privacy'), "RT's outgoing mail has no crypto";
-    is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Not encrypted',
-        "RT's outgoing mail looks not encrypted";
-    ok !$msg->GetHeader('X-RT-Incoming-Signature'),
-        "RT's outgoing mail looks not signed";
-
-    like $msg->Content, qr/Some content/, "RT's mail includes copy of ticket text";
-}
-
-foreach my $mail ( map cleanup_headers($_), @{ $mail{'signed'} } ) {
-    my ($status, $id) = RT::Test->send_via_mailgate($mail);
-    is ($status >> 8, 0, "The mail gateway exited normally");
-    ok ($id, "got id of a newly created ticket - $id");
-
-    my $tick = RT::Ticket->new( RT->SystemUser );
-    $tick->Load( $id );
-    ok ($tick->id, "loaded ticket #$id");
-
-    my $txn = $tick->Transactions->First;
-    my ($msg, @attachments) = @{$txn->Attachments->ItemsArrayRef};
-
-    is $msg->GetHeader('X-RT-Privacy'), 'PGP',
-        "RT's outgoing mail has crypto";
-    is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Not encrypted',
-        "RT's outgoing mail looks not encrypted";
-    like $msg->GetHeader('X-RT-Incoming-Signature'),
-        qr/<rt-recipient\@example.com>/,
-        "RT's outgoing mail looks signed";
-
-    like $attachments[0]->Content, qr/Some content/,
-        "RT's mail includes copy of ticket text";
-}
-
-foreach my $mail ( map cleanup_headers($_), @{ $mail{'encrypted'} } ) {
-    my ($status, $id) = RT::Test->send_via_mailgate($mail);
-    is ($status >> 8, 0, "The mail gateway exited normally");
-    ok ($id, "got id of a newly created ticket - $id");
-
-    my $tick = RT::Ticket->new( RT->SystemUser );
-    $tick->Load( $id );
-    ok ($tick->id, "loaded ticket #$id");
-
-    my $txn = $tick->Transactions->First;
-    my ($msg, @attachments) = @{$txn->Attachments->ItemsArrayRef};
-
-    is $msg->GetHeader('X-RT-Privacy'), 'PGP',
-        "RT's outgoing mail has crypto";
-    is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Success',
-        "RT's outgoing mail looks encrypted";
-    ok !$msg->GetHeader('X-RT-Incoming-Signature'),
-        "RT's outgoing mail looks not signed";
-
-    like $attachments[0]->Content, qr/Some content/,
-        "RT's mail includes copy of ticket text";
+for my $type ( keys %mail ) {
+    for my $mail ( map cleanup_headers($_), @{ $mail{$type} } ) {
+        send_email_and_check_transaction( $mail, $type );
+    }
 }
 
-foreach my $mail ( map cleanup_headers($_), @{ $mail{'signed_encrypted'} } ) {
-    my ($status, $id) = RT::Test->send_via_mailgate($mail);
-    is ($status >> 8, 0, "The mail gateway exited normally");
-    ok ($id, "got id of a newly created ticket - $id");
-
-    my $tick = RT::Ticket->new( RT->SystemUser );
-    $tick->Load( $id );
-    ok ($tick->id, "loaded ticket #$id");
-
-    my $txn = $tick->Transactions->First;
-    my ($msg, @attachments) = @{$txn->Attachments->ItemsArrayRef};
-
-    is $msg->GetHeader('X-RT-Privacy'), 'PGP',
-        "RT's outgoing mail has crypto";
-    is $msg->GetHeader('X-RT-Incoming-Encryption'), 'Success',
-        "RT's outgoing mail looks encrypted";
-    like $msg->GetHeader('X-RT-Incoming-Signature'),
-        qr/<rt-recipient\@example.com>/,
-        "RT's outgoing mail looks signed";
-
-    like $attachments[0]->Content, qr/Some content/,
-        "RT's mail includes copy of ticket text";
-}

commit 6aac8b0bf613c44fe75f348f62a93006ef9a890e
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Oct 29 16:57:22 2010 +0800

    tiny clean

diff --git a/t/mail/gnupg-outgoing.t b/t/mail/gnupg-outgoing.t
index ef8a2b1..400bb4a 100644
--- a/t/mail/gnupg-outgoing.t
+++ b/t/mail/gnupg-outgoing.t
@@ -9,8 +9,6 @@ use RT::Test::GnuPG
     'trust-model' => 'always',
   };
 
-use RT::Action::SendEmail;
-
 RT::Test->import_gnupg_key('rt-recipient at example.com');
 RT::Test->import_gnupg_key('rt-test at example.com', 'public');
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list