File: list_secret_keys.t

package info (click to toggle)
libgnupg-interface-perl 0.52-10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,296 kB
  • sloc: perl: 3,637; makefile: 10; sh: 1
file content (92 lines) | stat: -rw-r--r-- 2,043 bytes parent folder | download | duplicates (3)
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
88
89
90
91
92
#!/usr/bin/perl -w
#
# $Id: list_secret_keys.t,v 1.7 2001/05/03 06:00:06 ftobin Exp $
#

use strict;
use English qw( -no_match_vars );

use lib './t';
use MyTest;
use MyTestSpecific;

my $outfile;

TEST
{
    reset_handles();

    $ENV{LC_MESSAGES} = 'C';
    my $pid = $gnupg->list_secret_keys( handles => $handles );
    close $stdin;

    $outfile = 'test/secret-keys/1.out';
    my $out = IO::File->new( "> $outfile" )
      or die "cannot open $outfile for writing: $ERRNO";
    my $seckey_file = $gpg_is_modern ? 'pubring.kbx' : 'secring.gpg';
    my $pubring_line = $gnupg->options->homedir() . '/' . $seckey_file . "\n";
    while (<$stdout>) {
      if ($_ eq $pubring_line) {
        $out->print('test/gnupghome/'.$seckey_file."\n");
      } elsif (/^--*$/) {
        $out->print("--------------------------\n");
      } else {
        $out->print( $_ );
      }
    }
    close $stdout;
    $out->close();
    waitpid $pid, 0;

    return $CHILD_ERROR == 0;
};


TEST
{
    my $suffix = '0';
    $suffix = 'modern' if ($gpg_is_modern);
    my @files_to_test = ( 'test/secret-keys/1.'.$suffix.'.test' );

    return file_match( $outfile, @files_to_test );
};


TEST
{
    reset_handles();

    my $pid = $gnupg->list_secret_keys( handles      => $handles,
                                        command_args => '0x93AFC4B1B0288A104996B44253AE596EF950DA9C' );
    close $stdin;

    $outfile = 'test/secret-keys/2.out';
    my $out = IO::File->new( "> $outfile" )
      or die "cannot open $outfile for writing: $ERRNO";
    $out->print( <$stdout> );
    close $stdout;
    $out->close();

    waitpid $pid, 0;

    return $CHILD_ERROR == 0;

};


TEST
{
    reset_handles();

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

    my $pid = $gnupg->list_secret_keys( handles      => $handles,
                                        command_args => '0x93AFC4B1B0288A104996B44253AE596EF950DA9C' );

    waitpid $pid, 0;

    $outfile = $texts{temp}->fn();

    return $CHILD_ERROR == 0;
};