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_equals(expected, access_key_id)
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' utils.check_account_keys(config, command_args)
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_equals(1, utils.check_account_keys(config, command_args))
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_equals(expected, ssh_key_name)
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_equals(1, utils.check_account_keys(config, command_args))
def test_get_from_config_invalid_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) ssh_key_name = utils.get_from_config( None, config, None, 'ssh_key_name', '--ssh-key-pair')
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_equals(expected, access_key_id)
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_equals(expected, ssh_key_name)
def test_get_from_config_invalid_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) ssh_key_name = utils.get_from_config(None, config, None, 'ssh_key_name', '--ssh-key-pair')
def test_get_config_invalid(): """Test get_config with an invalid configuration file""" config_file = data_path + os.sep + 'invalid.cfg' config = utils.get_config(config_file)