summaryrefslogtreecommitdiff
path: root/rt/t/web/gnupg-headers.t
blob: 03e60901ea4b99b1f45819951a4784ba7d37cd93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use strict;
use warnings;

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');