Skip to content

Commit

Permalink
formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlm committed Oct 10, 2023
1 parent a3bfd1a commit 91519c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 4 additions & 6 deletions botocore/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,9 +1084,8 @@ def _retrieve_credentials_using(self, credential_process):
return creds_dict

def _resolve_account_id(self, parsed_response):
return parsed_response.get('AccountId') or self.profile_config.get(
'aws_account_id'
)
account_id = parsed_response.get('AccountId')
return account_id or self.profile_config.get('aws_account_id')

@property
def _credential_process(self):
Expand All @@ -1096,9 +1095,8 @@ def _credential_process(self):
def profile_config(self):
if self._loaded_config is None:
self._loaded_config = self._load_config()
return self._loaded_config.get('profiles', {}).get(
self._profile_name, {}
)
profiles = self._loaded_config.get('profiles', {})
return profiles.get(self._profile_name, {})


class InstanceMetadataProvider(CredentialProvider):
Expand Down
7 changes: 4 additions & 3 deletions botocore/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,19 +587,20 @@ def _resolve_account_id_builtin(self, request_context, builtins):
request_context
)
acct_id_builtin_key = EndpointResolverBuiltins.AWS_ACCOUNT_ID
acct_id_builtin = builtins.get(acct_id_builtin_key)
if acct_id_ep_mode == 'disabled':
# Unset the account ID if endpoint mode is disabled.
builtins[acct_id_builtin_key] = None
elif acct_id_builtin is None:

elif builtins.get(acct_id_builtin_key) is None:
self._do_resolve_account_id_builtin(acct_id_ep_mode, builtins)

def _resolve_account_id_endpoint_mode(self, request_context):
"""Resolve the account ID endpoint mode for the request."""
not_presign = not request_context.get('is_presign_request', False)
should_sign = self._requested_auth_scheme != UNSIGNED
creds_available = self._credentials is not None
if all((not_presign, should_sign, creds_available)):

if not_presign and should_sign and creds_available:
ep_mode = request_context['client_config'].account_id_endpoint_mode
return self._validate_account_id_endpoint_mode(ep_mode)
return 'disabled'
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def test_no_cache(self):
refresher = credentials.AssumeRoleCredentialFetcher(
client_creator, self.source_creds, self.role_arn
)

expected_response = self.get_expected_creds_from_response(response)
response = refresher.fetch_credentials()

Expand Down

0 comments on commit 91519c5

Please sign in to comment.