[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-629-g63a371a

Jesse Vincent jesse at bestpractical.com
Mon Aug 30 15:06:06 EDT 2010


The branch, 3.9-trunk has been updated
       via  63a371a74db5d123a36a8a742d306c814031c3aa (commit)
      from  47cc699ac5693df05a5c03ebb2dbab3ada4d4948 (commit)

Summary of changes:
 t/{web => mail}/gnupg-outgoing.t |   48 +-----------
 t/web/gnupg-tickyboxes.t         |  156 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 157 insertions(+), 47 deletions(-)
 rename t/{web => mail}/gnupg-outgoing.t (85%)
 create mode 100644 t/web/gnupg-tickyboxes.t

- Log -----------------------------------------------------------------
commit 63a371a74db5d123a36a8a742d306c814031c3aa
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Mon Aug 30 15:08:27 2010 -0400

    split apart t/web/gnupg-outgoing to actually separate two very different flows

diff --git a/t/web/gnupg-outgoing.t b/t/mail/gnupg-outgoing.t
similarity index 85%
rename from t/web/gnupg-outgoing.t
rename to t/mail/gnupg-outgoing.t
index 9eb56f4..728eda7 100644
--- a/t/web/gnupg-outgoing.t
+++ b/t/mail/gnupg-outgoing.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 456;
+use RT::Test tests => 430;
 
 plan skip_all => 'GnuPG required.'
     unless eval 'use GnuPG::Interface; 1';
@@ -63,52 +63,6 @@ my %mail = (
     signed_encrypted => [],
 );
 
-diag "check in read-only mode that queue's props influence create/update ticket pages";
-{
-    foreach my $variant ( @variants ) {
-        set_queue_crypt_options( %$variant );
-        $m->goto_create_ticket( $queue );
-        $m->form_name('TicketCreate');
-        if ( $variant->{'Encrypt'} ) {
-            ok $m->value('Encrypt', 2), "encrypt tick box is checked";
-        } else {
-            ok !$m->value('Encrypt', 2), "encrypt tick box is unchecked";
-        }
-        if ( $variant->{'Sign'} ) {
-            ok $m->value('Sign', 2), "sign tick box is checked";
-        } else {
-            ok !$m->value('Sign', 2), "sign tick box is unchecked";
-        }
-    }
-
-    # to avoid encryption/signing during create
-    set_queue_crypt_options();
-
-    my $ticket = RT::Ticket->new( $RT::SystemUser );
-    my ($id) = $ticket->Create(
-        Subject   => 'test',
-        Queue     => $queue->id,
-        Requestor => 'rt-test at example.com',
-    );
-    ok $id, 'ticket created';
-
-    foreach my $variant ( @variants ) {
-        set_queue_crypt_options( %$variant );
-        $m->get( $m->rt_base_url . "/Ticket/Update.html?Action=Respond&id=$id" );
-        $m->form_number(3);
-        if ( $variant->{'Encrypt'} ) {
-            ok $m->value('Encrypt', 2), "encrypt tick box is checked";
-        } else {
-            ok !$m->value('Encrypt', 2), "encrypt tick box is unchecked";
-        }
-        if ( $variant->{'Sign'} ) {
-            ok $m->value('Sign', 2), "sign tick box is checked";
-        } else {
-            ok !$m->value('Sign', 2), "sign tick box is unchecked";
-        }
-    }
-}
-
 # create a ticket for each combination
 foreach my $queue_set ( @variants ) {
     set_queue_crypt_options( %$queue_set );
diff --git a/t/web/gnupg-tickyboxes.t b/t/web/gnupg-tickyboxes.t
new file mode 100644
index 0000000..c5c14aa
--- /dev/null
+++ b/t/web/gnupg-tickyboxes.t
@@ -0,0 +1,156 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+use RT::Test tests => 30;
+
+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 RT::Action::SendEmail;
+use File::Temp qw(tempdir);
+
+RT::Test->set_mail_catcher;
+
+use_ok('RT::Crypt::GnuPG');
+
+RT->Config->Set( GnuPG =>
+    Enable => 1,
+    OutgoingMessagesFormat => 'RFC',
+);
+
+RT->Config->Set( GnuPGOptions =>
+    homedir => scalar tempdir( CLEANUP => 1 ),
+    passphrase => 'rt-test',
+    'no-permission-warning' => undef,
+    'trust-model' => 'always',
+);
+RT->Config->Set( 'MailPlugins' => 'Auth::MailFrom', 'Auth::GnuPG' );
+
+RT::Test->import_gnupg_key('rt-recipient at example.com');
+RT::Test->import_gnupg_key('rt-test at example.com', 'public');
+
+my $queue = RT::Test->load_or_create_queue(
+    Name              => 'Regression',
+    CorrespondAddress => 'rt-recipient at example.com',
+    CommentAddress    => 'rt-recipient at example.com',
+);
+ok $queue && $queue->id, 'loaded or created queue';
+
+RT::Test->set_rights(
+    Principal => 'Everyone',
+    Right => ['CreateTicket', 'ShowTicket', 'SeeQueue', 'ReplyToTicket', 'ModifyTicket'],
+);
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+my @variants = (
+    {},
+    { Sign => 1 },
+    { Encrypt => 1 },
+    { Sign => 1, Encrypt => 1 },
+);
+
+# collect emails
+my %mail = (
+    plain            => [],
+    signed           => [],
+    encrypted        => [],
+    signed_encrypted => [],
+);
+
+diag "check in read-only mode that queue's props influence create/update ticket pages";
+{
+    foreach my $variant ( @variants ) {
+        set_queue_crypt_options( %$variant );
+        $m->goto_create_ticket( $queue );
+        $m->form_name('TicketCreate');
+        if ( $variant->{'Encrypt'} ) {
+            ok $m->value('Encrypt', 2), "encrypt tick box is checked";
+        } else {
+            ok !$m->value('Encrypt', 2), "encrypt tick box is unchecked";
+        }
+        if ( $variant->{'Sign'} ) {
+            ok $m->value('Sign', 2), "sign tick box is checked";
+        } else {
+            ok !$m->value('Sign', 2), "sign tick box is unchecked";
+        }
+    }
+
+    # to avoid encryption/signing during create
+    set_queue_crypt_options();
+
+    my $ticket = RT::Ticket->new( $RT::SystemUser );
+    my ($id) = $ticket->Create(
+        Subject   => 'test',
+        Queue     => $queue->id,
+        Requestor => 'rt-test at example.com',
+    );
+    ok $id, 'ticket created';
+
+    foreach my $variant ( @variants ) {
+        set_queue_crypt_options( %$variant );
+        $m->get( $m->rt_base_url . "/Ticket/Update.html?Action=Respond&id=$id" );
+        $m->form_number(3);
+        if ( $variant->{'Encrypt'} ) {
+            ok $m->value('Encrypt', 2), "encrypt tick box is checked";
+        } else {
+            ok !$m->value('Encrypt', 2), "encrypt tick box is unchecked";
+        }
+        if ( $variant->{'Sign'} ) {
+            ok $m->value('Sign', 2), "sign tick box is checked";
+        } else {
+            ok !$m->value('Sign', 2), "sign tick box is unchecked";
+        }
+    }
+}
+
+
+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";
+
+    unlike($m->content, qr/unable to sign outgoing email messages/);
+
+    $m->get_ok('/'); # ensure that the mail has been processed
+
+    my @mail = RT::Test->fetch_caught_mails;
+    check_text_emails( \%args, @mail );
+}
+
+sub set_queue_crypt_options {
+    my %args = @_;
+    $m->get_ok("/Admin/Queues/Modify.html?id=". $queue->id);
+    $m->form_with_fields('Sign', 'Encrypt');
+    foreach my $opt ('Sign', 'Encrypt') {
+        if ( $args{$opt} ) {
+            $m->tick($opt => 1);
+        } else {
+            $m->untick($opt => 1);
+        }
+    }
+    $m->submit;
+}
+

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


More information about the Rt-commit mailing list