Fix ssl tests for when tls-server-end-point is not supported
Add a function to TestLib that allows us to check pg_config.h and then decide the expected test outcome based on that. Author: Michael Paquier <michael.paquier@gmail.com>
This commit is contained in:
parent
8a906204ae
commit
c3d41ccf59
@ -26,6 +26,7 @@ our @EXPORT = qw(
|
|||||||
slurp_dir
|
slurp_dir
|
||||||
slurp_file
|
slurp_file
|
||||||
append_to_file
|
append_to_file
|
||||||
|
check_pg_config
|
||||||
system_or_bail
|
system_or_bail
|
||||||
system_log
|
system_log
|
||||||
run_log
|
run_log
|
||||||
@ -221,6 +222,24 @@ sub append_to_file
|
|||||||
close $fh;
|
close $fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check presence of a given regexp within pg_config.h for the installation
|
||||||
|
# where tests are running, returning a match status result depending on
|
||||||
|
# that.
|
||||||
|
sub check_pg_config
|
||||||
|
{
|
||||||
|
my ($regexp) = @_;
|
||||||
|
my ($stdout, $stderr);
|
||||||
|
my $result = IPC::Run::run [ 'pg_config', '--includedir' ], '>',
|
||||||
|
\$stdout, '2>', \$stderr
|
||||||
|
or die "could not execute pg_config";
|
||||||
|
chomp($stdout);
|
||||||
|
|
||||||
|
open my $pg_config_h, '<', "$stdout/pg_config.h" or die "$!";
|
||||||
|
my $match = (grep {/^$regexp/} <$pg_config_h>);
|
||||||
|
close $pg_config_h;
|
||||||
|
return $match;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test functions
|
# Test functions
|
||||||
#
|
#
|
||||||
|
@ -11,6 +11,10 @@ use File::Copy;
|
|||||||
# This is the hostname used to connect to the server.
|
# This is the hostname used to connect to the server.
|
||||||
my $SERVERHOSTADDR = '127.0.0.1';
|
my $SERVERHOSTADDR = '127.0.0.1';
|
||||||
|
|
||||||
|
# Determine whether build supports tls-server-end-point.
|
||||||
|
my $supports_tls_server_end_point =
|
||||||
|
check_pg_config("#define HAVE_X509_GET_SIGNATURE_NID 1");
|
||||||
|
|
||||||
# Allocation of base connection string shared among multiple tests.
|
# Allocation of base connection string shared among multiple tests.
|
||||||
my $common_connstr;
|
my $common_connstr;
|
||||||
|
|
||||||
@ -45,9 +49,18 @@ test_connect_ok($common_connstr,
|
|||||||
test_connect_ok($common_connstr,
|
test_connect_ok($common_connstr,
|
||||||
"scram_channel_binding=''",
|
"scram_channel_binding=''",
|
||||||
"SCRAM authentication without channel binding");
|
"SCRAM authentication without channel binding");
|
||||||
|
if ($supports_tls_server_end_point)
|
||||||
|
{
|
||||||
test_connect_ok($common_connstr,
|
test_connect_ok($common_connstr,
|
||||||
"scram_channel_binding=tls-server-end-point",
|
"scram_channel_binding=tls-server-end-point",
|
||||||
"SCRAM authentication with tls-server-end-point as channel binding");
|
"SCRAM authentication with tls-server-end-point as channel binding");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
test_connect_fails($common_connstr,
|
||||||
|
"scram_channel_binding=tls-server-end-point",
|
||||||
|
"SCRAM authentication with tls-server-end-point as channel binding");
|
||||||
|
}
|
||||||
test_connect_fails($common_connstr,
|
test_connect_fails($common_connstr,
|
||||||
"scram_channel_binding=not-exists",
|
"scram_channel_binding=not-exists",
|
||||||
"SCRAM authentication with invalid channel binding");
|
"SCRAM authentication with invalid channel binding");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user