]> iEval git - app-edwardng.git/blame_incremental - t/App-EdwardNG.t
Set Content-Type and Content-Transfer-Encoding
[app-edwardng.git] / t / App-EdwardNG.t
... / ...
CommitLineData
1#!/usr/bin/perl -w
2use strict;
3use warnings;
4
5use constant KEYID => '34B22806';
6use constant EMAIL => 'EdwardNG (Key for testing EdwardNG) <edwardng@ieval.ro>';
7
8use File::Copy qw/cp/;
9use File::Temp qw/tempdir/;
10use Test::More tests => 20;
11BEGIN { use_ok('App::EdwardNG', qw/import_pubkeys process_message/) };
12
13umask 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;
16cp "t/keydir/$_", $ENV{EDWARDNG_KEYDIR} for qw/pubring.gpg secring.gpg/;
17
18my $contains_pubkey = App::EdwardNG::mp->parse_open('t/data/contains-pubkey');
19my @keys = import_pubkeys ($contains_pubkey, App::EdwardNG::mg);
20is $keys[0], 'DE12658069C2F09BF996CC855AAF79E969137654', 'import_pubkeys';
21
22my ($tmpl, %params);
23
24sub process {
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}"
28}
29
30process 'mime-signed', 'sign';
31is $params{keyid}, KEYID, 'mime-signed keyid';
32is $params{email}, EMAIL, 'mime-signed email';
33
34process 'mime-encrypted', 'encrypt';
35like $params{plaintext}, qr/MIME encrypted/, 'mime-signed plaintext';
36
37process 'mime-signed-encrypted', 'signencrypt';
38is $params{keyid}, KEYID, 'mime-signed-encrypted keyid';
39is $params{email}, EMAIL, 'mime-signed-encrypted email';
40like $params{plaintext}, qr/MIME signed & encrypted/, 'mime-signed-encrypted plaintext';
41
42process 'inline-signed', 'sign';
43is $params{keyid}, KEYID, 'inline-signed keyid';
44is $params{email}, EMAIL, 'inline-signed email';
45
46process 'inline-encrypted', 'encrypt';
47like $params{plaintext}, qr/Inline encrypted/, 'inline-signed plaintext';
48
49process 'inline-signed-encrypted', 'signencrypt';
50is $params{keyid}, KEYID, 'inline-signed-encrypted keyid';
51is $params{email}, EMAIL, 'inline-signed-encrypted email';
52like $params{plaintext}, qr/Inline signed & encrypted/, 'inline-signed-encrypted plaintext';
This page took 0.022857 seconds and 5 git commands to generate.