summaryrefslogtreecommitdiff
path: root/rt/t/web/gnupg-headers.t
diff options
context:
space:
mode:
Diffstat (limited to 'rt/t/web/gnupg-headers.t')
-rw-r--r--rt/t/web/gnupg-headers.t53
1 files changed, 53 insertions, 0 deletions
diff --git a/rt/t/web/gnupg-headers.t b/rt/t/web/gnupg-headers.t
new file mode 100644
index 000000000..88b3ab9c2
--- /dev/null
+++ b/rt/t/web/gnupg-headers.t
@@ -0,0 +1,53 @@
+#!/usr/bin/perl -w
+use strict;
+
+use RT::Test::GnuPG
+ tests => 15,
+ gnupg_options => {
+ passphrase => 'recipient',
+ 'trust-model' => 'always',
+ };
+
+RT::Test->import_gnupg_key( 'recipient@example.com', 'public' );
+RT::Test->import_gnupg_key( 'general@example.com', 'secret' );
+
+ok( my $user = RT::User->new( RT->SystemUser ) );
+ok( $user->Load('root'), "Loaded user 'root'" );
+$user->SetEmailAddress('recipient@example.com');
+
+my $queue = RT::Test->load_or_create_queue(
+ Name => 'General',
+ CorrespondAddress => 'general@example.com',
+);
+ok $queue && $queue->id, 'loaded or created queue';
+my $qid = $queue->id;
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+diag "test with Encrypt and Sign disabled";
+
+$m->goto_create_ticket($queue);
+$m->form_name('TicketCreate');
+$m->field( 'Subject', 'Signing test' );
+$m->field( 'Content', 'Some other content' );
+$m->submit;
+$m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
+$m->follow_link_ok( { text => 'with headers' } );
+$m->content_contains('X-RT-Encrypt: 0');
+$m->content_contains('X-RT-Sign: 0');
+
+diag "test with Encrypt and Sign enabled";
+
+$m->goto_create_ticket($queue);
+$m->form_name('TicketCreate');
+$m->field( 'Subject', 'Signing test' );
+$m->field( 'Content', 'Some other content' );
+$m->tick( 'Encrypt', 1 );
+$m->tick( 'Sign', 1 );
+$m->submit;
+$m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
+$m->follow_link_ok( { text => 'with headers' } );
+$m->content_contains('X-RT-Encrypt: 1');
+$m->content_contains('X-RT-Sign: 1');
+