Beispiel #1
0
def test_get_credentials_user_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.UserAuthenticationError(
    )
    with pytest.raises(exceptions.UserAuthenticationError):
        obj.get_credentials(args, profiles)
    obj.plugin_manager.hook.catch_user_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_user_authentication_error_message():
    err = exceptions.UserAuthenticationError('It did not work')
    assert str(err) == 'It did not work'
Beispiel #3
0
def test_user_authentication_error():
    err = exceptions.UserAuthenticationError()
    assert str(err) == 'Unable to get session token'