Skip to content

Commit 2c98a76

Browse files
committed
fix: disable_ssl_verification impl for CouchDbSessionAuthenticator
1 parent e7c6ae2 commit 2c98a76

File tree

4 files changed

+4
-34
lines changed

4 files changed

+4
-34
lines changed

ibmcloudant/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ibm_cloud_sdk_core import IAMTokenManager, DetailedResponse, BaseService, ApiException, get_authenticator
2020
from .couchdb_session_authenticator import CouchDbSessionAuthenticator
2121
from .couchdb_session_get_authenticator_patch import new_construct_authenticator
22-
from .cloudant_base_service import new_init, new_prepare_request, new_set_default_headers, new_set_http_client, new_set_service_url
22+
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
2323
from .couchdb_session_token_manager import CouchDbSessionTokenManager
2424
from .cloudant_v1 import CloudantV1
2525
from .features.changes_follower import ChangesFollower
@@ -37,3 +37,5 @@
3737
CloudantV1.prepare_request = new_prepare_request
3838

3939
CloudantV1.set_http_client = new_set_http_client
40+
41+
CloudantV1.set_disable_ssl_verification = new_set_disable_ssl_verification

ibmcloudant/cloudant_base_service.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ def new_set_default_headers(self, headers: Dict[str, str]):
114114

115115
_old_set_disable_ssl_verification = CloudantV1.set_disable_ssl_verification
116116

117-
# Note this is currently unused, but probably should be enabled.
118-
# To enable it we need to resolve whether CouchDbSessionAuthenticator
119-
# should ever be allowed to have a different value from the service client.
120117
def new_set_disable_ssl_verification(self, status: bool = False) -> None:
121118
_old_set_disable_ssl_verification(self, status)
122119
if isinstance(self.authenticator, CouchDbSessionAuthenticator):

ibmcloudant/couchdb_session_get_authenticator_patch.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ def new_construct_authenticator(config): # pylint: disable=missing-docstring
3434
return CouchDbSessionAuthenticator(
3535
username=config.get('USERNAME'),
3636
password=config.get('PASSWORD'),
37-
disable_ssl_verification=config.get(
38-
'AUTH_DISABLE_SSL',
39-
config.get('DISABLE_SSL', 'false')).lower() == 'true'
37+
disable_ssl_verification=config.get('DISABLE_SSL', 'false').lower() == 'true'
4038
)
4139
return old_construct_authenticator(config)

test/unit/test_couchdb_session_auth.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -231,30 +231,3 @@ def test_disable_ssl(self):
231231
self.assertTrue(service.disable_ssl_verification)
232232
self.assertTrue(
233233
service.authenticator.token_manager.disable_ssl_verification)
234-
235-
def test_auth_disable_ssl(self):
236-
os.environ['TEST_SERVICE_AUTHTYPE'] = 'couchdb_session'
237-
os.environ['TEST_SERVICE_USERNAME'] = 'adm'
238-
os.environ['TEST_SERVICE_PASSWORD'] = 'pass'
239-
os.environ['TEST_SERVICE_AUTH_DISABLE_SSL'] = 'true'
240-
service = CloudantV1.new_instance(service_name='TEST_SERVICE')
241-
self.assertIsNotNone(service)
242-
self.assertIsInstance(service, CloudantV1)
243-
self.assertEqual('COUCHDB_SESSION', service.authenticator.authentication_type())
244-
self.assertFalse(service.disable_ssl_verification)
245-
self.assertTrue(
246-
service.authenticator.token_manager.disable_ssl_verification)
247-
248-
def test_auth_disable_ssl_only(self):
249-
os.environ['TEST_SERVICE_AUTHTYPE'] = 'couchdb_session'
250-
os.environ['TEST_SERVICE_USERNAME'] = 'adm'
251-
os.environ['TEST_SERVICE_PASSWORD'] = 'pass'
252-
os.environ['TEST_SERVICE_DISABLE_SSL'] = 'false'
253-
os.environ['TEST_SERVICE_AUTH_DISABLE_SSL'] = 'true'
254-
service = CloudantV1.new_instance(service_name='TEST_SERVICE')
255-
self.assertIsNotNone(service)
256-
self.assertIsInstance(service, CloudantV1)
257-
self.assertEqual('COUCHDB_SESSION', service.authenticator.authentication_type())
258-
self.assertFalse(service.disable_ssl_verification)
259-
self.assertTrue(
260-
service.authenticator.token_manager.disable_ssl_verification)

0 commit comments

Comments
 (0)