예제 #1
0
def test_get_from_config_no_account_name():
    """Test get_from_config throws if no account name is given"""
    config_file = data_path + os.sep + 'complete.cfg'
    config = utils.get_config(config_file)

    with pytest.raises(EC2AccountException):
        utils.get_from_config(None, config, None, 'ssh_key_name',
                              '--ssh-key-pair')
예제 #2
0
def test_get_from_config_from_account():
    """Test get_from_config returns expected data form an account"""
    config_file = data_path + os.sep + 'complete.cfg'
    config = utils.get_config(config_file)
    expected = 'AAAAAAAAAAAAAA'
    access_key_id = utils.get_from_config('tester', config, None,
                                          'access_key_id', '--access-id')
    assert expected == access_key_id
예제 #3
0
def test_check_account_keys_no_cmd_keys():
    """Test check_account_keys with the keys available in the config file"""
    config_file = data_path + os.sep + 'complete.cfg'
    config = utils.get_config(config_file)
    command_args = Turncoat()
    command_args.accessKey = None
    command_args.secretKey = None
    command_args.accountName = 'tester'
    assert 1 == utils.check_account_keys(config, command_args)
예제 #4
0
def test_get_from_config_region_override():
    """Test get_from_config returns expected data if account setting
       is overridden ina a region"""
    config_file = data_path + os.sep + 'complete.cfg'
    config = utils.get_config(config_file)
    expected = 'east-region'
    ssh_key_name = utils.get_from_config('tester', config, 'us-east-1',
                                         'ssh_key_name', '--ssh-key-pair')
    assert expected == ssh_key_name
예제 #5
0
def test_check_account_keys_cmd_keys():
    """Test check_account_keys with the access and secret key on the
       command line."""
    config_file = data_path + os.sep + 'nokeys.cfg'
    config = utils.get_config(config_file)
    command_args = Turncoat()
    command_args.accessKey = 'AAAAAA'
    command_args.secretKey = 'BBBBBBB'
    command_args.accountName = 'tester'
    assert 1 == utils.check_account_keys(config, command_args)
예제 #6
0
def test_check_account_keys_no_keys():
    """Test check_account_keys with no keys available."""
    config_file = data_path + os.sep + 'nokeys.cfg'
    config = utils.get_config(config_file)
    command_args = Turncoat()
    command_args.accessKey = None
    command_args.secretKey = None
    command_args.accountName = 'tester'

    with pytest.raises(EC2AccountException):
        utils.check_account_keys(config, command_args)
예제 #7
0
def test_get_config_invalid():
    """Test get_config with an invalid configuration file"""
    config_file = data_path + os.sep + 'invalid.cfg'

    with pytest.raises(EC2ConfigFileParseException):
        utils.get_config(config_file)