[Rt-commit] r9371 - rtir/branches/2.3-EXPERIMENTAL/t

ruz at bestpractical.com ruz at bestpractical.com
Fri Oct 19 18:22:36 EDT 2007


Author: ruz
Date: Fri Oct 19 18:22:36 2007
New Revision: 9371

Added:
   rtir/branches/2.3-EXPERIMENTAL/t/023-gnupg-on-incident.t

Log:
* add tests for interaction with gnupg on updates of Incidents:
  'Reply To Reporters', 'Reply to All' and 'Abandon'.

Added: rtir/branches/2.3-EXPERIMENTAL/t/023-gnupg-on-incident.t
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-EXPERIMENTAL/t/023-gnupg-on-incident.t	Fri Oct 19 18:22:36 2007
@@ -0,0 +1,127 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 36;
+use File::Temp qw(tempdir);
+
+use lib qw(/opt/rt3/local/lib /opt/rt3/lib);
+require RT::Test; import RT::Test;
+require "t/rtir-test.pl";
+
+{
+    $RT::Handle->InsertSchema(undef, '/opt/rt3/local/etc/FM');
+    $RT::Handle->InsertACL(undef, '/opt/rt3/local/etc/FM');
+
+    $RT::Handle = new RT::Handle;
+    $RT::Handle->dbh( undef );
+    RT->ConnectToDatabase;
+
+    local @INC = ('/opt/rt3/local/etc', '/opt/rt3/etc', @INC);
+    RT->Config->LoadConfig(File => "IR/RTIR_Config.pm");
+    $RT::Handle->InsertData('IR/initialdata');
+
+    $RT::Handle = new RT::Handle;
+    $RT::Handle->dbh( undef );
+    RT->ConnectToDatabase;
+}
+
+RT::Test->set_mail_catcher;
+
+RT->Config->Set( 'GnuPG',
+                 Enable => 1,
+                 OutgoingMessagesFormat => 'RFC' );
+
+RT->Config->Set( GnuPGOptions =>
+    homedir => scalar tempdir( CLEANUP => 0 ),
+    passphrase => 'rt-test',
+    'no-permission-warning' => undef,
+);
+diag "GnuPG --homedir ". RT->Config->Get('GnuPGOptions')->{'homedir'};
+
+RT->Config->Set( 'MailPlugins' => 'Auth::MailFrom', 'Auth::GnuPG' );
+
+my $queue = RT::Test->load_or_create_queue(
+    Name              => 'Incident Reports',
+    CorrespondAddress => 'rt-recipient at example.com',
+    CommentAddress    => 'rt-recipient at example.com',
+);
+ok $queue && $queue->id, 'loaded or created queue';
+
+my ($baseurl, $agent) = RT::Test->started_ok;
+rtir_user();
+$agent->login( rtir_test_user => 'rtir_test_pass' );
+
+RT::Test->set_rights(
+    Principal => 'Everyone',
+    Right => ['CreateTicket', 'ShowTicket', 'SeeQueue', 'OwnTicket', 'ReplyToTicket', 'ModifyTicket'],
+);
+
+diag "check that things don't work if there is no key";
+{
+
+    my $ir_id = create_ir( $agent, { Subject => 'test', Requestors => 'rt-test at example.com' } );
+    ok $ir_id, 'created an IR';
+    
+    my $inc_id = create_incident_for_ir( $agent, $ir_id, { Subject => 'test' } );
+    ok $inc_id, 'created an Inc';
+
+    unlink "t/mailbox";
+
+    ok $agent->goto_ticket( $inc_id ), "UI -> ticket #$inc_id";
+    $agent->follow_link_ok( { text => 'Reply to Reporters' }, 'inc -> Reply to Reporters' );
+    $agent->form_number(3);
+    $agent->tick( SelectedReports => $ir_id );
+    $agent->tick( Sign => 1 );
+    $agent->click('SubmitTicket');
+    $agent->content_like(
+        qr/unable to sign outgoing email messages/i,
+        'problems with passphrase'
+    );
+    $agent->content_like(qr/rt-recipient\@example\.com/) or diag $agent->content;
+
+    my @mail = RT::Test->fetch_caught_mails;
+    ok !@mail, 'there are no outgoing emails';
+}
+
+diag 'import rt-recipient at example.com key and sign it';
+{
+    RT::Test->import_gnupg_key('rt-recipient at example.com');
+    RT::Test->trust_gnupg_key('rt-recipient at example.com');
+    my %res = RT::Crypt::GnuPG::GetKeysInfo('rt-recipient at example.com');
+    is $res{'info'}[0]{'TrustTerse'}, 'ultimate', 'ultimately trusted key';
+}
+
+diag "check that things don't work if there is no key";
+{
+    my $ir_id = create_ir( $agent, { Subject => 'test', Requestors => 'rt-test at example.com' } );
+    ok $ir_id, 'created an IR';
+    
+    my $inc_id = create_incident_for_ir( $agent, $ir_id, { Subject => 'test' } );
+    ok $inc_id, 'created an Inc';
+
+    unlink "t/mailbox";
+
+    ok $agent->goto_ticket( $inc_id ), "UI -> ticket #$inc_id";
+    $agent->follow_link_ok( { text => 'Reply to Reporters' }, 'inc -> Reply to Reporters' );
+    $agent->form_number(3);
+    $agent->tick( SelectedReports => $ir_id );
+    $agent->tick( Encrypt => 1 );
+    $agent->click('SubmitTicket');
+    $agent->content_like(
+        qr/You are going to encrypt outgoing email messages/i,
+        'problems with keys'
+    );
+    $agent->content_like(
+        qr/There is no key suitable for encryption/i,
+        'problems with keys'
+    );
+
+    my $form = $agent->form_number(3);
+    ok !$form->find_input( 'UseKey-rt-test at example.com' ), 'no key selector';
+
+    my @mail = RT::Test->fetch_caught_mails;
+    ok !@mail, 'there are no outgoing emails';
+}
+


More information about the Rt-commit mailing list