From d5ab9a891cb590aad4278026b2edda685f2524a2 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Thu, 4 Jul 2019 11:33:42 +0900 Subject: [PATCH] Simplify TAP tests of pg_dump for connection strings The last set of scenarios did an initialization of nodes followed by an extra command to set up the authentication policy with pg_regress --config-auth. This configuration step can be integrated directly using the option auth_extra from PostgresNode::init when initializing the node, saving from one extra command. On Windows, this also restricts more pg_ident.conf for the SSPI user mapping by removing the entry of the OS user running the test, which is not needed anyway. Note that IPC::Run mishandles double quotes, hence the restore user name is changed to map with that. This was already done in the test as a later step, but not in a consistent way, causing the switch to use auth_extra to fail. Found while reviewing ca129e5. Discussion: https://postgr.es/m/20190703062024.GD3084@paquier.xyz --- src/bin/pg_dump/t/010_dump_connstr.pl | 32 ++++++++++----------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/bin/pg_dump/t/010_dump_connstr.pl b/src/bin/pg_dump/t/010_dump_connstr.pl index 048ecf24eb..dc610fa494 100644 --- a/src/bin/pg_dump/t/010_dump_connstr.pl +++ b/src/bin/pg_dump/t/010_dump_connstr.pl @@ -171,21 +171,19 @@ $node->command_ok( system_log('cat', $plain); my ($stderr, $result); my $restore_super = qq{regress_a'b\\c=d\\ne"f}; +$restore_super =~ s/"//g + if $TestLib::windows_os; # IPC::Run mishandles '"' on Windows # Restore full dump through psql using environment variables for # dbname/user connection parameters my $envar_node = get_new_node('destination_envar'); -$envar_node->init(extra => - [ '-U', $dst_bootstrap_super, '--locale=C', '--encoding=LATIN1' ]); -$envar_node->run_log( - [ - $ENV{PG_REGRESS}, '--config-auth', - $envar_node->data_dir, '--user', - $dst_bootstrap_super, '--create-role', - $restore_super - ]); +$envar_node->init( + extra => + [ '-U', $dst_bootstrap_super, '--locale=C', '--encoding=LATIN1' ], + auth_extra => + [ '--user', $dst_bootstrap_super, '--create-role', $restore_super ]); $envar_node->start; # make superuser for restore @@ -207,18 +205,12 @@ is($stderr, '', 'no dump errors'); # dbname/user connection parameters. "\connect dbname=" forgets # user/port from command line. -$restore_super =~ s/"//g - if $TestLib::windows_os; # IPC::Run mishandles '"' on Windows my $cmdline_node = get_new_node('destination_cmdline'); -$cmdline_node->init(extra => - [ '-U', $dst_bootstrap_super, '--locale=C', '--encoding=LATIN1' ]); -$cmdline_node->run_log( - [ - $ENV{PG_REGRESS}, '--config-auth', - $cmdline_node->data_dir, '--user', - $dst_bootstrap_super, '--create-role', - $restore_super - ]); +$cmdline_node->init( + extra => + [ '-U', $dst_bootstrap_super, '--locale=C', '--encoding=LATIN1' ], + auth_extra => + [ '--user', $dst_bootstrap_super, '--create-role', $restore_super ]); $cmdline_node->start; $cmdline_node->run_log( [ 'createuser', '-U', $dst_bootstrap_super, '-s', $restore_super ]);