Closed afig closed 6 years ago
See here for one auto-login solution. psql allows automatic login by setting the PGPASSWORD
environment variable (in the client system's shell) to the password of the logging in user. psql can also set shell environment variables using the \setenv
meta command. So by setting PGPASSWORD
to the necessary password before using \c
, the user will auto login. At the end, PGPASSWORD
should be set to nothing, otherwise psql will continue to try and use its value for any user logging in and will not prompt the user for a password.
Several scripts, including
testAddConnectionActivityLogging.psql
and all Privilege tests, require the user who is running the tests to enter a password when connecting to the database as the test users/roles. IntestAddConnectionActivityLogging.psql
, the password for the test roles are' '
, and for the privilege tests, the password is the same as the name of the test role.Users are essentially only given one chance to type in the password correctly. If the user running the tests incorrectly types the password for the test role, the psql client is left in a state of not being connected to a database, requiring the user to quit/exit the psql window and having to reconnect to the database and run the tests anew.
Two possible solutions are:
The first solution may not be easy to implement, since this behavior is by design (running a script places psql in non-interactive mode):
The second solution would be ideal, making running of tests significantly easier on the user, and possibly, easier to automate in the future. This should be possible through the use of the \connect psql command with a Connection String. However, it remains to be investigated how the correct
host
andport
settings will be determined, and whether the connection string can be generated at script runtime.