[Rt-commit] rt branch, admin_ui, updated. ff1115c0594ec9ba37e8a031309a29d593fceee8

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Jan 19 22:48:29 EST 2010


The branch, admin_ui has been updated
       via  ff1115c0594ec9ba37e8a031309a29d593fceee8 (commit)
      from  6441b1e3ce289e13830fdb2faf9fbaa799bda0ba (commit)

Summary of changes:
 t/web/admin_gnupg.t |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)
 create mode 100644 t/web/admin_gnupg.t

- Log -----------------------------------------------------------------
commit ff1115c0594ec9ba37e8a031309a29d593fceee8
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jan 20 11:48:23 2010 +0800

    add admin_gnupg.t

diff --git a/t/web/admin_gnupg.t b/t/web/admin_gnupg.t
new file mode 100644
index 0000000..c88bc7f
--- /dev/null
+++ b/t/web/admin_gnupg.t
@@ -0,0 +1,65 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+use Test::More;
+use RT::Test strict => 1;
+
+plan skip_all => 'GnuPG required.'
+    unless eval 'use GnuPG::Interface; 1';
+plan skip_all => 'gpg executable is required.'
+    unless RT::Test->find_executable('gpg');
+
+plan tests => 14;
+
+use File::Temp qw(tempdir);
+use_ok('RT::Crypt::GnuPG');
+RT->config->set(
+    gnupg => {
+        enable                   => 1,
+        outgoing_messages_format => 'RFC',
+    }
+);
+
+RT->config->set(
+    gnupg_options => {
+        homedir                 => scalar tempdir( CLEANUP => 0 ),
+        passphrase              => 'rt-test',
+        'no-permission-warning' => undef,
+    }
+);
+
+diag "GnuPG --homedir ". RT->config->get('gnupg_options')->{'homedir'} if $ENV{TEST_VERBOSE};
+
+my $queue = RT::Model::Queue->new( current_user => RT->system_user );
+ok($queue->load('General'), 'load General queue');
+$queue->set_correspond_address( 'general at example.com' );
+RT::Test->import_gnupg_key('general at example.com');
+RT::Test->import_gnupg_key('general at example.com','secret');
+my ($baseurl, $agent) = RT::Test->started_ok;
+ok $agent->login, 'logged in';
+$agent->get_ok('/admin/queues/?id=' . $queue->id);
+$agent->follow_link_ok( { text => 'GnuPG' }, 'follow GnuPG link');
+$agent->content_contains('GnuPG private key', 'has private key section' );
+$agent->content_contains('general at example.com', 'email is right' );
+
+
+RT::Test->import_gnupg_key('general at example.com.2');
+RT::Test->import_gnupg_key('general at example.com.2','secret');
+my $user_general = RT::Test->load_or_create_user(
+    name     => 'user_general',
+    password => 'password',
+    email => 'general at example.com',
+);
+
+$agent->get_ok('/admin/users/?id=' . $user_general->id);
+$agent->follow_link_ok( { text => 'GnuPG' }, 'follow GnuPG link');
+$agent->content_contains('GnuPG public key', 'has public key section' );
+my %keys_meta = RT::Crypt::GnuPG::get_keys_for_signing( 'general at example.com', 'force' );
+my @keys = map $_->{'key'}, @{ $keys_meta{'info'} };
+my $moniker = 'user_select_private_key';
+$agent->fill_in_action_ok( $moniker, private_key => $keys[0] );
+$agent->submit;
+$agent->content_contains(('Updated private key selection')x2);
+is( $user_general->private_key, $keys[0], 'private key is indeed selected' );
+

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


More information about the Rt-commit mailing list