mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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
This commit is contained in:
@@ -46,12 +46,19 @@ sub test_role
|
||||
|
||||
$status_string = 'success' if ($expected_res eq 0);
|
||||
|
||||
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||
my $connstr = "user=$role";
|
||||
my $testname =
|
||||
"authentication $status_string for method $method, role $role";
|
||||
|
||||
my $res = $node->psql('postgres', undef, extra_params => [ '-U', $role, '-w' ]);
|
||||
is($res, $expected_res,
|
||||
"authentication $status_string for method $method, role $role");
|
||||
return;
|
||||
if ($expected_res eq 0)
|
||||
{
|
||||
$node->connect_ok($connstr, $testname);
|
||||
}
|
||||
else
|
||||
{
|
||||
# No checks of the error message, only the status code.
|
||||
$node->connect_fails($connstr, $testname);
|
||||
}
|
||||
}
|
||||
|
||||
# Initialize primary node
|
||||
|
@@ -41,12 +41,20 @@ sub test_login
|
||||
|
||||
$status_string = 'success' if ($expected_res eq 0);
|
||||
|
||||
my $connstr = "user=$role";
|
||||
my $testname =
|
||||
"authentication $status_string for role $role with password $password";
|
||||
|
||||
$ENV{"PGPASSWORD"} = $password;
|
||||
my $res = $node->psql('postgres', undef, extra_params => [ '-U', $role ]);
|
||||
is($res, $expected_res,
|
||||
"authentication $status_string for role $role with password $password"
|
||||
);
|
||||
return;
|
||||
if ($expected_res eq 0)
|
||||
{
|
||||
$node->connect_ok($connstr, $testname);
|
||||
}
|
||||
else
|
||||
{
|
||||
# No checks of the error message, only the status code.
|
||||
$node->connect_fails($connstr, $testname);
|
||||
}
|
||||
}
|
||||
|
||||
# Initialize primary node. Force UTF-8 encoding, so that we can use non-ASCII
|
||||
|
Reference in New Issue
Block a user