def test_post_add_arguments_role_arn_explicit(safe_print: MagicMock): config = {} arguments = argparse.Namespace( role_arn='arn:aws:iam::123123123123:role/myrole', auto_refresh=False, version=False, unset_variables=False, config=None, kill=False, profile_name=None, ) parser = argparse.ArgumentParser() default_plugins.post_add_arguments(config, arguments, parser)
def test_post_add_arguments_role_arn_no_auto_refresh(safe_print: MagicMock): config = {} arguments = argparse.Namespace( role_arn=True, auto_refresh=True, version=False, unset_variables=False, config=False, kill=False, profile_name=None, ) parser = argparse.ArgumentParser() with pytest.raises(SystemExit): default_plugins.post_add_arguments(config, arguments, parser)
def test_post_add_arguments_set_target_profile_name(safe_print: MagicMock): config = {} arguments = argparse.Namespace( role_arn=None, auto_refresh=False, version=False, unset_variables=False, config=None, kill=False, profile_name='profile', ) parser = argparse.ArgumentParser() default_plugins.post_add_arguments(config, arguments, parser) assert arguments.target_profile_name == 'profile'
def test_post_add_arguments_role_arn_short_bad_number_parts( safe_print: MagicMock, stdout: MagicMock, stderr: MagicMock): config = {} arguments = argparse.Namespace( role_arn='notanid:myrole:other', auto_refresh=False, version=False, unset_variables=False, config=None, kill=False, profile_name=None, ) parser = argparse.ArgumentParser() with pytest.raises(SystemExit): default_plugins.post_add_arguments(config, arguments, parser)
def test_post_add_arguments_kill(safe_print: MagicMock, kill: MagicMock, stdout: MagicMock, stderr: MagicMock): config = {} arguments = argparse.Namespace( role_arn=False, auto_refresh=False, version=False, unset_variables=False, config=None, kill=True, profile_name=None, ) parser = argparse.ArgumentParser() with pytest.raises(SystemExit): default_plugins.post_add_arguments(config, arguments, parser) kill.assert_called_with(arguments)
def test_post_add_arguments_config(safe_print: MagicMock, config_lib: MagicMock, stdout: MagicMock, stderr: MagicMock): config = {} arguments = argparse.Namespace( role_arn=False, auto_refresh=False, version=False, unset_variables=False, config=['clear', 'role-duration'], kill=False, profile_name=None, ) parser = argparse.ArgumentParser() with pytest.raises(SystemExit): default_plugins.post_add_arguments(config, arguments, parser) config_lib.update_config.assert_called_with(arguments.config)
def test_post_add_arguments_version(safe_print: MagicMock, stdout: MagicMock, stderr: MagicMock): config = {} arguments = argparse.Namespace( role_arn=False, auto_refresh=False, version=True, unset_variables=False, config=False, kill=False, profile_name=None, clean=False, output_profile=None, ) parser = argparse.ArgumentParser() with pytest.raises(exceptions.EarlyExit): default_plugins.post_add_arguments(config, arguments, parser)
def test_post_add_arguments_role_arn_short(safe_print: MagicMock): config = {} arguments = argparse.Namespace( role_arn='123123123123:myrole', auto_refresh=False, version=False, unset_variables=False, config=None, kill=False, profile_name=None, clean=False, output_profile=None, with_saml=False, principal_arn=None, ) parser = argparse.ArgumentParser() default_plugins.post_add_arguments(config, arguments, parser) assert arguments.role_arn == 'arn:aws:iam::123123123123:role/myrole'