[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.4-184-g943466c

Chia-liang Kao clkao at bestpractical.com
Wed Oct 20 04:54:30 EDT 2010


The branch, 3.9-trunk has been updated
       via  943466c58b16e86bae1651da483840c76096a826 (commit)
       via  af0040031255c7d23354bac1fb4fa35e73deb04d (commit)
       via  7e91702e9e5ed748b9a4d16552ea78cd60488f3e (commit)
      from  6160683c58469be4f59f97e0b65645b49e396e17 (commit)

Summary of changes:
 lib/RT/Test.pm                      |    2 +-
 lib/RT/Test/GnuPG.pm                |  131 +++++++++++++++++++++++++++++++++++
 t/mail/crypt-gnupg.t                |    8 +--
 t/mail/gnupg-bad.t                  |    8 +--
 t/mail/gnupg-incoming.t             |    7 +--
 t/mail/gnupg-outgoing.t             |  120 ++------------------------------
 t/mail/gnupg-realmail.t             |    7 +--
 t/mail/gnupg-reverification.t       |    7 +--
 t/mail/gnupg-special.t              |    7 +--
 t/web/crypt-gnupg.t                 |    7 +--
 t/web/gnupg-select-keys-on-create.t |    7 +--
 t/web/gnupg-select-keys-on-update.t |    7 +--
 t/web/gnupg-tickyboxes.t            |    7 +--
 13 files changed, 147 insertions(+), 178 deletions(-)
 create mode 100644 lib/RT/Test/GnuPG.pm

- Log -----------------------------------------------------------------
commit 7e91702e9e5ed748b9a4d16552ea78cd60488f3e
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Wed Oct 20 17:21:52 2010 +0900

    move gnupg test helpers to RT::Test::GnuPG

diff --git a/lib/RT/Test/GnuPG.pm b/lib/RT/Test/GnuPG.pm
new file mode 100644
index 0000000..d399c32
--- /dev/null
+++ b/lib/RT/Test/GnuPG.pm
@@ -0,0 +1,117 @@
+package RT::Test::GnuPG;
+use strict;
+use Test::More;
+use base qw(Exporter);
+
+our @EXPORT = qw(create_a_ticket update_ticket check_text_emails cleanup_headers set_queue_crypt_options);
+
+sub create_a_ticket {
+    my $queue = shift;
+    my $mail = shift;
+    my $m = shift;
+    my %args = (@_);
+
+    RT::Test->clean_caught_mails;
+
+    $m->goto_create_ticket( $queue );
+    $m->form_name('TicketCreate');
+    $m->field( Subject    => 'test' );
+    $m->field( Requestors => 'rt-test at example.com' );
+    $m->field( Content    => 'Some content' );
+
+    foreach ( qw(Sign Encrypt) ) {
+        if ( $args{ $_ } ) {
+            $m->tick( $_ => 1 );
+        } else {
+            $m->untick( $_ => 1 );
+        }
+    }
+
+    $m->submit;
+    is $m->status, 200, "request successful";
+
+    $m->content_lacks("unable to sign outgoing email messages");
+
+
+    my @mail = RT::Test->fetch_caught_mails;
+    check_text_emails($mail, \%args, @mail );
+}
+
+sub update_ticket {
+    my $tid = shift;
+    my $mail = shift;
+    my $m = shift;
+    my %args = (@_);
+
+    RT::Test->clean_caught_mails;
+
+    $m->get( $m->rt_base_url . "/Ticket/Update.html?Action=Respond&id=$tid" );
+    $m->form_number(3);
+    $m->field( UpdateContent => 'Some content' );
+
+    foreach ( qw(Sign Encrypt) ) {
+        if ( $args{ $_ } ) {
+            $m->tick( $_ => 1 );
+        } else {
+            $m->untick( $_ => 1 );
+        }
+    }
+
+    $m->click('SubmitTicket');
+    is $m->status, 200, "request successful";
+    $m->content_contains("Message recorded", 'Message recorded') or diag $m->content;
+
+
+    my @mail = RT::Test->fetch_caught_mails;
+    check_text_emails($mail, \%args, @mail );
+}
+
+sub check_text_emails {
+    my %mail = %{ shift @_ };
+    my %args = %{ shift @_ };
+    my @mail = @_;
+
+    ok scalar @mail, "got some mail";
+    for my $mail (@mail) {
+        if ( $args{'Encrypt'} ) {
+            unlike $mail, qr/Some content/, "outgoing email was encrypted";
+        } else {
+            like $mail, qr/Some content/, "outgoing email was not encrypted";
+        } 
+        if ( $args{'Sign'} && $args{'Encrypt'} ) {
+            like $mail, qr/BEGIN PGP MESSAGE/, 'outgoing email was signed';
+        } elsif ( $args{'Sign'} ) {
+            like $mail, qr/SIGNATURE/, 'outgoing email was signed';
+        } else {
+            unlike $mail, qr/SIGNATURE/, 'outgoing email was not signed';
+        }
+    }
+    if ( $args{'Sign'} && $args{'Encrypt'} ) {
+        push @{ $mail{'signed_encrypted'} }, @mail;
+    } elsif ( $args{'Sign'} ) {
+        push @{ $mail{'signed'} }, @mail;
+    } elsif ( $args{'Encrypt'} ) {
+        push @{ $mail{'encrypted'} }, @mail;
+    } else {
+        push @{ $mail{'plain'} }, @mail;
+    }
+}
+
+sub cleanup_headers {
+    my $mail = shift;
+    # strip id from subject to create new ticket
+    $mail =~ s/^(Subject:)\s*\[.*?\s+#\d+\]\s*/$1 /m;
+    # strip several headers
+    foreach my $field ( qw(Message-ID X-RT-Original-Encoding RT-Originator RT-Ticket X-RT-Loop-Prevention) ) {
+        $mail =~ s/^$field:.*?\n(?! |\t)//gmsi;
+    }
+    return $mail;
+}
+
+sub set_queue_crypt_options {
+    my $queue = shift;
+    my %args = @_;
+    $queue->SetEncrypt($args{'Encrypt'});
+    $queue->SetSign($args{'Sign'});
+}
+
diff --git a/t/mail/gnupg-outgoing.t b/t/mail/gnupg-outgoing.t
index 325612c..87832b1 100644
--- a/t/mail/gnupg-outgoing.t
+++ b/t/mail/gnupg-outgoing.t
@@ -9,6 +9,7 @@ plan skip_all => 'gpg executable is required.'
     unless RT::Test->find_executable('gpg');
 plan tests => 390;
 
+use RT::Test::GnuPG;
 use RT::Action::SendEmail;
 use File::Temp qw(tempdir);
 
@@ -64,9 +65,9 @@ my %mail = (
 
 # create a ticket for each combination
 foreach my $queue_set ( @variants ) {
-    set_queue_crypt_options( %$queue_set );
+    set_queue_crypt_options( $queue, %$queue_set );
     foreach my $ticket_set ( @variants ) {
-        create_a_ticket( %$ticket_set );
+        create_a_ticket( $queue, \%mail, $m, %$ticket_set );
     }
 }
 
@@ -83,9 +84,9 @@ my $tid;
 
 # again for each combination add a reply message
 foreach my $queue_set ( @variants ) {
-    set_queue_crypt_options( %$queue_set );
+    set_queue_crypt_options( $queue, %$queue_set );
     foreach my $ticket_set ( @variants ) {
-        update_ticket( $tid, %$ticket_set );
+        update_ticket( $tid, \%mail, $m, %$ticket_set );
     }
 }
 
@@ -198,107 +199,3 @@ foreach my $mail ( map cleanup_headers($_), @{ $mail{'signed_encrypted'} } ) {
     like $attachments[0]->Content, qr/Some content/,
         "RT's mail includes copy of ticket text";
 }
-
-sub create_a_ticket {
-    my %args = (@_);
-
-    RT::Test->clean_caught_mails;
-
-    $m->goto_create_ticket( $queue );
-    $m->form_name('TicketCreate');
-    $m->field( Subject    => 'test' );
-    $m->field( Requestors => 'rt-test at example.com' );
-    $m->field( Content    => 'Some content' );
-
-    foreach ( qw(Sign Encrypt) ) {
-        if ( $args{ $_ } ) {
-            $m->tick( $_ => 1 );
-        } else {
-            $m->untick( $_ => 1 );
-        }
-    }
-
-    $m->submit;
-    is $m->status, 200, "request successful";
-
-    $m->content_lacks("unable to sign outgoing email messages");
-
-
-    my @mail = RT::Test->fetch_caught_mails;
-    check_text_emails( \%args, @mail );
-}
-
-sub update_ticket {
-    my $tid = shift;
-    my %args = (@_);
-
-    RT::Test->clean_caught_mails;
-
-    $m->get( $m->rt_base_url . "/Ticket/Update.html?Action=Respond&id=$tid" );
-    $m->form_number(3);
-    $m->field( UpdateContent => 'Some content' );
-
-    foreach ( qw(Sign Encrypt) ) {
-        if ( $args{ $_ } ) {
-            $m->tick( $_ => 1 );
-        } else {
-            $m->untick( $_ => 1 );
-        }
-    }
-
-    $m->click('SubmitTicket');
-    is $m->status, 200, "request successful";
-    $m->content_contains("Message recorded", 'Message recorded') or diag $m->content;
-
-
-    my @mail = RT::Test->fetch_caught_mails;
-    check_text_emails( \%args, @mail );
-}
-
-sub check_text_emails {
-    my %args = %{ shift @_ };
-    my @mail = @_;
-
-    ok scalar @mail, "got some mail";
-    for my $mail (@mail) {
-        if ( $args{'Encrypt'} ) {
-            unlike $mail, qr/Some content/, "outgoing email was encrypted";
-        } else {
-            like $mail, qr/Some content/, "outgoing email was not encrypted";
-        } 
-        if ( $args{'Sign'} && $args{'Encrypt'} ) {
-            like $mail, qr/BEGIN PGP MESSAGE/, 'outgoing email was signed';
-        } elsif ( $args{'Sign'} ) {
-            like $mail, qr/SIGNATURE/, 'outgoing email was signed';
-        } else {
-            unlike $mail, qr/SIGNATURE/, 'outgoing email was not signed';
-        }
-    }
-    if ( $args{'Sign'} && $args{'Encrypt'} ) {
-        push @{ $mail{'signed_encrypted'} }, @mail;
-    } elsif ( $args{'Sign'} ) {
-        push @{ $mail{'signed'} }, @mail;
-    } elsif ( $args{'Encrypt'} ) {
-        push @{ $mail{'encrypted'} }, @mail;
-    } else {
-        push @{ $mail{'plain'} }, @mail;
-    }
-}
-
-sub cleanup_headers {
-    my $mail = shift;
-    # strip id from subject to create new ticket
-    $mail =~ s/^(Subject:)\s*\[.*?\s+#\d+\]\s*/$1 /m;
-    # strip several headers
-    foreach my $field ( qw(Message-ID X-RT-Original-Encoding RT-Originator RT-Ticket X-RT-Loop-Prevention) ) {
-        $mail =~ s/^$field:.*?\n(?! |\t)//gmsi;
-    }
-    return $mail;
-}
-
-sub set_queue_crypt_options {
-    my %args = @_;
-            $queue->SetEncrypt($args{'Encrypt'});
-            $queue->SetSign($args{'Sign'});
-}
-

commit af0040031255c7d23354bac1fb4fa35e73deb04d
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Wed Oct 20 17:34:18 2010 +0900

    check test builder is_passing rather than summary.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index b71e782..a098dfb 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1381,7 +1381,7 @@ END {
     RT::Test->stop_server;
 
     # not success
-    if ( !$Test->summary || grep !$_, $Test->summary ) {
+    if ( !$Test->is_passing ) {
         $tmp{'directory'}->unlink_on_destroy(0);
 
         Test::More::diag(

commit 943466c58b16e86bae1651da483840c76096a826
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Wed Oct 20 17:38:12 2010 +0900

    cleanup gnupg test prereq checks

diff --git a/lib/RT/Test/GnuPG.pm b/lib/RT/Test/GnuPG.pm
index d399c32..878aaa3 100644
--- a/lib/RT/Test/GnuPG.pm
+++ b/lib/RT/Test/GnuPG.pm
@@ -1,10 +1,24 @@
 package RT::Test::GnuPG;
 use strict;
 use Test::More;
-use base qw(Exporter);
+use base qw(RT::Test);
 
 our @EXPORT = qw(create_a_ticket update_ticket check_text_emails cleanup_headers set_queue_crypt_options);
 
+sub import {
+    my $class = shift;
+    my %args  = @_;
+    my $t = $class->builder;
+
+    $t->plan( skip_all => 'GnuPG required.' )
+        unless eval { require GnuPG::Interface; 1 };
+    $t->plan( skip_all => 'gpg executable is required.' )
+        unless RT::Test->find_executable('gpg');
+
+    $class->SUPER::import( %args );
+    $class->export_to_level(1);
+}
+
 sub create_a_ticket {
     my $queue = shift;
     my $mail = shift;
diff --git a/t/mail/crypt-gnupg.t b/t/mail/crypt-gnupg.t
index 237a43b..2c297ba 100644
--- a/t/mail/crypt-gnupg.t
+++ b/t/mail/crypt-gnupg.t
@@ -3,13 +3,7 @@
 use strict;
 use warnings;
 
-use RT::Test nodata => 1, tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 97;
-
+use RT::Test::GnuPG tests => 97;
 
 use File::Spec ();
 use Cwd;
diff --git a/t/mail/gnupg-bad.t b/t/mail/gnupg-bad.t
index 82cadcd..f9e4248 100644
--- a/t/mail/gnupg-bad.t
+++ b/t/mail/gnupg-bad.t
@@ -2,13 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 5;
-
+use RT::Test::GnuPG tests => 5;
 
 use Cwd 'getcwd';
 
diff --git a/t/mail/gnupg-incoming.t b/t/mail/gnupg-incoming.t
index 3230dce..a1d401a 100644
--- a/t/mail/gnupg-incoming.t
+++ b/t/mail/gnupg-incoming.t
@@ -2,12 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 39;
+use RT::Test::GnuPG tests => 39;
 
 use File::Temp;
 use Cwd 'getcwd';
diff --git a/t/mail/gnupg-outgoing.t b/t/mail/gnupg-outgoing.t
index 87832b1..e64e9a7 100644
--- a/t/mail/gnupg-outgoing.t
+++ b/t/mail/gnupg-outgoing.t
@@ -2,14 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 390;
-
-use RT::Test::GnuPG;
+use RT::Test::GnuPG tests => 390;
 use RT::Action::SendEmail;
 use File::Temp qw(tempdir);
 
diff --git a/t/mail/gnupg-realmail.t b/t/mail/gnupg-realmail.t
index 9ca4716..8ad2869 100644
--- a/t/mail/gnupg-realmail.t
+++ b/t/mail/gnupg-realmail.t
@@ -2,12 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 196;
+use RT::Test::GnuPG tests => 196;
 
 use Digest::MD5 qw(md5_hex);
 
diff --git a/t/mail/gnupg-reverification.t b/t/mail/gnupg-reverification.t
index 0767f87..97218a7 100644
--- a/t/mail/gnupg-reverification.t
+++ b/t/mail/gnupg-reverification.t
@@ -2,12 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 214;
+use RT::Test::GnuPG tests => 214;
 
 use File::Temp qw(tempdir);
 my $homedir = tempdir( CLEANUP => 1 );
diff --git a/t/mail/gnupg-special.t b/t/mail/gnupg-special.t
index 19e8660..07ed288 100644
--- a/t/mail/gnupg-special.t
+++ b/t/mail/gnupg-special.t
@@ -2,12 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 11;
+use RT::Test::GnuPG tests => 11;
 
 use File::Temp qw(tempdir);
 my $homedir = tempdir( CLEANUP => 1 );
diff --git a/t/web/crypt-gnupg.t b/t/web/crypt-gnupg.t
index a9065e5..985a2f5 100644
--- a/t/web/crypt-gnupg.t
+++ b/t/web/crypt-gnupg.t
@@ -1,12 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 
-use RT::Test tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 101;
+use RT::Test::GnuPG tests => 101;
 
 use RT::Action::SendEmail;
 
diff --git a/t/web/gnupg-select-keys-on-create.t b/t/web/gnupg-select-keys-on-create.t
index 28bc6ce..f3e1dd5 100644
--- a/t/web/gnupg-select-keys-on-create.t
+++ b/t/web/gnupg-select-keys-on-create.t
@@ -2,12 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 78;
+use RT::Test::GnuPG tests => 78;
 
 use RT::Action::SendEmail;
 use File::Temp qw(tempdir);
diff --git a/t/web/gnupg-select-keys-on-update.t b/t/web/gnupg-select-keys-on-update.t
index 6bb6f44..62a6002 100644
--- a/t/web/gnupg-select-keys-on-update.t
+++ b/t/web/gnupg-select-keys-on-update.t
@@ -2,12 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 85;
+use RT::Test::GnuPG tests => 85;
 
 use RT::Action::SendEmail;
 use File::Temp qw(tempdir);
diff --git a/t/web/gnupg-tickyboxes.t b/t/web/gnupg-tickyboxes.t
index c478abd..4786bb2 100644
--- a/t/web/gnupg-tickyboxes.t
+++ b/t/web/gnupg-tickyboxes.t
@@ -2,12 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => undef;
-plan skip_all => 'GnuPG required.'
-    unless eval { require GnuPG::Interface; 1 };
-plan skip_all => 'gpg executable is required.'
-    unless RT::Test->find_executable('gpg');
-plan tests => 30;
+use RT::Test::GnuPG tests => 30;
 
 use RT::Action::SendEmail;
 use File::Temp qw(tempdir);

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


More information about the Rt-commit mailing list