diff options
author | Mike Crute <mike@crute.us> | 2022-12-05 20:26:37 -0800 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-01-03 09:30:53 +0100 |
commit | 0b78ac3fc7bd9f0c57518d0c1a153582318edd59 (patch) | |
tree | 75e44e6158f91dd1ade63c7d9a2aac9e34fb78d7 /tests/backends | |
parent | 2a14b8df39b573124ea42dec0ce96147c8e767d4 (diff) | |
download | django-0b78ac3fc7bd9f0c57518d0c1a153582318edd59.tar.gz |
Fixed #34200 -- Made the session role configurable on PostgreSQL.
Diffstat (limited to 'tests/backends')
-rw-r--r-- | tests/backends/postgresql/tests.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/backends/postgresql/tests.py b/tests/backends/postgresql/tests.py index 7e1a2d000d..7b0e0bfb52 100644 --- a/tests/backends/postgresql/tests.py +++ b/tests/backends/postgresql/tests.py @@ -15,7 +15,7 @@ from django.db.backends.base.base import BaseDatabaseWrapper from django.test import TestCase, override_settings try: - from django.db.backends.postgresql.psycopg_any import is_psycopg3 + from django.db.backends.postgresql.psycopg_any import errors, is_psycopg3 except ImportError: is_psycopg3 = False @@ -262,6 +262,21 @@ class Tests(TestCase): with self.assertRaisesMessage(ImproperlyConfigured, msg): new_connection.ensure_connection() + def test_connect_role(self): + """ + The session role can be configured with DATABASES + ["OPTIONS"]["assume_role"]. + """ + try: + custom_role = "django_nonexistent_role" + new_connection = connection.copy() + new_connection.settings_dict["OPTIONS"]["assume_role"] = custom_role + msg = f'role "{custom_role}" does not exist' + with self.assertRaisesMessage(errors.InvalidParameterValue, msg): + new_connection.connect() + finally: + new_connection.close() + def test_connect_no_is_usable_checks(self): new_connection = connection.copy() try: |