Skip to content

Commit

Permalink
Fix integ test failure
Browse files Browse the repository at this point in the history
It's possible that a profile does not exist and therefore
the cred provider cannot be retrieved.  If this is the case
then we just shouldn't register the assume role provider.
  • Loading branch information
jamesls committed Nov 8, 2014
1 parent 8e79332 commit b854792
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions awscli/customizations/assumerole.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ def inject_assume_role_provider(session, event_name, **kwargs):
# before we start injecting things into the session.
return
provider = create_assume_role_provider(session)
session.get_component('credential_provider').insert_before(
'config-file', provider)
try:
session.get_component('credential_provider').insert_before(
'config-file', provider)
except Exception:
# This is ok, it just means that we couldn't create the credential
# provider object.
LOG.debug("Not registering assume-role provider, credential "
"provider from session could not be created.")


def create_assume_role_provider(session):
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/customizations/test_assumerole.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ def test_assume_role_provider_registration(self):
# be registered.
session.get_component.assert_called_with('credential_provider')

def test_provider_not_registered_on_error(self):
session = mock.Mock()
session.get_component.side_effect = Exception(
"Couldn't get credential_provider.")
assumerole.inject_assume_role_provider(
session, event_name='building-command-table.foo')
self.assertFalse(
session.get_component.return_value.insert_before.called)


class TestAssumeRoleCredentialProvider(unittest.TestCase):

Expand Down

0 comments on commit b854792

Please sign in to comment.