| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | use strictscip-perl cpan CGI-Application-Plugin-Authentication 0.25 strict/; |
| 4 | use Test::Morescip-perl cpan CGI-Application-Plugin-Authentication 0.25 Test/More/; |
| 5 | |
| 6 | if (!$ENVscip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/`%ENV`.{TEST_SIGNATURE}) { |
| 7 | planscip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/plan(). skip_all => |
| 8 | "Set the environment variable TEST_SIGNATURE to enable this test."; |
| 9 | } |
| 10 | elsif (!eval { requirescip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/require(). Module::Signature; 1 }) { |
| 11 | planscip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/plan(). skip_all => |
| 12 | "Next time around, consider installing Module::Signature, ". |
| 13 | "so you can verify the integrity of this distribution."; |
| 14 | } |
| 15 | elsif ( !-e 'SIGNATURE' ) { |
| 16 | planscip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/plan(). skip_all => "SIGNATURE not found"; |
| 17 | } |
| 18 | elsif ( -s 'SIGNATURE' == 0 ) { |
| 19 | planscip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/plan(). skip_all => "SIGNATURE file empty"; |
| 20 | } |
| 21 | elsif (!eval { requirescip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/require(). Socket; Socket::inet_atonscip-perl cpan CGI-Application-Plugin-Authentication 0.25 Socket/inet_aton().('pgp.mit.edu') }) { |
| 22 | planscip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/plan(). skip_all => "Cannot connect to the keyserver to check module ". |
| 23 | "signature"; |
| 24 | } |
| 25 | else { |
| 26 | planscip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/plan(). tests => 1; |
| 27 | } |
| 28 | |
| 29 | my $ret = Module::Signature::verifyscip-perl cpan CGI-Application-Plugin-Authentication 0.25 Module/Signature/verify().(); |
| 30 | SKIP: { |
| 31 | skipscip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/skip(). "Module::Signature cannot verify", 1 |
| 32 | if $ret eq Module::Signature::CANNOT_VERIFYscip-perl cpan CGI-Application-Plugin-Authentication 0.25 Module/Signature/CANNOT_VERIFY().(); |
| 33 | |
| 34 | cmp_okscip-perl cpan CGI-Application-Plugin-Authentication 0.25 main/cmp_ok(). $ret, '==', Module::Signature::SIGNATURE_OKscip-perl cpan CGI-Application-Plugin-Authentication 0.25 Module/Signature/SIGNATURE_OK().(), "Valid signature"; |
| 35 | } |