test: restore app.PGADMIN_EXTERNAL_AUTH_SOURCE in auth-mocking tearDown

Each of the Kerberos/LDAP/OAuth2/webserver login-mocking test classes
sets self.app.PGADMIN_EXTERNAL_AUTH_SOURCE (the Flask app instance
attribute before_request() actually reads) in setUp, but tearDownClass
only restored app_config.PGADMIN_EXTERNAL_AUTH_SOURCE -- a different
object (the config module). Whichever of these classes ran last
(test_webserver_with_mocking, alphabetically) left the live app
attribute stuck at WEBSERVER for the rest of the suite, making
before_request() route every subsequent unauthenticated /login request
through authenticate.login()'s webserver auto-auth path instead of
rendering the login form -- surfacing as an unrelated CSRF-harvest
failure in test_close_requires_auth much later in the run.

Full server-mode regression: 2507 tests, 0 failures/errors (was 2).
This commit is contained in:
Ashesh Vashi
2026-07-28 11:07:37 +05:30
parent 689d200e9f
commit 78f7a5f6ab
5 changed files with 10 additions and 0 deletions
@@ -8,6 +8,7 @@
##########################################################################
import config as app_config
from pgAdmin4 import app
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils as utils
from pgadmin.authenticate.registry import AuthSourceRegistry
@@ -166,4 +167,5 @@ class KerberosLoginMockTestCase(BaseTestGenerator):
cls.tester.logout()
app_config.AUTHENTICATION_SOURCES = [INTERNAL]
app_config.PGADMIN_EXTERNAL_AUTH_SOURCE = INTERNAL
app.PGADMIN_EXTERNAL_AUTH_SOURCE = INTERNAL
utils.login_tester_account(cls.tester)
@@ -8,6 +8,7 @@
##########################################################################
import config as app_config
from pgAdmin4 import app
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils as utils
from regression.test_setup import config_data
@@ -103,4 +104,5 @@ class LDAPLoginTestCase(BaseTestGenerator):
cls.tester.logout()
app_config.AUTHENTICATION_SOURCES = [INTERNAL]
app_config.PGADMIN_EXTERNAL_AUTH_SOURCE = INTERNAL
app.PGADMIN_EXTERNAL_AUTH_SOURCE = INTERNAL
utils.login_tester_account(cls.tester)
@@ -8,6 +8,7 @@
##########################################################################
import config as app_config
from pgAdmin4 import app
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils as utils
from regression.test_setup import config_data
@@ -87,4 +88,5 @@ class LDAPLoginMockTestCase(BaseTestGenerator):
cls.tester.logout()
app_config.AUTHENTICATION_SOURCES = [INTERNAL]
app_config.PGADMIN_EXTERNAL_AUTH_SOURCE = INTERNAL
app.PGADMIN_EXTERNAL_AUTH_SOURCE = INTERNAL
utils.login_tester_account(cls.tester)
@@ -8,6 +8,7 @@
##########################################################################
import config as app_config
from pgAdmin4 import app
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils as utils
from pgadmin.authenticate.registry import AuthSourceRegistry
@@ -862,4 +863,5 @@ class Oauth2LoginMockTestCase(BaseTestGenerator):
cls.tester.logout()
app_config.AUTHENTICATION_SOURCES = [INTERNAL]
app_config.PGADMIN_EXTERNAL_AUTH_SOURCE = INTERNAL
app.PGADMIN_EXTERNAL_AUTH_SOURCE = INTERNAL
utils.login_tester_account(cls.tester)
@@ -8,6 +8,7 @@
##########################################################################
import config as app_config
from pgAdmin4 import app
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils as utils
from pgadmin.authenticate.registry import AuthSourceRegistry
@@ -87,4 +88,5 @@ class WebserverLoginMockTestCase(BaseTestGenerator):
cls.tester.logout()
app_config.AUTHENTICATION_SOURCES = [INTERNAL]
app_config.PGADMIN_EXTERNAL_AUTH_SOURCE = INTERNAL
app.PGADMIN_EXTERNAL_AUTH_SOURCE = INTERNAL
utils.login_tester_account(cls.tester)