Esempio n. 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')
Esempio n. 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
Esempio n. 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)
Esempio n. 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
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)