aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2020-09-28 19:44:49 +0200
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>2020-09-30 20:49:44 +0200
commit9032c2c11b2f14dcdbd253b470abc595a07a6c51 (patch)
tree3592c0b6876ed35569da8367a9531d3cfdadeb83 /test
parente1f5a92df4b612de8eac7ca538ef44f4b1deec5a (diff)
downloadopenssl-9032c2c11b2f14dcdbd253b470abc595a07a6c51.tar.gz
25-test_x509.t: Add test for suitable error report loading unsupported sm2 cert
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13023)
Diffstat (limited to 'test')
-rw-r--r--test/recipes/25-test_x509.t15
1 files changed, 11 insertions, 4 deletions
diff --git a/test/recipes/25-test_x509.t b/test/recipes/25-test_x509.t
index 4b37ee6464..f5b4245960 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 => 14;
+plan tests => 15;
require_ok(srctop_file('test','recipes','tconversion.pl'));
@@ -105,9 +105,10 @@ 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);
+ push(@args, $infile, @opts);
my $tmpfile = 'out.txt';
- my $res = !run(app([@args], stderr => $tmpfile));
+ my $res = grep(/-text/, @opts) ? run(app([@args], stdout => $tmpfile))
+ : !run(app([@args], stderr => $tmpfile));
my $found = 0;
open(my $in, '<', $tmpfile) or die "Could not open file $tmpfile";
while(<$in>) {
@@ -116,7 +117,7 @@ sub test_errors { # actually tests diagnostics of OSSL_STORE
$found = 1 if m/$expected/; # output must include $expected
}
close $in;
- unlink $tmpfile;
+ # $tmpfile is kept to help with investigation in case of failure
return $res && $found;
}
@@ -124,3 +125,9 @@ 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");
+SKIP: {
+ skip "sm2 not disabled", 1 if !disabled("sm2");
+
+ ok(test_errors("unknown group|unsupported algorithm", "sm2.pem", '-text'),
+ "error loading unsupported sm2 cert");
+}