Add tests for the exit status of pgpverify in various situations.
This commit is contained in:
parent
5612d3c454
commit
4fa1f2973c
4 changed files with 140 additions and 0 deletions
23
tests/messages/bad-corrupt
Normal file
23
tests/messages/bad-corrupt
Normal file
|
@ -0,0 +1,23 @@
|
|||
Path: bounce-back
|
||||
From: group-admin@isc.org (David C Lawrence)
|
||||
Newsgroups: news.announce.newusers
|
||||
Subject: cmsg newgroup news.announce.newusers moderated
|
||||
Control: newgroup news.announce.newusers moderated
|
||||
Approved: newgroups-request@isc.org
|
||||
Message-ID: <868485430.2655@isc.org>
|
||||
Date: Wed, 09 Jul 1997 21:57:10 GMT
|
||||
Lines: 8
|
||||
X-Info: ftp://ftp.isc.org/pub/pgpcontrol/README.html
|
||||
ftp://ftp.isc.org/pub/pgpcontrol/README
|
||||
X-PGP-Sig: 2.6.2 Subject,Control,Message-ID,Date,From,Sender
|
||||
iQCVAwUBM8QJNsJdOtO4janBAQGkUAP6AlzO065jDQFrG20/b3/SaOm4WGQBly5D
|
||||
pXlVJdYBqPAG3HvxVqAdKM7y6ixM7Mml4OdfK0JeVCH03nqeGuBc51sTDIZ6kyAx
|
||||
+YHlNSnp/JJnpDuJCfXZjwNl4kWImucGgwI5BxrQco8re949Cg5m5TFXiwYMiR/+
|
||||
AjKZCTtmV1Y=
|
||||
=uSbd
|
||||
|
||||
news.announce.newusers is a moderated newsgroup which has existed
|
||||
since the mid-1980s.
|
||||
|
||||
For your newsgroups file:
|
||||
news.announce.newusers Explanatory postings for new users. (Moderated)
|
25
tests/messages/bad-syntax
Normal file
25
tests/messages/bad-syntax
Normal file
|
@ -0,0 +1,25 @@
|
|||
Path: bounce-back
|
||||
From: group-admin@isc.org (David C Lawrence)
|
||||
Newsgroups: news.announce.newusers
|
||||
Subject: cmsg newgroup news.announce.newusers moderated
|
||||
Control: newgroup news.announce.newusers moderated
|
||||
Approved: newgroups-request@isc.org
|
||||
Message-ID: <868485430.2655@isc.org>
|
||||
Date: Wed, 09 Jul 1997 21:57:10 GMT
|
||||
Lines: 8
|
||||
X-Info: ftp://ftp.isc.org/pub/pgpcontrol/README.html
|
||||
ftp://ftp.isc.org/pub/pgpcontrol/README
|
||||
X-PGP-Sig: 2.6.2 Subject,Control,Message-ID,Date,From,Sender
|
||||
iQCVAwUBM8QJNsJdOtO4janBAQGkUAP6AlzO065jDQFrG20/b3/SaOm4WGQBly5D
|
||||
pXlVJdYBqPAG3HvxVqAdKM7y6ixM7Mml4OdfK0JeVCH03nqeGuBc51sTDIZ6kyAx
|
||||
+YHlNSnp/JJnpDuJCfXZjwNl4kWImucGgwI5BxrQco8re949Cg5m5TFXiwYMiR/+
|
||||
=uSbd
|
||||
|
||||
news.announce.newusers is a moderated newsgroup which has existed
|
||||
since the mid-1980s.
|
||||
|
||||
Group submission address: netannounce@deshaw.com
|
||||
Moderator contact address: netannounce@deshaw.com (Mark Moraes)
|
||||
|
||||
For your newsgroups file:
|
||||
news.announce.newusers Explanatory postings for new users. (Moderated)
|
30
tests/messages/gnu
Normal file
30
tests/messages/gnu
Normal file
|
@ -0,0 +1,30 @@
|
|||
Path: usenet.gnu.org!not-for-mail
|
||||
From: usenet@gnu.org
|
||||
Newsgroups: gnu.cvs.bug
|
||||
Subject: cmsg newgroup gnu.cvs.bug
|
||||
Control: newgroup gnu.cvs.bug
|
||||
Date: Mon, 17 Jan 2005 17:17:07 -0800
|
||||
Message-ID: <cmsg-20050118011707$140f@usenet.gnu.org>
|
||||
X-PGP-Sig: GnuPG_v1.2.4_(GNU/Linux) Subject,Control,Message-ID,Date,From,Sender
|
||||
iQCVAwUBQexjk/IyWVItWelFAQEV+AP/TQa8myc0/OS+SVlRD10JK5tEF8+uYBC+
|
||||
Y7PKfFaWEC2srD4jutLFEPSdqEWCEvydh4odirmI3gkJECNL8HZ1qn/ov7daXS51
|
||||
yyg5H0/OidwRswNILSRw7QNd9tKoMX2b5D+B9E4Lem//a09c1z5dSmruo/S7jIFC
|
||||
01x8svEwA1M=
|
||||
=XpKe
|
||||
|
||||
gnu.cvs.bug is a unmoderated newsgroup in the gnu.* hierarchy. Please
|
||||
create it at all sites carrying gnu.* newsgroups.
|
||||
|
||||
Please send any queries about this action to usenet@gnu.org.
|
||||
|
||||
For your newsgroups file:
|
||||
gnu.cvs.bug Concurrent Versions System (CVS) bug reports and fixes.
|
||||
|
||||
|
||||
This newsgroup was initially created on 1999-02-25. The corresponding
|
||||
mailing list is bug-cvs@gnu.org.
|
||||
|
||||
Charter:
|
||||
|
||||
This list distributes bug reports, fixes, and suggestions for improvements
|
||||
to the maintainers of CVS.
|
|
@ -89,6 +89,22 @@ sub pgpverify {
|
|||
}
|
||||
}
|
||||
|
||||
# Run pgpverify on a given file, expecting failure with the provided status
|
||||
# code. Warn if we succeed and return true on success of the test and false
|
||||
# on failure.
|
||||
sub pgpverify_fail {
|
||||
my ($file, $status) = @_;
|
||||
my $signer = `./pgpverify < $file 2> /dev/null`;
|
||||
chomp $signer;
|
||||
if (($? >> 8) == $status && !$signer) {
|
||||
return 1;
|
||||
} else {
|
||||
print "pgpverify exited with status ", ($? >> 8), "\n";
|
||||
print "pgpverify said the signer was $signer\n" if $signer;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
# Test suite
|
||||
##############################################################################
|
||||
|
@ -245,6 +261,52 @@ if (pgpverify ('./signed.pgp', 'testing')) {
|
|||
}
|
||||
$tests++;
|
||||
|
||||
# Check the return status for a truncated signature.
|
||||
if (pgpverify_fail ('./messages/bad-syntax', 255)) {
|
||||
print "PASS: pgpverify-pgp-syntax\n";
|
||||
} else {
|
||||
print "FAIL: pgpverify-pgp-syntax\n";
|
||||
$failed++;
|
||||
}
|
||||
$tests++;
|
||||
|
||||
# Check the return status for a bad signature.
|
||||
if (pgpverify_fail ('./messages/bad-corrupt', 3)) {
|
||||
print "PASS: pgpverify-pgp-bad\n";
|
||||
} else {
|
||||
print "FAIL: pgpverify-pgp-bad\n";
|
||||
$failed++;
|
||||
}
|
||||
$tests++;
|
||||
|
||||
# Switch to GnuPG and check the return status for a truncated signature.
|
||||
fix_pgpverify ($gpgv);
|
||||
if (pgpverify_fail ('./messages/bad-syntax', 255)) {
|
||||
print "PASS: pgpverify-gpg-syntax\n";
|
||||
} else {
|
||||
print "FAIL: pgpverify-gpg-syntax\n";
|
||||
$failed++;
|
||||
}
|
||||
$tests++;
|
||||
|
||||
# Check the return status for a bad signature.
|
||||
if (pgpverify_fail ('./messages/bad-corrupt', 3)) {
|
||||
print "PASS: pgpverify-gpg-bad\n";
|
||||
} else {
|
||||
print "FAIL: pgpverify-gpg-bad\n";
|
||||
$failed++;
|
||||
}
|
||||
$tests++;
|
||||
|
||||
# Check the return status for an unknown signer.
|
||||
if (pgpverify_fail ('./messages/gnu', 2)) {
|
||||
print "PASS: pgpverify-gpg-unknown\n";
|
||||
} else {
|
||||
print "FAIL: pgpverify-gpg-unknown\n";
|
||||
$failed++;
|
||||
}
|
||||
$tests++;
|
||||
|
||||
# Print out a summary of the tests.
|
||||
unlink ('pgpverify', 'signcontrol', 'signed', 'signed.pgp', 'signed.gpg')
|
||||
unless $failed > 0;
|
||||
|
|
Loading…
Reference in a new issue