Skip to content

Commit bf5a894

Browse files
Test SCRAM iteration changes with psql \password
A version of this test was included in the original patch for altering SCRAM iteration count, but was omitted due to how interactive psql TAP sessions worked before being refactored. Discussion: https://postgr.es/m/20230130194350.zj5v467x4jgqt3d6@awork3.anarazel.de Discussion: https://postgr.es/m/F72E7BC7-189F-4B17-BF47-9735EB72C364@yesql.se
1 parent 664d757 commit bf5a894

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/authentication/t/001_password.pl

+26
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,32 @@ sub test_conn
101101
WHERE rolname = 'scram_role_iter'");
102102
is($res, 'SCRAM-SHA-256$1024:', 'scram_iterations in server side ROLE');
103103

104+
# If we don't have IO::Pty, forget it, because IPC::Run depends on that
105+
# to support pty connections
106+
SKIP:
107+
{
108+
skip "IO::Pty required", 1 unless eval { require IO::Pty; };
109+
110+
# Alter the password on the created role using \password in psql to ensure
111+
# that clientside password changes use the scram_iterations value when
112+
# calculating SCRAM secrets.
113+
my $session = $node->interactive_psql('postgres');
114+
115+
$session->set_query_timer_restart();
116+
$session->query("SET password_encryption='scram-sha-256';");
117+
$session->query("SET scram_iterations=42;");
118+
$session->query_until(qr/Enter new password/, "\\password scram_role_iter\n");
119+
$session->query_until(qr/Enter it again/, "pass\n");
120+
$session->query_until(qr/postgres=# /, "pass\n");
121+
$session->quit;
122+
123+
$res = $node->safe_psql('postgres',
124+
"SELECT substr(rolpassword,1,17)
125+
FROM pg_authid
126+
WHERE rolname = 'scram_role_iter'");
127+
is($res, 'SCRAM-SHA-256$42:', 'scram_iterations in psql \password command');
128+
}
129+
104130
# Create a database to test regular expression.
105131
$node->safe_psql('postgres', "CREATE database regex_testdb;");
106132

0 commit comments

Comments
 (0)