~ubuntu-branches/ubuntu/gutsy/libgnupg-interface-perl/gutsy

« back to all changes in this revision

Viewing changes to t/passphrase_handling.t

  • Committer: Bazaar Package Importer
  • Author(s): Peter Palfrader
  • Date: 2002-03-31 20:54:51 UTC
  • Revision ID: james.westby@ubuntu.com-20020331205451-ggm3hbo19ff14h1l
Tags: upstream-0.31
ImportĀ upstreamĀ versionĀ 0.31

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
#
 
3
# $Id: passphrase_handling.t,v 1.6 2001/05/03 06:02:39 ftobin Exp $
 
4
#
 
5
 
 
6
use strict;
 
7
use English;
 
8
use Symbol;
 
9
use IO::File;
 
10
 
 
11
use lib './t';
 
12
use MyTest;
 
13
use MyTestSpecific;
 
14
 
 
15
TEST
 
16
{
 
17
    reset_handles();
 
18
    return $gnupg->test_default_key_passphrase()
 
19
};
 
20
 
 
21
 
 
22
$gnupg->clear_passphrase();
 
23
    
 
24
TEST
 
25
{
 
26
    reset_handles();
 
27
    
 
28
    my $passphrase_handle = gensym;
 
29
    $handles->passphrase( $passphrase_handle );
 
30
    
 
31
    my $pid = $gnupg->sign( handles => $handles );
 
32
    
 
33
    print $passphrase_handle 'test';
 
34
    print $stdin @{ $texts{plain}->data() };
 
35
    
 
36
    close $passphrase_handle;
 
37
    close $stdin;
 
38
    
 
39
    waitpid $pid, 0;
 
40
    return $CHILD_ERROR == 0;
 
41
};
 
42
 
 
43
 
 
44
 
 
45
TEST
 
46
{
 
47
    reset_handles();
 
48
    $handles->clear_stderr();
 
49
    $handles->stderr( '>&STDERR' );
 
50
    
 
51
    my $pass_fn = 'test/passphrase';
 
52
    my $passfile = IO::File->new( $pass_fn )
 
53
      or die "cannot open $pass_fn: $ERRNO";
 
54
    $handles->passphrase( $passfile );
 
55
    $handles->options( 'passphrase' )->{direct} = 1;
 
56
    
 
57
    my $pid = $gnupg->sign( handles => $handles );
 
58
    close $stdin;
 
59
    
 
60
    waitpid $pid, 0;
 
61
    return $CHILD_ERROR == 0;
 
62
};