fix ticketing system error on bootstrap of new install
[freeside.git] / rt / t / web / admin_user.t
1
2 use strict;
3 use warnings;
4
5 use RT::Test::GnuPG
6   tests         => undef,
7   gnupg_options => {
8     passphrase    => 'recipient',
9     'trust-model' => 'always',
10   };
11
12 RT::Test->import_gnupg_key( 'rt-test@example.com', 'secret' );
13
14 ok( my $user = RT::User->new( RT->SystemUser ) );
15 ok( $user->Load('root'), "loaded user 'root'" );
16 $user->SetEmailAddress('rt-test@example.com');
17
18 my ( $url, $m ) = RT::Test->started_ok;
19 ok( $m->login(), 'logged in' );
20
21 my $root = RT::User->new( $RT::SystemUser );
22 $root->Load('root');
23 ok( $root->id, 'loaded root' );
24
25
26 diag "test the history page" if $ENV{TEST_VERBOSE};
27 $m->get_ok( $url . '/Admin/Users/History.html?id=' . $root->id );
28 $m->content_contains('User created', 'has User created entry');
29
30 diag "test keys page" if $ENV{TEST_VERBOSE};
31 $m->follow_link_ok( { text => 'Private keys' } );
32 $m->content_contains('Public key(s) for rt-test@example.com');
33 $m->content_contains('The key is ultimately trusted');
34 $m->content_contains('F0CB3B482CFA485680A4A0BDD328035D84881F1B');
35 $m->content_contains('Tue Aug 07 2007');
36 $m->content_contains('never');
37
38 $m->content_contains('GnuPG private key');
39
40 my $form = $m->form_with_fields('PrivateKey');
41 is( $form->find_input('PrivateKey')->value,
42     '__empty_value__', 'default no private key' );
43 $m->submit_form_ok(
44     {
45         fields => { PrivateKey => 'D328035D84881F1B' },
46         button => 'Update',
47     },
48     'submit PrivateKey form'
49 );
50
51 $m->content_contains('Set private key');
52 $form = $m->form_with_fields('PrivateKey');
53 is( $form->find_input('PrivateKey')->value,
54     'D328035D84881F1B', 'set private key' );
55 $m->submit_form_ok(
56     {
57         fields => { PrivateKey => '__empty_value__' },
58         button => 'Update',
59     },
60     'submit PrivateKey form'
61 );
62
63 $m->content_contains('Unset private key');
64 is( $form->find_input('PrivateKey')->value,
65     '__empty_value__', 'unset private key' );
66 $form = $m->form_with_fields('PrivateKey');
67 $m->submit_form_ok(
68     {
69         fields => { PrivateKey => 'C798591AA831DBFB' },
70         button => 'Update',
71     },
72     'submit PrivateKey form'
73 );
74 is( $form->find_input('PrivateKey')->value,
75     'C798591AA831DBFB', 'set private key' );
76
77 # TODO more /Admin/Users tests
78
79 undef $m;
80 done_testing;