Commit 5d79b67b authored by Heikki Linnakangas's avatar Heikki Linnakangas

Make SSL regression test suite more portable by avoiding cp.

Use perl 'glob' and File::Copy instead of "cp". This takes us one step
closer to running the suite on Windows.

Michael Paquier
parent 0fb256dc
...@@ -19,6 +19,8 @@ package ServerSetup; ...@@ -19,6 +19,8 @@ package ServerSetup;
use strict; use strict;
use warnings; use warnings;
use TestLib; use TestLib;
use File::Basename;
use File::Copy;
use Test::More; use Test::More;
use Exporter 'import'; use Exporter 'import';
...@@ -26,6 +28,20 @@ our @EXPORT = qw( ...@@ -26,6 +28,20 @@ our @EXPORT = qw(
configure_test_server_for_ssl switch_server_cert configure_test_server_for_ssl switch_server_cert
); );
# Copy a set of files, taking into account wildcards
sub copy_files
{
my $orig = shift;
my $dest = shift;
my @orig_files = glob $orig;
foreach my $orig_file (@orig_files)
{
my $base_file = basename($orig_file);
copy($orig_file, "$dest/$base_file") or die "Could not copy $orig_file to $dest";
}
}
sub configure_test_server_for_ssl sub configure_test_server_for_ssl
{ {
my $tempdir = $_[0]; my $tempdir = $_[0];
...@@ -48,13 +64,12 @@ sub configure_test_server_for_ssl ...@@ -48,13 +64,12 @@ sub configure_test_server_for_ssl
close CONF; close CONF;
# Copy all server certificates and keys, and client root cert, to the data dir # Copy all server certificates and keys, and client root cert, to the data dir
system_or_bail "cp ssl/server-*.crt '$tempdir'/pgdata"; copy_files("ssl/server-*.crt", "$tempdir/pgdata");
system_or_bail "cp ssl/server-*.key '$tempdir'/pgdata"; copy_files("ssl/server-*.key", "$tempdir/pgdata");
system_or_bail "chmod 0600 '$tempdir'/pgdata/server-*.key"; system_or_bail "chmod 0600 '$tempdir'/pgdata/server-*.key";
system_or_bail "cp ssl/root+client_ca.crt '$tempdir'/pgdata"; copy_files("ssl/root+client_ca.crt", "$tempdir/pgdata");
system_or_bail "cp ssl/root+client.crl '$tempdir'/pgdata"; copy_files("ssl/root+client.crl", "$tempdir/pgdata");
# Only accept SSL connections from localhost. Our tests don't depend on this # Only accept SSL connections from localhost. Our tests don't depend on this
# but seems best to keep it as narrow as possible for security reasons. # but seems best to keep it as narrow as possible for security reasons.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment