fix ticketing system error on bootstrap of new install
[freeside.git] / rt / t / web / gnupg-tickyboxes.t
1 use strict;
2 use warnings;
3
4 use RT::Test::GnuPG tests => 22, gnupg_options => { passphrase => 'rt-test' };
5
6 use RT::Action::SendEmail;
7
8 RT::Test->import_gnupg_key('rt-recipient@example.com');
9 RT::Test->import_gnupg_key('rt-test@example.com', 'public');
10
11 my $queue = RT::Test->load_or_create_queue(
12     Name              => 'Regression',
13     CorrespondAddress => 'rt-recipient@example.com',
14     CommentAddress    => 'rt-recipient@example.com',
15 );
16 ok $queue && $queue->id, 'loaded or created queue';
17
18 my ($baseurl, $m) = RT::Test->started_ok;
19 ok $m->login, 'logged in';
20
21 my @variants = (
22     {},
23     { Sign => 1 },
24     { Encrypt => 1 },
25     { Sign => 1, Encrypt => 1 },
26 );
27
28 # collect emails
29 my %mail = (
30     plain            => [],
31     signed           => [],
32     encrypted        => [],
33     signed_encrypted => [],
34 );
35
36 diag "check in read-only mode that queue's props influence create/update ticket pages";
37 {
38     foreach my $variant ( @variants ) {
39         set_queue_crypt_options( $queue =>  %$variant );
40         $m->goto_create_ticket( $queue );
41         $m->form_name('TicketCreate');
42         if ( $variant->{'Encrypt'} ) {
43             ok $m->value('Encrypt', 2), "encrypt tick box is checked";
44         } else {
45             ok !$m->value('Encrypt', 2), "encrypt tick box is unchecked";
46         }
47         if ( $variant->{'Sign'} ) {
48             ok $m->value('Sign', 2), "sign tick box is checked";
49         } else {
50             ok !$m->value('Sign', 2), "sign tick box is unchecked";
51         }
52     }
53
54     # to avoid encryption/signing during create
55     set_queue_crypt_options($queue);
56
57     my $ticket = RT::Ticket->new( RT->SystemUser );
58     my ($id) = $ticket->Create(
59         Subject   => 'test',
60         Queue     => $queue->id,
61         Requestor => 'rt-test@example.com',
62     );
63     ok $id, 'ticket created';
64
65     foreach my $variant ( @variants ) {
66         set_queue_crypt_options( $queue => %$variant );
67         $m->get( $m->rt_base_url . "/Ticket/Update.html?Action=Respond&id=$id" );
68         $m->form_name('TicketUpdate');
69         if ( $variant->{'Encrypt'} ) {
70             ok $m->value('Encrypt', 2), "encrypt tick box is checked";
71         } else {
72             ok !$m->value('Encrypt', 2), "encrypt tick box is unchecked";
73         }
74         if ( $variant->{'Sign'} ) {
75             ok $m->value('Sign', 2), "sign tick box is checked";
76         } else {
77             ok !$m->value('Sign', 2), "sign tick box is unchecked";
78         }
79     }
80 }
81
82
83