How to use the awsume.awsumepy.default_plugins.assume_role_from_cli function in awsume

To help you get started, we’ve selected a few awsume examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trek10inc / awsume / test / unit / awsume / awsumepy / test_default_plugins.py View on Github external
external_id=None,
        mfa_token='123123',
        force_refresh=False,
    )
    profiles = {
        'mysource': {
            'aws_access_key_id': 'AKIA...',
            'aws_secret_access_key': 'SECRET',
            'mfa_serial': 'mymfaserial',
        },
    }
    profile_lib.profile_to_credentials.return_value = {
        'AccessKeyId': 'AKIA...',
        'SecretAccessKey': 'SECRET',
    }
    default_plugins.assume_role_from_cli(config, arguments, profiles, 'us-east-1')
    aws_lib.get_session_token.assert_called_with(
        { 'AccessKeyId': 'AKIA...', 'SecretAccessKey': 'SECRET' },
        region=profile_lib.get_region.return_value,
        mfa_serial='mymfaserial',
        mfa_token='123123',
        ignore_cache=False,
    )
    aws_lib.assume_role.assert_called_with(
        aws_lib.get_session_token.return_value,
        arguments.role_arn,
        'awsume-cli-role',
        region='us-east-1',
        external_id=arguments.external_id,
        role_duration=0,
    )
github trek10inc / awsume / test / unit / awsume / awsumepy / test_default_plugins.py View on Github external
role_arn='myrolearn',
        external_id=None,
        mfa_token=None,
        force_refresh=False,
    )
    profiles = {
        'mysource': {
            'aws_access_key_id': 'AKIA...',
            'aws_secret_access_key': 'SECRET',
        },
    }
    profile_lib.profile_to_credentials.return_value = {
        'AccessKeyId': 'AKIA...',
        'SecretAccessKey': 'SECRET',
    }
    default_plugins.assume_role_from_cli(config, arguments, profiles, 'us-east-1')
    aws_lib.get_session_token.assert_not_called()
    aws_lib.assume_role.assert_called_with(
        profile_lib.profile_to_credentials.return_value,
        arguments.role_arn,
        'awsume-cli-role',
        region='us-east-1',
        external_id=arguments.external_id,
        role_duration=0,
    )
github trek10inc / awsume / test / unit / awsume / awsumepy / test_default_plugins.py View on Github external
session_name=None,
        source_profile='notfoundsource',
        role_arn='myrolearn',
        external_id=None,
        mfa_token='123123',
        force_refresh=False,
    )
    profiles = {
        'mysource': {
            'aws_access_key_id': 'AKIA...',
            'aws_secret_access_key': 'SECRET',
            'mfa_serial': 'mymfaserial',
        },
    }
    with pytest.raises(exceptions.ProfileNotFoundError):
        default_plugins.assume_role_from_cli(config, arguments, profiles, 'us-east-1')
github trek10inc / awsume / test / unit / awsume / awsumepy / test_default_plugins.py View on Github external
external_id=None,
        mfa_token='123123',
        force_refresh=False,
    )
    profiles = {
        'mysource': {
            'aws_access_key_id': 'AKIA...',
            'aws_secret_access_key': 'SECRET',
            'mfa_serial': 'mymfaserial',
        },
    }
    profile_lib.profile_to_credentials.return_value = {
        'AccessKeyId': 'AKIA...',
        'SecretAccessKey': 'SECRET',
    }
    default_plugins.assume_role_from_cli(config, arguments, profiles, 'us-east-1')
    aws_lib.get_session_token.assert_not_called()
    aws_lib.assume_role.assert_called_with(
        profile_lib.profile_to_credentials.return_value,
        arguments.role_arn,
        'awsume-cli-role',
        region='us-east-1',
        external_id=arguments.external_id,
        role_duration='43200',
        mfa_serial='mymfaserial',
        mfa_token='123123',
    )
github trek10inc / awsume / test / unit / awsume / awsumepy / test_default_plugins.py View on Github external
external_id=None,
        mfa_token='123123',
        force_refresh=False,
    )
    profiles = {
        'mysource': {
            'aws_access_key_id': 'AKIA...',
            'aws_secret_access_key': 'SECRET',
            'mfa_serial': 'mymfaserial',
        },
    }
    profile_lib.profile_to_credentials.return_value = {
        'AccessKeyId': 'AKIA...',
        'SecretAccessKey': 'SECRET',
    }
    default_plugins.assume_role_from_cli(config, arguments, profiles, 'us-east-1')
    aws_lib.get_session_token.assert_called_with(profile_lib.profile_to_credentials.return_value, region=profile_lib.get_region.return_value, mfa_serial='mymfaserial', mfa_token='123123', ignore_cache=False)
    aws_lib.assume_role.assert_called_with(
        aws_lib.get_session_token.return_value,
        arguments.role_arn,
        'awsume-cli-role',
        region='us-east-1',
        external_id=arguments.external_id,
        role_duration=0,
    )
github trek10inc / awsume / test / unit / awsume / awsumepy / test_default_plugins.py View on Github external
role_arn='myrolearn',
        external_id=None,
        mfa_token=None,
        force_refresh=False,
    )
    profiles = {
        'mysource': {
            'aws_access_key_id': 'AKIA...',
            'aws_secret_access_key': 'SECRET',
        },
    }
    profile_lib.profile_to_credentials.return_value = {
        'AccessKeyId': 'AKIA...',
        'SecretAccessKey': 'SECRET',
    }
    default_plugins.assume_role_from_cli(config, arguments, profiles, 'us-east-1')
    aws_lib.get_session_token.assert_not_called()
    aws_lib.assume_role.assert_called_with(
        profile_lib.profile_to_credentials.return_value,
        arguments.role_arn,
        'awsume-cli-role',
        region='us-east-1',
        external_id=arguments.external_id,
        role_duration='43200',
    )
github trek10inc / awsume / test / unit / awsume / awsumepy / test_default_plugins.py View on Github external
def test_assume_role_from_cli(aws_lib: MagicMock, profile_lib: MagicMock):
    config = {}
    arguments = argparse.Namespace(
        role_duration=None,
        session_name=None,
        source_profile=None,
        role_arn='myrolearn',
        external_id=None,
        mfa_token=None,
        force_refresh=False,
    )
    profiles = {}
    default_plugins.assume_role_from_cli(config, arguments, profiles, 'us-east-1')
    aws_lib.assume_role.assert_called_with(
        {}, arguments.role_arn, 'awsume-cli-role',
        region='us-east-1',
        external_id=arguments.external_id,
        role_duration=0,
    )