diff options
Diffstat (limited to 'test/recipes/25-test_x509.t')
-rw-r--r-- | test/recipes/25-test_x509.t | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/test/recipes/25-test_x509.t b/test/recipes/25-test_x509.t index 3cfcb2290c..4b37ee6464 100644 --- a/test/recipes/25-test_x509.t +++ b/test/recipes/25-test_x509.t @@ -16,7 +16,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/; setup("test_x509"); -plan tests => 12; +plan tests => 14; require_ok(srctop_file('test','recipes','tconversion.pl')); @@ -100,3 +100,27 @@ sub has_doctor_id { close(DATA); return m/2.16.528.1.1003.1.3.5.5.2-1-0000006666-Z-12345678-01.015-12345678/; } + +sub test_errors { # actually tests diagnostics of OSSL_STORE + my ($expected, $cert, @opts) = @_; + my $infile = srctop_file('test', 'certs', $cert); + my @args = qw(openssl x509 -in); + push(@args, "$infile", @opts); + my $tmpfile = 'out.txt'; + my $res = !run(app([@args], stderr => $tmpfile)); + my $found = 0; + open(my $in, '<', $tmpfile) or die "Could not open file $tmpfile"; + while(<$in>) { + print; # this may help debugging + $res &&= !m/asn1 encoding/; # output must not include ASN.1 parse errors + $found = 1 if m/$expected/; # output must include $expected + } + close $in; + unlink $tmpfile; + return $res && $found; +} + +ok(test_errors("Can't open any-dir/", "root-cert.pem", '-out', 'any-dir/'), + "load root-cert errors"); +ok(test_errors("RC2-40-CBC", "v3-certs-RC2.p12", '-passin', 'pass:v3-certs'), + "load v3-certs-RC2 no asn1 errors"); |