Beispiel #1
0
def test_get_credentials_role_authentication_error(__init__: MagicMock,
                                                   safe_print: MagicMock,
                                                   isatty: MagicMock,
                                                   get_role_chain: MagicMock):
    __init__.return_value = None
    args = argparse.Namespace(json=None,
                              with_saml=False,
                              with_web_identity=False,
                              auto_refresh=False,
                              target_profile_name='profilename')
    profiles = {}
    obj = app.Awsume()
    obj.config = {}
    obj.plugin_manager = MagicMock()
    isatty.return_value = True
    get_role_chain.return_value = ['profilename']

    obj.plugin_manager.hook.get_credentials.side_effect = exceptions.RoleAuthenticationError(
    )
    with pytest.raises(exceptions.RoleAuthenticationError):
        obj.get_credentials(args, profiles)
    obj.plugin_manager.hook.catch_role_authentication_error.assert_called_with(
        config=obj.config,
        arguments=args,
        error=obj.plugin_manager.hook.get_credentials.side_effect,
        profiles=profiles)
Beispiel #2
0
def test_role_authentication_error_message():
    err = exceptions.RoleAuthenticationError('It did not work')
    assert str(err) == 'It did not work'
Beispiel #3
0
def test_role_authentication_error():
    err = exceptions.RoleAuthenticationError()
    assert str(err) == 'Unable to assume role'