From fa530fb2236bab8e491f960996743dddd5442d77 Mon Sep 17 00:00:00 2001 From: Ondrej Mejzlik Date: Oct 12 2020 11:36:38 +0000 Subject: Adding sftp test to upstream --- diff --git a/Sanity/sftp/Makefile b/Sanity/sftp/Makefile new file mode 100644 index 0000000..55787ee --- /dev/null +++ b/Sanity/sftp/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/lftp/Sanity/sftp +# Description: Basic test for SFTP file transfer +# Author: Martin Frodl +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/lftp/Sanity/sftp +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE main.fmf + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Martin Frodl " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Basic test for SFTP file transfer" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: lftp" >> $(METADATA) + @echo "Requires: lftp" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 1305235" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5 -RHEL7 -RHEL-ALT-7" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/Sanity/sftp/PURPOSE b/Sanity/sftp/PURPOSE new file mode 100644 index 0000000..b628820 --- /dev/null +++ b/Sanity/sftp/PURPOSE @@ -0,0 +1,12 @@ +PURPOSE of /CoreOS/lftp/Sanity/sftp +Description: Basic test for SFTP file transfer +Author: Martin Frodl +Bug summary: lftp not following symlinks through sftp +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1305235 + +This is a test for basic SFTP file transfer with lftp's mirror command. It +verifies that lftp correctly downloads files and directories (recursively) and +that symbolic links are being dereferenced when requested (mirror -L option). + +For rhel7 check this https://bugzilla.redhat.com/show_bug.cgi?id=1653611 +Only if a customer requests this to be fixed, will the test be used. diff --git a/Sanity/sftp/main.fmf b/Sanity/sftp/main.fmf new file mode 100644 index 0000000..f3fedcd --- /dev/null +++ b/Sanity/sftp/main.fmf @@ -0,0 +1,34 @@ +summary: Basic test for SFTP file transfer +description: | + Bug summary: lftp not following symlinks through sftp + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1305235 + + This is a test for basic SFTP file transfer with lftp's mirror command. It + verifies that lftp correctly downloads files and directories (recursively) and + that symbolic links are being dereferenced when requested (mirror -L option). + + For rhel7 check this https://bugzilla.redhat.com/show_bug.cgi?id=1653611 + Only if a customer requests this to be fixed, will the test be used. +component: +- lftp +test: ./runtest.sh +framework: beakerlib +recommend: +- lftp +duration: 5m +enabled: true +tag: +- NoRHEL4 +- NoRHEL5 +- NoRHEL7 +- TIP_fedora_fail +- TIPfail_infra +- TIPfail_samba +- TIPfail_systemd +- TIPpass +- TIPpass_Apps +relevancy: | + distro = rhel-4, rhel-5, rhel-7, rhel-alt-7: False +extra-nitrate: TC#0530537 +extra-summary: /CoreOS/lftp/Sanity/sftp +extra-task: /CoreOS/lftp/Sanity/sftp diff --git a/Sanity/sftp/runtest.sh b/Sanity/sftp/runtest.sh new file mode 100755 index 0000000..2a0fe44 --- /dev/null +++ b/Sanity/sftp/runtest.sh @@ -0,0 +1,95 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/lftp/Sanity/sftp +# Description: Basic test for SFTP file transfer +# Author: Martin Frodl +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES="lftp" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm "$PACKAGES" + + rlRun "useradd lftp" 0 "Creating user lftp" + rlRun "passwd --stdin lftp <<< lftp" 0 "Setting password" + + rlRun "REMOTE=\$(mktemp -d)" 0 "Creating remote directory" + rlRun "touch ${REMOTE}/file1" 0 "Creating remote file" + rlRun "mkdir ${REMOTE}/dir" 0 "Creating remote subdirectory" + rlRun "touch ${REMOTE}/dir/file2" 0 "Creating another remote file" + rlRun "chmod -R 0755 ${REMOTE}" 0 "Allowing access to remote directory for user lftp" + + rlRun "LOCAL=\$(mktemp -d)" 0 "Creating local directory" + rlRun "pushd ${LOCAL}" + if ! rlIsRHEL '<8'; then + if ! test -e ~/.ssh/known_hosts; then + rlRun "mkdir -p ~/.ssh" 0 "Create ~/.ssh" + fi + rlRun "ssh-keyscan $(hostname) >> ~/.ssh/known_hosts" 0 "Add localhost to known_hosts" + fi + rlPhaseEnd + + rlPhaseStartTest "Mirroring files and directories" + rlRun "lftp -u lftp,lftp -e 'mirror ${REMOTE} ${LOCAL}; exit' sftp://${HOSTNAME}" \ + 0 "Mirroring ${REMOTE} to ${LOCAL}" + rlAssertExists "file1" + rlAssertExists "dir" + rlAssertExists "dir/file2" + rlRun "rm -rf *" 0 "Cleaning local directory" + rlPhaseEnd + + rlPhaseStartTest "Mirroring symlinks [BZ#1305235]" + rlRun "TARGET=\$(mktemp -d)" 0 "Creating another directory" + rlRun "touch ${TARGET}/file3" 0 "Creating file inside it" + rlRun "ln -s ${TARGET} ${REMOTE}/symlink1" 0 "Creating symlink to it" + rlRun "chmod -R 0755 ${TARGET}" 0 "Allowing access to remote directory for user lftp" + + rlRun "lftp -u lftp,lftp -e 'mirror -L ${REMOTE} ${LOCAL}; exit' sftp://${HOSTNAME}" \ + 0 "Mirroring ${REMOTE} to ${LOCAL} (follow symlinks)" + rlAssertExists "symlink1" + rlAssertExists "symlink1/file3" + rlRun "rm -rf *" 0 "Cleaning local directory" + rlPhaseEnd + + rlPhaseStartTest "Mirroring circular symlinks" + rlRun "ln -s ${REMOTE} ${TARGET}/symlink2" 0 "Creating symlink cycle" + rlRun "lftp -u lftp,lftp -e 'mirror -L ${REMOTE} ${LOCAL}; exit' sftp://${HOSTNAME}" \ + 0,41,1 "Mirroring ${REMOTE} to ${LOCAL} (follow symlinks)" + rlAssertExists "symlink1" + rlAssertExists "symlink1/file3" + rlAssertExists "symlink1/symlink2" + rlAssertExists "symlink1/symlink2/file1" + rlRun "rm -rf *" 0 "Cleaning local directory" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r ${REMOTE} ${LOCAL} ${TARGET}" 0 "Removing test directories" + rlRun "userdel -rf lftp" 0 "Deleting user lftp" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd