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
2 changes: 2 additions & 0 deletions alibabacloud_credentials/provider/cli_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,7 @@ def _get_credentials_provider(self, config: Dict, profile_name: str) -> ICredent
else:
raise CredentialException(f"unsupported profile mode '{mode}' form cli credentials file.")

raise CredentialException(f"unable to get profile with '{profile_name}' form cli credentials file.")

def get_provider_name(self) -> str:
return 'cli_profile'
2 changes: 1 addition & 1 deletion alibabacloud_credentials/provider/uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _refresh_credentials(self) -> RefreshResult[Credentials]:
tea_request = ph.get_new_request()
tea_request.headers['host'] = r.hostname
tea_request.port = r.port
tea_request.protocol = self._protocol
tea_request.protocol = r.scheme or self._protocol or 'http'
tea_request.method = 'GET'
tea_request.pathname = r.path
for key, values in parse_qs(r.query).items():
Expand Down
12 changes: 12 additions & 0 deletions tests/provider/test_cli_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ def test_get_credentials_cli_profile_disabled(self):

self.assertIn("cli credentials file is disabled", str(context.exception))

def test_get_credentials_profile_name_not_exists(self):
"""
Test case 8: Profile file does not exist raises CredentialException
"""
with patch('alibabacloud_credentials.provider.cli_profile.au.environment_cli_profile_disabled', 'False'):
provider = CLIProfileCredentialsProvider(profile_name='not_exists')

with self.assertRaises(CredentialException) as context:
provider.get_credentials()

self.assertIn(f"unable to get profile with 'not_exists' form cli credentials file.", str(context.exception))

def test_get_credentials_profile_file_not_exists(self):
"""
Test case 8: Profile file does not exist raises CredentialException
Expand Down
Loading