summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2015-09-09 17:36:21 +0200
committerRichard Levitte <levitte@openssl.org>2015-09-09 19:12:09 +0200
commit84d90cf335209e6c1dcb5124d2ddf14ea617212f (patch)
tree3def10a957a34f6c623edb2420132683fd3243cc /test
parentceffb33db28d067fde07531c3fd36a0ed4b95ded (diff)
Add a simple test for the new rehash command
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'test')
-rw-r--r--test/recipes/40-test_rehash.t56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/recipes/40-test_rehash.t b/test/recipes/40-test_rehash.t
new file mode 100644
index 0000000000..514d0d3df3
--- /dev/null
+++ b/test/recipes/40-test_rehash.t
@@ -0,0 +1,56 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+use File::Spec::Functions;
+use File::Copy;
+use File::Basename;
+use OpenSSL::Test qw/:DEFAULT top_file/;
+
+setup("test_rehash");
+
+plan tests => 4;
+
+indir "rehash.$$" => sub {
+ prepare();
+ ok(run(app(["openssl", "rehash", curdir()])),
+ 'Testing normal rehash operations');
+}, create => 1, cleanup => 1;
+
+indir "rehash.$$" => sub {
+ prepare(sub { chmod 400, $_ foreach (@_); });
+ ok(run(app(["openssl", "rehash", curdir()])),
+ 'Testing rehash operations on readonly files');
+}, create => 1, cleanup => 1;
+
+indir "rehash.$$" => sub {
+ ok(run(app(["openssl", "rehash", curdir()])),
+ 'Testing rehash operations on empty directory');
+}, create => 1, cleanup => 1;
+
+indir "rehash.$$" => sub {
+ prepare();
+ chmod 0500, curdir();
+ isnt(run(app(["openssl", "rehash", curdir()])), 1,
+ 'Testing rehash operations on readonly directory');
+ chmod 0700, curdir(); # make it writable again, so cleanup works
+}, create => 1, cleanup => 1;
+
+sub prepare {
+ my @sourcefiles =
+ sort map { glob(top_file('certs', 'demo', "*.$_")) } ('pem',
+ 'crt',
+ 'cer',
+ 'crl');
+ my @destfiles = ();
+ foreach (@sourcefiles) {
+ copy($_, curdir());
+ push @destfiles, catfile(curdir(), basename($_));
+ }
+ foreach (@_) {
+ die "Internal error, argument is not CODE"
+ unless (ref($_) eq 'CODE');
+ $_->(@destfiles);
+ }
+}