def test_restore(copy_dir_mock, ensure_mock): dest = get_ssh_user_dir() ssh_files.restore() copy_dir_mock.assert_called_with(get_ssh_backup_dir(), dest, with_sudo=True) ensure_mock.assert_called_with(dest, get_user())
def backup(): source = get_ssh_user_dir() if not exists(source): log.info('No .ssh dir found... skipping.') return log.info('Backing up .ssh dir...') dest = get_ssh_backup_dir() ensure_exists(dest) copy_dir(source, dest)
def restore(): source = get_ssh_backup_dir() if not exists(source): log.info('No .ssh dir found... skipping.') return log.info('Restoring .ssh dir...') dest = get_ssh_user_dir() copy_dir(source, dest, with_sudo=True) ensure_dir_owned_by_user(dest, get_user())
def backup(): source = get_ssh_user_dir() if not exists(source): print 'No .ssh dir found... skipping.' return print 'Backing up .ssh dir...' dest = get_ssh_backup_dir() ensure_exists(dest) copy_dir(source, dest)
def test_get_ssh_user_dir(): assert config.get_ssh_user_dir() == path.join(config.get_home_dir(), '.ssh/')
def test_ensure_subdirs_listable(execute_shell_mock): ssh_dir = config.get_ssh_user_dir() utils.ensure_subdirs_listable(config.get_ssh_user_dir()) execute_shell_mock.assert_called_with( ['sudo', 'chmod', '-R', 'a+X', ssh_dir])
def test_change_mode(execute_shell_mock): ssh_dir = config.get_ssh_user_dir() utils.change_mode(ssh_dir, 600, True) execute_shell_mock.assert_called_with( ['sudo', 'chmod', '-R', '600', ssh_dir])
def test_change_owner(execute_shell_mock): ssh_dir = config.get_ssh_user_dir() utils.change_owner(ssh_dir, 'clint', True) execute_shell_mock.assert_called_with( ['sudo', 'chown', '-R', 'clint', ssh_dir])
def test_backup(copy_dir_mock): ssh_files.backup() copy_dir_mock.assert_called_with(get_ssh_user_dir(), get_ssh_backup_dir())