Skip to content

Testing scripts require a user to correctly type in a password (N) #207

@afig

Description

@afig

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. In testAddConnectionActivityLogging.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:

  1. Gracefully handle an incorrectly typed password, allowing the user another chance to type in the password again (security is not an issue here since these are only test scripts with test roles).
  2. Have it so users do not have to manually type in a password.

The first solution may not be easy to implement, since this behavior is by design (running a script places psql in non-interactive mode):

If the connection attempt failed (wrong user name, access denied, etc.), the previous connection will only be kept if psql is in interactive mode. When executing a non-interactive script, processing will immediately stop with an error. This distinction was chosen as a user convenience against typos on the one hand, and a safety mechanism that scripts are not accidentally acting on the wrong database on the other hand.
psql - \connect

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 and port settings will be determined, and whether the connection string can be generated at script runtime.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions