Skip to content

Commit

Permalink
revert stubber and add session test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlm committed Sep 27, 2023
1 parent 5d2c21c commit 9acd697
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 1 addition & 3 deletions tests/functional/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,7 @@ def assert_session_credentials(self, expected_params, **kwargs):
expected_creds = self.create_random_credentials()
response = self.create_assume_role_response(expected_creds)
session = StubbedSession(**kwargs)
stubber = session.stub(
'sts', config=Config(signature_version=UNSIGNED)
)
stubber = session.stub('sts')
stubber.add_response(
'assume_role_with_web_identity', response, expected_params
)
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,20 @@ def test_cred_provider_called_when_partial_creds_provided(self):
aws_secret_access_key='foo',
)

@mock.patch('botocore.client.ClientCreator')
def test_account_id(self, client_creator):
self.session.create_client(
'sts',
'us-west-2',
aws_access_key_id='foo',
aws_secret_access_key='bar',
aws_session_token='baz',
aws_account_id='123456789012',
)
call_args = client_creator.return_value.create_client.call_args[1]
credentials = call_args['credentials']
self.assertEqual(credentials.account_id, '123456789012')

def test_cred_provider_not_called_on_unsigned_client(self):
cred_provider = mock.Mock()
self.session.register_component('credential_provider', cred_provider)
Expand Down

0 comments on commit 9acd697

Please sign in to comment.