summaryrefslogtreecommitdiff
path: root/src/test/authentication
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/authentication')
-rw-r--r--src/test/authentication/t/001_password.pl29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/test/authentication/t/001_password.pl b/src/test/authentication/t/001_password.pl
index 1305de0051a..1b4323fe2a6 100644
--- a/src/test/authentication/t/001_password.pl
+++ b/src/test/authentication/t/001_password.pl
@@ -17,7 +17,7 @@ if (!$use_unix_sockets)
}
else
{
- plan tests => 10;
+ plan tests => 13;
}
@@ -45,7 +45,9 @@ sub test_role
$status_string = 'success' if ($expected_res eq 0);
- my $res = $node->psql('postgres', undef, extra_params => [ '-U', $role ]);
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ my $res = $node->psql('postgres', undef, extra_params => [ '-U', $role, '-w' ]);
is($res, $expected_res,
"authentication $status_string for method $method, role $role");
return;
@@ -96,3 +98,26 @@ test_role($node, 'scram_role', 'scram-sha-256', 2);
reset_pg_hba($node, 'scram-sha-256');
$ENV{"PGCHANNELBINDING"} = 'require';
test_role($node, 'scram_role', 'scram-sha-256', 2);
+
+# Test .pgpass processing; but use a temp file, don't overwrite the real one!
+my $pgpassfile = "${TestLib::tmp_check}/pgpass";
+
+delete $ENV{"PGPASSWORD"};
+delete $ENV{"PGCHANNELBINDING"};
+$ENV{"PGPASSFILE"} = $pgpassfile;
+
+append_to_file($pgpassfile, qq!
+# This very long comment is just here to exercise handling of long lines in the file. This very long comment is just here to exercise handling of long lines in the file. This very long comment is just here to exercise handling of long lines in the file. This very long comment is just here to exercise handling of long lines in the file. This very long comment is just here to exercise handling of long lines in the file.
+*:*:postgres:scram_role:pass:this is not part of the password.
+!);
+chmod 0600, $pgpassfile or die;
+
+reset_pg_hba($node, 'password');
+test_role($node, 'scram_role', 'password from pgpass', 0);
+test_role($node, 'md5_role', 'password from pgpass', 2);
+
+append_to_file($pgpassfile, qq!
+*:*:*:md5_role:p\\ass
+!);
+
+test_role($node, 'md5_role', 'password from pgpass', 0);