Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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_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_set_target_profile_name_role_arn(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)
assert arguments.target_profile_name == 'arn:aws:iam::123123123123:role/myrole'
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_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_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_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_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,
)
parser = argparse.ArgumentParser()
with pytest.raises(SystemExit):
default_plugins.post_add_arguments(config, arguments, parser)
def test_post_add_arguments_unset_variables(safe_print: MagicMock, stdout: MagicMock, stderr: MagicMock):
config = {}
arguments = argparse.Namespace(
role_arn=False,
auto_refresh=False,
version=False,
unset_variables=True,
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_role_arn_short_bad_id(safe_print: MagicMock, stdout: MagicMock, stderr: MagicMock):
config = {}
arguments = argparse.Namespace(
role_arn='notanid:myrole',
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)