summaryrefslogtreecommitdiff
path: root/t/decrypt.t
diff options
context:
space:
mode:
Diffstat (limited to 't/decrypt.t')
-rw-r--r--t/decrypt.t91
1 files changed, 91 insertions, 0 deletions
diff --git a/t/decrypt.t b/t/decrypt.t
new file mode 100644
index 0000000..5bb35da
--- /dev/null
+++ b/t/decrypt.t
@@ -0,0 +1,91 @@
+#!/usr/bin/perl -w
+#
+# $Id: decrypt.t,v 1.4 2001/05/03 06:00:06 ftobin Exp $
+#
+
+use strict;
+use English qw( -no_match_vars );
+use File::Compare;
+
+use lib './t';
+use MyTest;
+use MyTestSpecific;
+
+my $compare;
+
+TEST
+{
+ reset_handles();
+
+ my $pid = $gnupg->decrypt( handles => $handles );
+
+ print $stdin @{ $texts{encrypted}->data() };
+ close $stdin;
+
+ $compare = compare( $texts{plain}->fn(), $stdout );
+ close $stdout;
+ waitpid $pid, 0;
+
+ return $CHILD_ERROR == 0;;
+};
+
+
+TEST
+{
+ return $compare == 0;
+};
+
+
+TEST
+{
+ reset_handles();
+
+ $handles->stdin( $texts{encrypted}->fh() );
+ $handles->options( 'stdin' )->{direct} = 1;
+
+ $handles->stdout( $texts{temp}->fh() );
+ $handles->options( 'stdout' )->{direct} = 1;
+
+ my $pid = $gnupg->decrypt( handles => $handles );
+
+ waitpid $pid, 0;
+
+ return $CHILD_ERROR == 0;
+};
+
+
+TEST
+{
+ return compare( $texts{plain}->fn(), $texts{temp}->fn() ) == 0;
+};
+
+
+# test without default_passphrase (that is, by using the agent, if ENV flag set)
+TEST
+{
+ return 1 unless ($gnupg->cmp_version($gnupg->version, '2.2') >= 0);
+
+ reset_handles();
+
+ $handles->stdin( $texts{alt_encrypted}->fh() );
+ $handles->options( 'stdin' )->{direct} = 1;
+
+ $handles->stdout( $texts{temp}->fh() );
+ $handles->options( 'stdout' )->{direct} = 1;
+
+ $handles->clear_passphrase();
+ $gnupg->clear_passphrase();
+
+ my $pid = $gnupg->decrypt( handles => $handles );
+
+ waitpid $pid, 0;
+
+ return $CHILD_ERROR == 0;
+};
+
+
+TEST
+{
+ return 1 unless ($gnupg->cmp_version($gnupg->version, '2.2') >= 0);
+ return compare( $texts{alt_plain}->fn(), $texts{temp}->fn() ) == 0;
+};