diff options
| author | Michael Paquier | 2021-04-05 01:13:57 +0000 |
|---|---|---|
| committer | Michael Paquier | 2021-04-05 01:13:57 +0000 |
| commit | c50624cdd248c13b4ba199f95e24c88d2cc8a097 (patch) | |
| tree | 6fb036a55f9ad4f15b63cc64c23127d24759de6c /src/test/kerberos | |
| parent | dfc843d465689d2c2af8b0e01c66c51ccaae2343 (diff) | |
Refactor all TAP test suites doing connection checks
This commit refactors more TAP tests to adapt with the recent
introduction of connect_ok() and connect_fails() in PostgresNode,
introduced by 0d1a3343. This changes the following test suites to use
the same code paths for connection checks:
- Kerberos
- LDAP
- SSL
- Authentication
Those routines are extended to be able to handle optional parameters
that are set depending on each suite's needs, as of:
- custom SQL query.
- expected stderr matching pattern.
- expected stdout matching pattern.
The new design is extensible with more parameters, and there are some
plans for those routines in the future with checks based on the contents
of the backend logs.
Author: Jacob Champion, Michael Paquier
Discussion: https://postgr.es/m/d17b919e27474abfa55d97786cb9cfadfe2b59e9.camel@vmware.com
Diffstat (limited to 'src/test/kerberos')
| -rw-r--r-- | src/test/kerberos/t/001_auth.pl | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/src/test/kerberos/t/001_auth.pl b/src/test/kerberos/t/001_auth.pl index 38e9ef7b1f4..de52a667854 100644 --- a/src/test/kerberos/t/001_auth.pl +++ b/src/test/kerberos/t/001_auth.pl @@ -20,7 +20,7 @@ use Time::HiRes qw(usleep); if ($ENV{with_gssapi} eq 'yes') { - plan tests => 26; + plan tests => 30; } else { @@ -182,28 +182,25 @@ note "running tests"; # Test connection success or failure, and if success, that query returns true. sub test_access { - my ($node, $role, $query, $expected_res, $gssencmode, $test_name, $expect_log_msg) = @_; + my ($node, $role, $query, $expected_res, $gssencmode, $test_name, + $expect_log_msg) + = @_; # need to connect over TCP/IP for Kerberos - my ($res, $stdoutres, $stderrres) = $node->psql( - 'postgres', - "$query", - extra_params => [ - '-XAtd', - $node->connstr('postgres') - . " host=$host hostaddr=$hostaddr $gssencmode", - '-U', - $role - ]); - - # If we get a query result back, it should be true. - if ($res == $expected_res and $res eq 0) + my $connstr = $node->connstr('postgres') + . " user=$role host=$host hostaddr=$hostaddr $gssencmode"; + + if ($expected_res eq 0) { - is($stdoutres, "t", $test_name); + # The result is assumed to match "true", or "t", here. + $node->connect_ok( + $connstr, $test_name, + sql => $query, + expected_stdout => qr/t/); } else { - is($res, $expected_res, $test_name); + $node->connect_fails($connstr, $test_name); } # Verify specified log message is logged in the log file. @@ -227,20 +224,12 @@ sub test_query my ($node, $role, $query, $expected, $gssencmode, $test_name) = @_; # need to connect over TCP/IP for Kerberos - my ($res, $stdoutres, $stderrres) = $node->psql( - 'postgres', - "$query", - extra_params => [ - '-XAtd', - $node->connstr('postgres') - . " host=$host hostaddr=$hostaddr $gssencmode", - '-U', - $role - ]); - - is($res, 0, $test_name); - like($stdoutres, $expected, $test_name); - is($stderrres, "", $test_name); + my $connstr = $node->connstr('postgres') + . " user=$role host=$host hostaddr=$hostaddr $gssencmode"; + + my ($stdoutres, $stderrres); + + $node->connect_ok($connstr, $test_name, $query, $expected); return; } |
