Commit a09009e4 authored by Robert Haas's avatar Robert Haas

Update the SSL test suite for recent changes to TAP testing framework.

listen_addresses needs to be handled differently now, and so does
logging.

Michael Paquier
parent 30bb26b5
...@@ -46,6 +46,7 @@ sub copy_files ...@@ -46,6 +46,7 @@ sub copy_files
sub configure_test_server_for_ssl sub configure_test_server_for_ssl
{ {
my $tempdir = $_[0]; my $tempdir = $_[0];
my $serverhost = $_[1];
# Create test users and databases # Create test users and databases
psql 'postgres', "CREATE USER ssltestuser"; psql 'postgres', "CREATE USER ssltestuser";
...@@ -58,6 +59,7 @@ sub configure_test_server_for_ssl ...@@ -58,6 +59,7 @@ sub configure_test_server_for_ssl
print CONF "fsync=off\n"; print CONF "fsync=off\n";
print CONF "log_connections=on\n"; print CONF "log_connections=on\n";
print CONF "log_hostname=on\n"; print CONF "log_hostname=on\n";
print CONF "listen_addresses='$serverhost'\n";
print CONF "log_statement=all\n"; print CONF "log_statement=all\n";
# enable SSL and set up server key # enable SSL and set up server key
...@@ -80,11 +82,11 @@ sub configure_test_server_for_ssl ...@@ -80,11 +82,11 @@ sub configure_test_server_for_ssl
print HBA print HBA
"# TYPE DATABASE USER ADDRESS METHOD\n"; "# TYPE DATABASE USER ADDRESS METHOD\n";
print HBA print HBA
"hostssl trustdb ssltestuser 127.0.0.1/32 trust\n"; "hostssl trustdb ssltestuser $serverhost/32 trust\n";
print HBA print HBA
"hostssl trustdb ssltestuser ::1/128 trust\n"; "hostssl trustdb ssltestuser ::1/128 trust\n";
print HBA print HBA
"hostssl certdb ssltestuser 127.0.0.1/32 cert\n"; "hostssl certdb ssltestuser $serverhost/32 cert\n";
print HBA print HBA
"hostssl certdb ssltestuser ::1/128 cert\n"; "hostssl certdb ssltestuser ::1/128 cert\n";
close HBA; close HBA;
...@@ -107,10 +109,6 @@ sub switch_server_cert ...@@ -107,10 +109,6 @@ sub switch_server_cert
print SSLCONF "ssl_crl_file='root+client.crl'\n"; print SSLCONF "ssl_crl_file='root+client.crl'\n";
close SSLCONF; close SSLCONF;
# Stop and restart server to reload the new config. We cannot use # Stop and restart server to reload the new config.
# restart_test_server() because that overrides listen_addresses to only all restart_test_server();
# Unix domain socket connections.
system_or_bail 'pg_ctl', 'stop', '-D', "$tempdir/pgdata";
system_or_bail 'pg_ctl', 'start', '-D', "$tempdir/pgdata", '-w';
} }
...@@ -27,9 +27,6 @@ my $SERVERHOSTADDR = '127.0.0.1'; ...@@ -27,9 +27,6 @@ my $SERVERHOSTADDR = '127.0.0.1';
my $tempdir = TestLib::tempdir; my $tempdir = TestLib::tempdir;
#my $tempdir = "tmp_check";
# Define a couple of helper functions to test connecting to the server. # Define a couple of helper functions to test connecting to the server.
my $common_connstr; my $common_connstr;
...@@ -43,12 +40,7 @@ sub run_test_psql ...@@ -43,12 +40,7 @@ sub run_test_psql
'psql', '-A', '-t', '-c', "SELECT 'connected with $connstr'", 'psql', '-A', '-t', '-c', "SELECT 'connected with $connstr'",
'-d', "$connstr" ]; '-d', "$connstr" ];
open CLIENTLOG, ">>$tempdir/client-log" my $result = run_log($cmd);
or die "Could not open client-log file";
print CLIENTLOG "\n# Running test: $connstr $logstring\n";
close CLIENTLOG;
my $result = run $cmd, '>>', "$tempdir/client-log", '2>&1';
return $result; return $result;
} }
...@@ -84,7 +76,7 @@ chmod 0600, "ssl/client.key"; ...@@ -84,7 +76,7 @@ chmod 0600, "ssl/client.key";
diag "setting up data directory in \"$tempdir\"..."; diag "setting up data directory in \"$tempdir\"...";
start_test_server($tempdir); start_test_server($tempdir);
configure_test_server_for_ssl($tempdir); configure_test_server_for_ssl($tempdir, $SERVERHOSTADDR);
switch_server_cert($tempdir, 'server-cn-only'); switch_server_cert($tempdir, 'server-cn-only');
### Part 1. Run client-side tests. ### Part 1. Run client-side tests.
......
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