Skip to content

Commit c3d41cc

Browse files
committed
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>
1 parent 8a90620 commit c3d41cc

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

src/test/perl/TestLib.pm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ our @EXPORT = qw(
2626
slurp_dir
2727
slurp_file
2828
append_to_file
29+
check_pg_config
2930
system_or_bail
3031
system_log
3132
run_log
@@ -221,6 +222,24 @@ sub append_to_file
221222
close $fh;
222223
}
223224

225+
# Check presence of a given regexp within pg_config.h for the installation
226+
# where tests are running, returning a match status result depending on
227+
# that.
228+
sub check_pg_config
229+
{
230+
my ($regexp) = @_;
231+
my ($stdout, $stderr);
232+
my $result = IPC::Run::run [ 'pg_config', '--includedir' ], '>',
233+
\$stdout, '2>', \$stderr
234+
or die "could not execute pg_config";
235+
chomp($stdout);
236+
237+
open my $pg_config_h, '<', "$stdout/pg_config.h" or die "$!";
238+
my $match = (grep {/^$regexp/} <$pg_config_h>);
239+
close $pg_config_h;
240+
return $match;
241+
}
242+
224243
#
225244
# Test functions
226245
#

src/test/ssl/t/002_scram.pl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# This is the hostname used to connect to the server.
1212
my $SERVERHOSTADDR = '127.0.0.1';
1313

14+
# Determine whether build supports tls-server-end-point.
15+
my $supports_tls_server_end_point =
16+
check_pg_config("#define HAVE_X509_GET_SIGNATURE_NID 1");
17+
1418
# Allocation of base connection string shared among multiple tests.
1519
my $common_connstr;
1620

@@ -44,10 +48,19 @@
4448
"SCRAM authentication with tls-unique as channel binding");
4549
test_connect_ok($common_connstr,
4650
"scram_channel_binding=''",
47-
"SCRAM authentication without channel binding");
48-
test_connect_ok($common_connstr,
49-
"scram_channel_binding=tls-server-end-point",
50-
"SCRAM authentication with tls-server-end-point as channel binding");
51+
"SCRAM authentication without channel binding");
52+
if ($supports_tls_server_end_point)
53+
{
54+
test_connect_ok($common_connstr,
55+
"scram_channel_binding=tls-server-end-point",
56+
"SCRAM authentication with tls-server-end-point as channel binding");
57+
}
58+
else
59+
{
60+
test_connect_fails($common_connstr,
61+
"scram_channel_binding=tls-server-end-point",
62+
"SCRAM authentication with tls-server-end-point as channel binding");
63+
}
5164
test_connect_fails($common_connstr,
5265
"scram_channel_binding=not-exists",
5366
"SCRAM authentication with invalid channel binding");

0 commit comments

Comments
 (0)