From a5d189ba8e2d9fad23ca68de9706ea6dad29b002 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Thu, 3 Dec 2026 11:37:27 +0000 Subject: [PATCH] Patch the libpq version in two OAuth server tests so they pass on libpq older than 18. test_server_kerberos_exclusivity and test_update_checked_endpoint save or update servers that use oauth_direct, which pgAdmin refuses when its libpq is older than 18. They passed where CI loads libpq 18 or later, but failed on macOS and Windows against PostgreSQL 15 to 17. Patch the loaded libpq version to 18, as the other auth method tests already do, so they run the same on any libpq. --- .../servers/tests/test_server_kerberos_exclusivity.py | 9 +++++++++ .../servers/tests/test_update_checked_endpoint.py | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_server_kerberos_exclusivity.py b/web/pgadmin/browser/server_groups/servers/tests/test_server_kerberos_exclusivity.py index 9da9c74c416..e2a52cdb0e8 100644 --- a/web/pgadmin/browser/server_groups/servers/tests/test_server_kerberos_exclusivity.py +++ b/web/pgadmin/browser/server_groups/servers/tests/test_server_kerberos_exclusivity.py @@ -12,11 +12,15 @@ import json import unittest +from unittest.mock import patch from pgadmin.model import Server from pgadmin.utils.route import BaseTestGenerator from regression.python_test_utils import test_utils as utils +LIBPQ_VERSION = 'pgadmin.utils.pg_oauth2.loaded_libpq_version' +LIBPQ_18 = 180000 + class ServerKerberosExclusivityTestCase(BaseTestGenerator): @@ -76,6 +80,11 @@ def setUp(self): # server is needed. unittest.TestCase.setUp(self) self.server_id = None + # The token methods need libpq 18 or later, so patch the version + # for the scenarios to run the same on any libpq. + libpq = patch(LIBPQ_VERSION, return_value=LIBPQ_18) + libpq.start() + self.addCleanup(libpq.stop) def _url(self, *parts): return '/browser/server/obj/{0}/'.format( diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_update_checked_endpoint.py b/web/pgadmin/browser/server_groups/servers/tests/test_update_checked_endpoint.py index a326ac192f7..00439cb92c2 100644 --- a/web/pgadmin/browser/server_groups/servers/tests/test_update_checked_endpoint.py +++ b/web/pgadmin/browser/server_groups/servers/tests/test_update_checked_endpoint.py @@ -26,6 +26,8 @@ from pgadmin.utils.route import BaseTestGenerator ServerNode = servers_module.ServerNode +LIBPQ_VERSION = 'pgadmin.utils.pg_oauth2.loaded_libpq_version' +LIBPQ_18 = 180000 SHOWN = ('db.example.com', 5432, {'sslmode': 'verify-full'}) @@ -49,6 +51,11 @@ def setUp(self): self.app = Flask(__name__) self.app.config.update(SECRET_KEY='unit-test', TESTING=True) Babel(self.app) + # The OAuth methods need libpq 18 or later, so patch the version + # for the scenarios to run the same on any libpq. + libpq = patch(LIBPQ_VERSION, return_value=LIBPQ_18) + libpq.start() + self.addCleanup(libpq.stop) def runTest(self): server = SimpleNamespace(