Extend configure_test_server_for_ssl to add extensions
In order to be able to test extensions with SSL connections, allow configure_test_server_for_ssl to create any extensions passed as an array. Each extension is created in all the test databases. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Andrew Dunstan <andrew@dunslane.net> Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Discussion: https://postgr.es/m/E23F9811-0C77-45DA-912F-D809AB140741@yesql.se
This commit is contained in:
parent
be5455124b
commit
879fc1a579
@ -49,7 +49,7 @@ $node->start;
|
|||||||
|
|
||||||
# Configure server for SSL connections, with password handling.
|
# Configure server for SSL connections, with password handling.
|
||||||
configure_test_server_for_ssl($node, $SERVERHOSTADDR, $SERVERHOSTCIDR,
|
configure_test_server_for_ssl($node, $SERVERHOSTADDR, $SERVERHOSTCIDR,
|
||||||
"scram-sha-256", "pass", "scram-sha-256");
|
"scram-sha-256", 'password' => "pass", 'password_enc' => "scram-sha-256");
|
||||||
switch_server_cert($node, 'server-cn-only');
|
switch_server_cert($node, 'server-cn-only');
|
||||||
$ENV{PGPASSWORD} = "pass";
|
$ENV{PGPASSWORD} = "pass";
|
||||||
$common_connstr =
|
$common_connstr =
|
||||||
|
@ -62,38 +62,52 @@ sub copy_files
|
|||||||
# servercidr: what to put in pg_hba.conf, e.g. '127.0.0.1/32'
|
# servercidr: what to put in pg_hba.conf, e.g. '127.0.0.1/32'
|
||||||
sub configure_test_server_for_ssl
|
sub configure_test_server_for_ssl
|
||||||
{
|
{
|
||||||
my ($node, $serverhost, $servercidr, $authmethod, $password,
|
my ($node, $serverhost, $servercidr, $authmethod, %params) = @_;
|
||||||
$password_enc) = @_;
|
|
||||||
|
|
||||||
my $pgdata = $node->data_dir;
|
my $pgdata = $node->data_dir;
|
||||||
|
|
||||||
|
my @databases = ( 'trustdb', 'certdb', 'certdb_dn', 'certdb_dn_re', 'certdb_cn', 'verifydb' );
|
||||||
|
|
||||||
# Create test users and databases
|
# Create test users and databases
|
||||||
$node->psql('postgres', "CREATE USER ssltestuser");
|
$node->psql('postgres', "CREATE USER ssltestuser");
|
||||||
$node->psql('postgres', "CREATE USER md5testuser");
|
$node->psql('postgres', "CREATE USER md5testuser");
|
||||||
$node->psql('postgres', "CREATE USER anotheruser");
|
$node->psql('postgres', "CREATE USER anotheruser");
|
||||||
$node->psql('postgres', "CREATE USER yetanotheruser");
|
$node->psql('postgres', "CREATE USER yetanotheruser");
|
||||||
$node->psql('postgres', "CREATE DATABASE trustdb");
|
|
||||||
$node->psql('postgres', "CREATE DATABASE certdb");
|
foreach my $db (@databases)
|
||||||
$node->psql('postgres', "CREATE DATABASE certdb_dn");
|
{
|
||||||
$node->psql('postgres', "CREATE DATABASE certdb_dn_re");
|
$node->psql('postgres', "CREATE DATABASE $db");
|
||||||
$node->psql('postgres', "CREATE DATABASE certdb_cn");
|
}
|
||||||
$node->psql('postgres', "CREATE DATABASE verifydb");
|
|
||||||
|
|
||||||
# Update password of each user as needed.
|
# Update password of each user as needed.
|
||||||
if (defined($password))
|
if (defined($params{password}))
|
||||||
{
|
{
|
||||||
|
die "Password encryption must be specified when password is set"
|
||||||
|
unless defined($params{password_enc});
|
||||||
|
|
||||||
$node->psql('postgres',
|
$node->psql('postgres',
|
||||||
"SET password_encryption='$password_enc'; ALTER USER ssltestuser PASSWORD '$password';"
|
"SET password_encryption='$params{password_enc}'; ALTER USER ssltestuser PASSWORD '$params{password}';"
|
||||||
);
|
);
|
||||||
# A special user that always has an md5-encrypted password
|
# A special user that always has an md5-encrypted password
|
||||||
$node->psql('postgres',
|
$node->psql('postgres',
|
||||||
"SET password_encryption='md5'; ALTER USER md5testuser PASSWORD '$password';"
|
"SET password_encryption='md5'; ALTER USER md5testuser PASSWORD '$params{password}';"
|
||||||
);
|
);
|
||||||
$node->psql('postgres',
|
$node->psql('postgres',
|
||||||
"SET password_encryption='$password_enc'; ALTER USER anotheruser PASSWORD '$password';"
|
"SET password_encryption='$params{password_enc}'; ALTER USER anotheruser PASSWORD '$params{password}';"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create any extensions requested in the setup
|
||||||
|
if (defined($params{extensions}))
|
||||||
|
{
|
||||||
|
foreach my $extension (@{$params{extensions}})
|
||||||
|
{
|
||||||
|
foreach my $db (@databases)
|
||||||
|
{
|
||||||
|
$node->psql($db, "CREATE EXTENSION $extension CASCADE;");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# enable logging etc.
|
# enable logging etc.
|
||||||
open my $conf, '>>', "$pgdata/postgresql.conf";
|
open my $conf, '>>', "$pgdata/postgresql.conf";
|
||||||
print $conf "fsync=off\n";
|
print $conf "fsync=off\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user