Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ibmcloudant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 0 additions & 3 deletions ibmcloudant/cloudant_base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 1 addition & 3 deletions ibmcloudant/couchdb_session_get_authenticator_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
27 changes: 0 additions & 27 deletions test/unit/test_couchdb_session_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)