diff --git a/apimatic_core/utilities/auth_helper.py b/apimatic_core/utilities/auth_helper.py index 2ee0dec..5a167b4 100644 --- a/apimatic_core/utilities/auth_helper.py +++ b/apimatic_core/utilities/auth_helper.py @@ -7,7 +7,7 @@ class AuthHelper: @staticmethod def get_base64_encoded_value(*props, delimiter=':'): - if props: + if props.__len__() > 0 and not any(prop is None for prop in props): joined = delimiter.join(props) encoded = base64.b64encode(str.encode(joined)).decode('iso-8859-1') return encoded diff --git a/setup.py b/setup.py index b637602..b1239e8 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='apimatic-core', - version='0.2.8', + version='0.2.9', description='A library that contains core logic and utilities for ' 'consuming REST APIs using Python SDKs generated by APIMatic.', long_description=long_description, diff --git a/tests/apimatic_core/utility_tests/test_auth_helper.py b/tests/apimatic_core/utility_tests/test_auth_helper.py index 2cf097b..7fea37c 100644 --- a/tests/apimatic_core/utility_tests/test_auth_helper.py +++ b/tests/apimatic_core/utility_tests/test_auth_helper.py @@ -8,6 +8,15 @@ def test_base64_encoded_none_value(self): expected_base64_encoded_value = None assert actual_base64_encoded_value == expected_base64_encoded_value + def test_base64_encoded_provided_none_values(self): + actual_base64_encoded_value = AuthHelper.get_base64_encoded_value(None, None) + expected_base64_encoded_value = None + assert actual_base64_encoded_value == expected_base64_encoded_value + + actual_base64_encoded_value = AuthHelper.get_base64_encoded_value('test_username', None) + expected_base64_encoded_value = None + assert actual_base64_encoded_value == expected_base64_encoded_value + def test_base64_encoded_value(self): actual_base64_encoded_value = AuthHelper.get_base64_encoded_value('test_username', 'test_password') expected_base64_encoded_value = 'dGVzdF91c2VybmFtZTp0ZXN0X3Bhc3N3b3Jk'