]>
Commit | Line | Data |
---|---|---|
2f9e679a MG |
1 | #!/usr/bin/perl -w |
2 | use strict; | |
3 | use warnings; | |
4 | ||
5 | use constant KEYID => '34B22806'; | |
6 | use constant EMAIL => 'EdwardNG (Key for testing EdwardNG) <edwardng@ieval.ro>'; | |
7 | ||
2f363992 MG |
8 | use Test::More tests => 20; |
9 | BEGIN { use_ok('App::EdwardNG', qw/import_pubkeys process_message/) }; | |
2f9e679a MG |
10 | $ENV{EDWARDNG_DEBUG} = $ENV{TEST_VERBOSE}; |
11 | $ENV{EDWARDNG_KEYDIR} = 't/keydir'; | |
12 | ||
2f363992 MG |
13 | my $contains_pubkey = App::EdwardNG::mp->parse_open('t/data/contains-pubkey'); |
14 | my @keys = import_pubkeys ($contains_pubkey, App::EdwardNG::mg); | |
15 | is $keys[0], 'DE12658069C2F09BF996CC855AAF79E969137654', 'import_pubkeys'; | |
16 | ||
2f9e679a MG |
17 | my ($tmpl, %params); |
18 | ||
19 | sub process { | |
20 | my ($name, $expected) = @_; | |
2f363992 | 21 | ($tmpl, %params) = process_message("t/data/$name"); |
2f9e679a MG |
22 | is $tmpl, $expected, "Result for $name is $expected" or diag "GnuPG said: $params{message}" |
23 | } | |
24 | ||
25 | process 'mime-signed', 'sign'; | |
26 | is $params{keyid}, KEYID, 'mime-signed keyid'; | |
27 | is $params{email}, EMAIL, 'mime-signed email'; | |
28 | ||
29 | process 'mime-encrypted', 'encrypt'; | |
30 | like $params{plaintext}, qr/MIME encrypted/, 'mime-signed plaintext'; | |
31 | ||
32 | process 'mime-signed-encrypted', 'signencrypt'; | |
33 | is $params{keyid}, KEYID, 'mime-signed-encrypted keyid'; | |
34 | is $params{email}, EMAIL, 'mime-signed-encrypted email'; | |
35 | like $params{plaintext}, qr/MIME signed & encrypted/, 'mime-signed-encrypted plaintext'; | |
36 | ||
37 | process 'inline-signed', 'sign'; | |
38 | is $params{keyid}, KEYID, 'inline-signed keyid'; | |
39 | is $params{email}, EMAIL, 'inline-signed email'; | |
40 | ||
41 | process 'inline-encrypted', 'encrypt'; | |
42 | like $params{plaintext}, qr/Inline encrypted/, 'inline-signed plaintext'; | |
43 | ||
44 | process 'inline-signed-encrypted', 'signencrypt'; | |
45 | is $params{keyid}, KEYID, 'inline-signed-encrypted keyid'; | |
46 | is $params{email}, EMAIL, 'inline-signed-encrypted email'; | |
47 | like $params{plaintext}, qr/Inline signed & encrypted/, 'inline-signed-encrypted plaintext'; |