From c48f169d9102b2d05261c84004c46250ad83a9a9 Mon Sep 17 00:00:00 2001 From: Eric Avdey Date: Mon, 6 Oct 2025 16:16:56 -0300 Subject: [PATCH] fix: disable_ssl_verification impl for CouchDbSessionAuthenticator --- ibmcloudant/__init__.py | 4 ++- ibmcloudant/cloudant_base_service.py | 3 --- ...couchdb_session_get_authenticator_patch.py | 4 +-- test/unit/test_couchdb_session_auth.py | 27 ------------------- 4 files changed, 4 insertions(+), 34 deletions(-) diff --git a/ibmcloudant/__init__.py b/ibmcloudant/__init__.py index 1ce2afa9..3b83fbad 100644 --- a/ibmcloudant/__init__.py +++ b/ibmcloudant/__init__.py @@ -19,7 +19,7 @@ from ibm_cloud_sdk_core import IAMTokenManager, DetailedResponse, BaseService, ApiException, get_authenticator from .couchdb_session_authenticator import CouchDbSessionAuthenticator from .couchdb_session_get_authenticator_patch import new_construct_authenticator -from .cloudant_base_service import new_init, new_prepare_request, new_set_default_headers, new_set_http_client, new_set_service_url +from .cloudant_base_service import new_init, new_prepare_request, new_set_default_headers, new_set_http_client, new_set_service_url, new_set_disable_ssl_verification from .couchdb_session_token_manager import CouchDbSessionTokenManager from .cloudant_v1 import CloudantV1 from .features.changes_follower import ChangesFollower @@ -37,3 +37,5 @@ CloudantV1.prepare_request = new_prepare_request CloudantV1.set_http_client = new_set_http_client + +CloudantV1.set_disable_ssl_verification = new_set_disable_ssl_verification diff --git a/ibmcloudant/cloudant_base_service.py b/ibmcloudant/cloudant_base_service.py index f9922bc4..172e791f 100644 --- a/ibmcloudant/cloudant_base_service.py +++ b/ibmcloudant/cloudant_base_service.py @@ -114,9 +114,6 @@ def new_set_default_headers(self, headers: Dict[str, str]): _old_set_disable_ssl_verification = CloudantV1.set_disable_ssl_verification -# Note this is currently unused, but probably should be enabled. -# To enable it we need to resolve whether CouchDbSessionAuthenticator -# should ever be allowed to have a different value from the service client. def new_set_disable_ssl_verification(self, status: bool = False) -> None: _old_set_disable_ssl_verification(self, status) if isinstance(self.authenticator, CouchDbSessionAuthenticator): diff --git a/ibmcloudant/couchdb_session_get_authenticator_patch.py b/ibmcloudant/couchdb_session_get_authenticator_patch.py index f917fe1e..cd31ef97 100644 --- a/ibmcloudant/couchdb_session_get_authenticator_patch.py +++ b/ibmcloudant/couchdb_session_get_authenticator_patch.py @@ -34,8 +34,6 @@ def new_construct_authenticator(config): # pylint: disable=missing-docstring return CouchDbSessionAuthenticator( username=config.get('USERNAME'), password=config.get('PASSWORD'), - disable_ssl_verification=config.get( - 'AUTH_DISABLE_SSL', - config.get('DISABLE_SSL', 'false')).lower() == 'true' + disable_ssl_verification=config.get('DISABLE_SSL', 'false').lower() == 'true' ) return old_construct_authenticator(config) diff --git a/test/unit/test_couchdb_session_auth.py b/test/unit/test_couchdb_session_auth.py index 6738943b..9285d9d2 100644 --- a/test/unit/test_couchdb_session_auth.py +++ b/test/unit/test_couchdb_session_auth.py @@ -231,30 +231,3 @@ def test_disable_ssl(self): self.assertTrue(service.disable_ssl_verification) self.assertTrue( service.authenticator.token_manager.disable_ssl_verification) - - def test_auth_disable_ssl(self): - os.environ['TEST_SERVICE_AUTHTYPE'] = 'couchdb_session' - os.environ['TEST_SERVICE_USERNAME'] = 'adm' - os.environ['TEST_SERVICE_PASSWORD'] = 'pass' - os.environ['TEST_SERVICE_AUTH_DISABLE_SSL'] = 'true' - service = CloudantV1.new_instance(service_name='TEST_SERVICE') - self.assertIsNotNone(service) - self.assertIsInstance(service, CloudantV1) - self.assertEqual('COUCHDB_SESSION', service.authenticator.authentication_type()) - self.assertFalse(service.disable_ssl_verification) - self.assertTrue( - service.authenticator.token_manager.disable_ssl_verification) - - def test_auth_disable_ssl_only(self): - os.environ['TEST_SERVICE_AUTHTYPE'] = 'couchdb_session' - os.environ['TEST_SERVICE_USERNAME'] = 'adm' - os.environ['TEST_SERVICE_PASSWORD'] = 'pass' - os.environ['TEST_SERVICE_DISABLE_SSL'] = 'false' - os.environ['TEST_SERVICE_AUTH_DISABLE_SSL'] = 'true' - service = CloudantV1.new_instance(service_name='TEST_SERVICE') - self.assertIsNotNone(service) - self.assertIsInstance(service, CloudantV1) - self.assertEqual('COUCHDB_SESSION', service.authenticator.authentication_type()) - self.assertFalse(service.disable_ssl_verification) - self.assertTrue( - service.authenticator.token_manager.disable_ssl_verification)