]>
iEval git - app-edwardng.git/blob - t/App-EdwardNG.t
5 use constant KEYID
=> '34B22806';
6 use constant EMAIL
=> 'EdwardNG (Key for testing EdwardNG) <edwardng@ieval.ro>';
9 use File
::Temp qw
/tempdir/;
10 use Test
::More tests
=> 20;
11 BEGIN { use_ok
('App::EdwardNG', qw
/import_pubkeys process_message/) };
13 umask 0077; # GPG doesn't like group-/world-readable homedirs
14 $ENV{EDWARDNG_DEBUG
} = $ENV{TEST_VERBOSE
};
15 $ENV{EDWARDNG_KEYDIR
} = tempdir
'App-EdwardNG-test.XXXX', TMPDIR
=> 1, CLEANUP
=> 1;
16 cp
"t/keydir/$_", $ENV{EDWARDNG_KEYDIR
} for qw
/pubring.gpg secring.gpg/;
18 my $contains_pubkey = App
::EdwardNG
::mp
->parse_open('t/data/contains-pubkey');
19 my @keys = import_pubkeys
($contains_pubkey, App
::EdwardNG
::mg
);
20 is
$keys[0], 'DE12658069C2F09BF996CC855AAF79E969137654', 'import_pubkeys';
25 my ($name, $expected) = @_;
26 ($tmpl, %params) = process_message
("t/data/$name");
27 is
$tmpl, $expected, "Result for $name is $expected" or diag
"GnuPG said: $params{message}"
30 process
'mime-signed', 'sign';
31 is
$params{keyid
}, KEYID
, 'mime-signed keyid';
32 is
$params{email
}, EMAIL
, 'mime-signed email';
34 process
'mime-encrypted', 'encrypt';
35 like
$params{plaintext
}, qr/MIME encrypted/, 'mime-signed plaintext';
37 process
'mime-signed-encrypted', 'signencrypt';
38 is
$params{keyid
}, KEYID
, 'mime-signed-encrypted keyid';
39 is
$params{email
}, EMAIL
, 'mime-signed-encrypted email';
40 like
$params{plaintext
}, qr/MIME signed & encrypted/, 'mime-signed-encrypted plaintext';
42 process
'inline-signed', 'sign';
43 is
$params{keyid
}, KEYID
, 'inline-signed keyid';
44 is
$params{email
}, EMAIL
, 'inline-signed email';
46 process
'inline-encrypted', 'encrypt';
47 like
$params{plaintext
}, qr/Inline encrypted/, 'inline-signed plaintext';
49 process
'inline-signed-encrypted', 'signencrypt';
50 is
$params{keyid
}, KEYID
, 'inline-signed-encrypted keyid';
51 is
$params{email
}, EMAIL
, 'inline-signed-encrypted email';
52 like
$params{plaintext
}, qr/Inline signed & encrypted/, 'inline-signed-encrypted plaintext';
This page took 0.057401 seconds and 5 git commands to generate.