Simplify TAP tests of pg_dump for connection strings
authorMichael Paquier <[email protected]>
Thu, 4 Jul 2019 02:33:42 +0000 (11:33 +0900)
committerMichael Paquier <[email protected]>
Thu, 4 Jul 2019 02:33:42 +0000 (11:33 +0900)
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[email protected]

src/bin/pg_dump/t/010_dump_connstr.pl

index 048ecf24eb46e3c0999b332273f7e6010cee1c6b..dc610fa49437dcba41ae1d0c0557902a38c1b072 100644 (file)
@@ -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 ]);