Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure bytes for ssl connection #6913

Merged
merged 2 commits into from
Jun 26, 2020
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: 2 additions & 2 deletions ibm_mq/datadog_checks/ibm_mq/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def get_ssl_connection(config):
Get the connection with SSL
"""
cd = _get_channel_definition(config)
cd.SSLCipherSpec = config.ssl_cipher_spec
cd.SSLCipherSpec = pymqi.ensure_bytes(config.ssl_cipher_spec)
florimondmanca marked this conversation as resolved.
Show resolved Hide resolved

sco = pymqi.SCO()
sco.KeyRepository = config.ssl_key_repository_location
sco.KeyRepository = pymqi.ensure_bytes(config.ssl_key_repository_location)

queue_manager = pymqi.QueueManager(None)
queue_manager.connect_with_options(config.queue_manager_name, cd, sco)
Expand Down
23 changes: 23 additions & 0 deletions ibm_mq/tests/test_ibm_mq_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,26 @@ def test_channel_queue_config_error(instance_config):
IBMMQConfig(instance_config)

assert 'channel, queue_manager are required configurations' in str(excinfo.value)


def test_ssl_connection_creation(instance):
"""
Test that we are not getting unicode/bytes type error.

TODO: We should test SSL in e2e
AlexandreYang marked this conversation as resolved.
Show resolved Hide resolved
"""
instance['ssl_auth'] = 'yes'
instance['ssl_cipher_spec'] = 'TLS_RSA_WITH_AES_256_CBC_SHA256'
instance['ssl_key_repository_location'] = '/dummy'

check = IbmMqCheck('ibm_mq', {}, [instance])

check.check(instance)

assert len(check.warnings) == 1
warning = check.warnings[0]

# Check that we are not getting a unicode/bytes type error but a MQRC_KEY_REPOSITORY_ERROR (dummy location)
assert 'bytes' not in warning
assert 'unicode' not in warning
assert 'MQRC_KEY_REPOSITORY_ERROR' in warning