summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2017-02-20 02:49:13 +0100
committerRichard Levitte <levitte@openssl.org>2018-02-23 07:40:42 +0100
commita75831f9cc608e4f4502f86f6ab35ef742762e85 (patch)
tree3189505464e8fcd336ed4c45b2c12c8cc6cfbd55 /test
parent6ab6deccd95c97a6235f345b371664afb65f77c7 (diff)
Test the storeutl searching options
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2688)
Diffstat (limited to 'test')
-rw-r--r--test/recipes/90-test_store.t54
1 files changed, 49 insertions, 5 deletions
diff --git a/test/recipes/90-test_store.t b/test/recipes/90-test_store.t
index 94f2c1aca6..2a6414bd88 100644
--- a/test/recipes/90-test_store.t
+++ b/test/recipes/90-test_store.t
@@ -6,7 +6,7 @@
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
-use File::Spec;
+use File::Spec::Functions;
use File::Copy;
use MIME::Base64;
use OpenSSL::Test qw(:DEFAULT srctop_file srctop_dir bldtop_file data_file);
@@ -75,7 +75,7 @@ my $n = (3 * scalar @noexist_files)
+ (scalar keys %generated_file_files)
+ (scalar @noexist_file_files)
+ 3
- + 4;
+ + 11;
plan tests => $n;
@@ -84,9 +84,7 @@ indir "store_$$" => sub {
{
skip "failed initialisation", $n unless init();
- # test PEM_read_bio_PrivateKey
- ok(run(app(["openssl", "rsa", "-in", "rsa-key-pkcs8-pbes2-sha256.pem",
- "-passin", "pass:password"])));
+ my $rehash = init_rehash();
foreach (@noexist_files) {
my $file = srctop_file($_);
@@ -153,6 +151,11 @@ indir "store_$$" => sub {
}
}
+ ok(!run(app(['openssl', 'storeutl',
+ '-subject', '/C=AU/ST=QLD/CN=SSLeay\/rsa test cert',
+ srctop_file('test', 'testx509.pem')])),
+ "Checking that -subject can't be used with a single file");
+
ok(run(app(['openssl', 'storeutl', '-certs',
srctop_file('test', 'testx509.pem')])),
"Checking that -certs returns 1 object on a certificate file");
@@ -166,6 +169,36 @@ indir "store_$$" => sub {
ok(run(app(['openssl', 'storeutl', '-crls',
srctop_file('test', 'testcrl.pem')])),
"Checking that -crls returns 1 object on a CRL file");
+
+ SKIP: {
+ skip "failed rehash initialisation", 6 unless $rehash;
+
+ # subject from testx509.pem:
+ # '/C=AU/ST=QLD/CN=SSLeay\/rsa test cert'
+ # issuer from testcrl.pem:
+ # '/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority'
+ ok(run(app(['openssl', 'storeutl',
+ '-subject', '/C=AU/ST=QLD/CN=SSLeay\/rsa test cert',
+ catdir(curdir(), 'rehash')])));
+ ok(run(app(['openssl', 'storeutl',
+ '-subject',
+ '/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority',
+ catdir(curdir(), 'rehash')])));
+ ok(run(app(['openssl', 'storeutl', '-certs',
+ '-subject', '/C=AU/ST=QLD/CN=SSLeay\/rsa test cert',
+ catdir(curdir(), 'rehash')])));
+ ok(run(app(['openssl', 'storeutl', '-crls',
+ '-subject', '/C=AU/ST=QLD/CN=SSLeay\/rsa test cert',
+ catdir(curdir(), 'rehash')])));
+ ok(run(app(['openssl', 'storeutl', '-certs',
+ '-subject',
+ '/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority',
+ catdir(curdir(), 'rehash')])));
+ ok(run(app(['openssl', 'storeutl', '-crls',
+ '-subject',
+ '/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority',
+ catdir(curdir(), 'rehash')])));
+ }
}
}, create => 1, cleanup => 1;
@@ -364,6 +397,17 @@ sub init {
);
}
+sub init_rehash {
+ return (
+ mkdir(catdir(curdir(), 'rehash'))
+ && copy(srctop_file('test', 'testx509.pem'),
+ catdir(curdir(), 'rehash'))
+ && copy(srctop_file('test', 'testcrl.pem'),
+ catdir(curdir(), 'rehash'))
+ && run(app(['openssl', 'rehash', catdir(curdir(), 'rehash')]))
+ );
+}
+
sub runall {
my ($function, @items) = @_;