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
11 changes: 9 additions & 2 deletions alibabacloud_credentials/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,15 @@ def parse_ini(self):
if file_path is None:
if not ac.HOME:
return
file_path = os.path.join(ac.HOME, ".alibabacloud/credentials.ini")
if len(file_path) == 0:
if os.path.exists(os.path.join(ac.HOME, "/.alibabacloud/credentials.ini")):
# Support '/.alibabacloud/credentials.ini' is due to historical mistakes.
# Please try to use '~/.alibabacloud/credentials.ini'.
file_path = os.path.join(ac.HOME, "/.alibabacloud/credentials.ini")
elif os.path.exists(os.path.join(ac.HOME, ".alibabacloud/credentials.ini")):
file_path = os.path.join(ac.HOME, ".alibabacloud/credentials.ini")
if file_path is None:
return
elif len(file_path) == 0:
raise CredentialException("The specified credentials file is empty")

# loads ini
Expand Down
3 changes: 2 additions & 1 deletion tests/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def test_OIDCRoleArnCredentialProvider(self):
access_key_id, access_key_secret, role_session_name, role_arn, oidc_provider_arn, oidc_token_file_path, region_id, policy = \
'access_key_id', 'access_key_secret', 'role_session_name', 'role_arn', 'oidc_provider_arn', 'tests/private_key.txt', 'region_id', 'policy'
prov = providers.OIDCRoleArnCredentialProvider(
access_key_id, access_key_secret, role_session_name, role_arn, oidc_provider_arn, oidc_token_file_path, region_id, policy
access_key_id, access_key_secret, role_session_name, role_arn, oidc_provider_arn, oidc_token_file_path,
region_id, policy
)
self.assertEqual('role_session_name', prov.role_session_name)
self.assertEqual('role_arn', prov.role_arn)
Expand Down