summaryrefslogtreecommitdiff
path: root/t/decrypt.t
blob: ee41448b0fd67cd3504aa89bdb2b071fb272fa02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/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)
TEST
{
    reset_handles();

    $handles->stdin( $texts{alt_encrypted}->fh() );
    $handles->options( 'stdin' )->{direct} = 1;

    $handles->stdout( $texts{temp}->fh() );
    $handles->options( 'stdout' )->{direct} = 1;

    $gnupg->clear_passphrase();

    my $pid = $gnupg->decrypt( handles => $handles );

    waitpid $pid, 0;

    return $CHILD_ERROR == 0;
};


TEST
{
    return compare( $texts{alt_plain}->fn(), $texts{temp}->fn() ) == 0;
};