From 8380fe08a025bd41b242c545f7c1b4f333274cbc Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Wed, 24 Feb 2021 17:16:45 +0100 Subject: Fixed #32456 -- Added dbshell support for specifying a password file on PostgreSQL. --- tests/dbshell/test_postgresql.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/dbshell/test_postgresql.py') diff --git a/tests/dbshell/test_postgresql.py b/tests/dbshell/test_postgresql.py index 3345035a24..a96acac6f1 100644 --- a/tests/dbshell/test_postgresql.py +++ b/tests/dbshell/test_postgresql.py @@ -73,6 +73,34 @@ class PostgreSqlDbshellCommandTestCase(SimpleTestCase): (['psql'], {'PGSERVICE': 'django_test'}), ) + def test_passfile(self): + self.assertEqual( + self.settings_to_cmd_args_env({ + 'NAME': 'dbname', + 'USER': 'someuser', + 'HOST': 'somehost', + 'PORT': '444', + 'OPTIONS': { + 'passfile': '~/.custompgpass', + }, + }), + ( + ['psql', '-U', 'someuser', '-h', 'somehost', '-p', '444', 'dbname'], + {'PGPASSFILE': '~/.custompgpass'}, + ), + ) + self.assertEqual( + self.settings_to_cmd_args_env({ + 'OPTIONS': { + 'service': 'django_test', + 'passfile': '~/.custompgpass', + }, + }), + ( + ['psql'], {'PGSERVICE': 'django_test', 'PGPASSFILE': '~/.custompgpass'}, + ), + ) + def test_column(self): self.assertEqual( self.settings_to_cmd_args_env({ -- cgit v1.2.1