summaryrefslogtreecommitdiff
path: root/t/00_signature.t
blob: fc07ec7801a6cf427fb00ac6ea225ec99c87daa4 (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
#!perl

## Test that our PGP signature file is valid

use 5.006;
use strict;
use warnings;
use Test::More;

my $sigfile = 'check_postgres.pl.asc';

if (!$ENV{RELEASE_TESTING}) {
    plan (skip_all =>  'Test skipped unless environment variable RELEASE_TESTING is set');
}

plan tests => 2;

SKIP: {
    if ( !-e $sigfile ) {
        fail (qq{File '$sigfile' file was not found});
    }
    elsif ( ! -s $sigfile) {
        fail (qq{File '$sigfile' was empty});
    }
    else {
        my $result = system "gpg --no-options --no-auto-check-trustdb --no-tty --logger-fd 1 --quiet --verify $sigfile >/dev/null";
        if (0 == $result) {
            pass (qq{Valid signature file '$sigfile'});
        }
        else {
            fail (qq{Invalid signature file '$sigfile'});
        }
    }
}

SKIP: {
    if (!eval { require Module::Signature; 1 }) {
        skip ('Must have Module::Signature to test SIGNATURE file', 1);
    }
    elsif ( !-e 'SIGNATURE' ) {
        fail ('SIGNATURE file was not found');
    }
    elsif ( ! -s 'SIGNATURE') {
        fail ('SIGNATURE file was empty');
    }
    else {
        my $ret = Module::Signature::verify();
        if ($ret eq Module::Signature::SIGNATURE_OK()) {
            pass ('Valid SIGNATURE file');
        }
        else {
            fail ('Invalid SIGNATURE file');
        }
    }
}