From 4c0669dc6f5863b4d79c45abe37f566ffc61af01 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 12 Jul 2017 12:42:16 +0200 Subject: [PATCH] test/recipes/90-test_store.t: Add a few cases with files starting with 'file:' These cases are performed on Linux only. They check that files with names starting with 'file:' can be processed as well. Reviewed-by: Andy Polyakov (Merged from https://github.com/openssl/openssl/pull/3907) --- test/recipes/90-test_store.t | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/recipes/90-test_store.t b/test/recipes/90-test_store.t index aae46963c0..699a67ee81 100644 --- a/test/recipes/90-test_store.t +++ b/test/recipes/90-test_store.t @@ -7,6 +7,7 @@ # https://www.openssl.org/source/license.html use File::Spec; +use File::Copy; use MIME::Base64; use OpenSSL::Test qw(:DEFAULT srctop_file srctop_dir bldtop_file data_file); @@ -55,10 +56,24 @@ my @generated_files = "ec-key-pkcs8-pbes2-sha1.pem", "ec-key-pkcs8-pbes2-sha1.der", "ec-key-aes256-cbc-sha256.p12", ); +my %generated_file_files = + $^O eq 'linux' + ? ( "test/testx509.pem" => "file:testx509.pem", + "test/testrsa.pem" => "file:testrsa.pem", + "test/testrsapub.pem" => "file:testrsapub.pem", + "test/testcrl.pem" => "file:testcrl.pem", + "apps/server.pem" => "file:server.pem" ) + : (); +my @noexist_file_files = + ( "file:blahdiblah.pem", + "file:test/blahdibleh.der" ); + my $n = (3 * scalar @noexist_files) + (6 * scalar @src_files) + (4 * scalar @generated_files) + + (scalar keys %generated_file_files) + + (scalar @noexist_file_files) + 3; plan tests => $n; @@ -96,6 +111,12 @@ indir "store_$$" => sub { ok(!run(app(["openssl", "storeutl", "-passin", "pass:password", to_file_uri($_)]))); } + foreach (values %generated_file_files) { + ok(run(app(["openssl", "storeutl", $_]))); + } + foreach (@noexist_file_files) { + ok(!run(app(["openssl", "storeutl", $_]))); + } { my $dir = srctop_dir("test", "certs"); ok(run(app(["openssl", "storeutl", $dir]))); @@ -287,6 +308,16 @@ sub init { close $outfh; return 1; }, grep(/\.der$/, @generated_files)) + && runall(sub { + my $srcfile = shift; + my $dstfile = $generated_file_files{$srcfile}; + + unless (copy srctop_file($srcfile), $dstfile) { + warn "$!\n"; + return 0; + } + return 1; + }, keys %generated_file_files) ); } -- 2.25.1