Subject: | proper roundtrip test for t/roundtrip.t |
Hi,
while working on other issues in Mail::GnuPG 0.10, I noticed that
t/roundtrip.t is currently incomplete. The comments inside indicate a
problem with initializing the trust database in the test gpg keyring.
One fix for this is to import the test key with '--trusted-key'.
I'm attaching a patch that makes the tests more complete. Hope this is
helpful to you.
Thanks for your work on Mail::GnuPG,
--
Niko Tyni
ntyni@debian.org
Subject: | mail-gnupg-test.patch |
diff --git a/t/round-trip.t b/t/round-trip.t
index 821a4aa..f27fc25 100644
--- a/t/round-trip.t
+++ b/t/round-trip.t
@@ -17,12 +17,12 @@ unless ( 0 == system("gpg --version 2>&1 >/dev/null") ) {
my $tmpdir = tempdir( "mgtXXXXX", CLEANUP => 1);
-unless ( 0 == system("gpg --homedir $tmpdir --import t/test-key.pgp 2>&1 >/dev/null")) {
+unless ( 0 == system("gpg --homedir $tmpdir --trusted-key 0x49539D60EFEA4EAD --import t/test-key.pgp 2>&1 >/dev/null")) {
plan skip_all => "unable to import testing keys";
goto end;
}
-plan tests => 13;
+plan tests => 20;
my $mg = new Mail::GnuPG( key => '49539D60EFEA4EAD',
@@ -36,7 +36,6 @@ my $me = MIME::Entity->build(From => 'me@myhost.com',
To => 'you@yourhost.com',
Subject => "Hello, nurse!",
Data => ["Line 1","Line 2"]);
-
# Test MIME Signing Round Trip
$copy = $me->dup;
@@ -67,30 +66,18 @@ is( 0, $mg->is_encrypted($copy) );
}
# Test MIME Encryption Round Trip
-# hmm.. the encryption functions don't seem to be working right.
-# something about ...
-# gpg: 9FE08E94: There is no indication that this key really belongs to the owner
-# gpg: [stdin]: encryption failed: unusable public key
-
-
-# $copy = $me->dup;
-
-# is( 0, $mg->ascii_encrypt( $copy, $KEY ));
-# warn @{$mg->{last_message}},"\n";
-# warn @{$mg->{plaintext}},"\n";
-# warn "hihi\n";
-# exit;
-# is( 0, $mg->is_signed($copy) );
-# is( 1, $mg->is_encrypted($copy) );
-
-# my ($verify,$key,$who) = $mg->decrypt($copy);
+$copy = $me->dup;
-# is( 0, $verify );
-# is( undef, $key );
-# is( undef, $who );
+is( 0, $mg->ascii_encrypt( $copy, $KEY ));
+is( 0, $mg->is_signed($copy) );
+is( 1, $mg->is_encrypted($copy) );
-# is_deeply($mg->{decrypted},$me);
+($verify,$key,$who) = $mg->decrypt($copy);
+is( 0, $verify );
+is( undef, $key );
+is( undef, $who );
+is_deeply($mg->{decrypted}->body,$me->body);
end: