tests: migrate to tmt tests from Fedora upstream

Related: CVE-2022-32207
This commit is contained in:
Lukáš Zaoral 2022-08-10 14:39:48 +02:00
parent c72bd06c40
commit 83bad6fdd1
No known key found for this signature in database
GPG Key ID: 39157506DD67752D
12 changed files with 57 additions and 240 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

9
ci.fmf Normal file
View File

@ -0,0 +1,9 @@
discover:
how: fmf
prepare:
how: install
exclude:
- libcurl-minimal
- curl-minimal
execute:
how: tmt

View File

@ -1,63 +0,0 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/curl/Sanity/non-root-user-download
# Description: various download methods with non-root user
# Author: Karel Srot <ksrot@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/curl/Sanity/non-root-user-download
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.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: Karel Srot <ksrot@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: various download methods with non-root user" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: curl" >> $(METADATA)
@echo "Requires: curl" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -1,3 +0,0 @@
PURPOSE of /CoreOS/curl/Sanity/non-root-user-download
Description: various download methods with non-root user
Author: Karel Srot <ksrot@redhat.com>

View File

@ -0,0 +1,18 @@
summary: various download methods with non-root user
description: ''
contact: Daniel Rusek <drusek@redhat.com>
component:
- curl
require:
- findutils
- libselinux-utils
- openssh-clients
- openssh-server
- passwd
test: ./runtest.sh
framework: beakerlib
duration: 5m
enabled: true
tier: '1'
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1049921

15
tests/non-root-user-download/runtest.sh Normal file → Executable file
View File

@ -27,14 +27,13 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment # Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="curl" PACKAGE="curl"
FTP_URL=ftp://ftp.scientificlinux.org/linux/fedora/releases/18/Live/x86_64/Fedora-18-x86_64-Live-CHECKSUM FTP_URL=ftp://ftp.fi.muni.cz/pub/linux/fedora/linux/releases/36/Everything/x86_64/iso/Fedora-Everything-36-1.5-x86_64-CHECKSUM
HTTP_URL=https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/18/Live/x86_64/Fedora-18-x86_64-Live-CHECKSUM HTTP_URL=https://archives.fedoraproject.org/pub/fedora/linux/releases/36/Everything/x86_64/iso/Fedora-Everything-36-1.5-x86_64-CHECKSUM
CONTENT=a276e06d244e04b765f0a35532d9036ad84f340b0bdcc32e0233a8fbc31d5bed CONTENT=85cb450443d68d513b41e57b0bd818a740279dac5dfc09c68e681ff8a3006404
PASSWORD=pAssw0rd PASSWORD=pAssw0rd
OPTIONS="" OPTIONS=""
rlIsRHEL 7 && OPTIONS="--insecure" rlIsRHEL 7 && OPTIONS="--insecure"
@ -47,9 +46,11 @@ rlJournalStart
rlRun "useradd -m curltester" 0 "Adding the test user" rlRun "useradd -m curltester" 0 "Adding the test user"
rlRun "echo $PASSWORD | passwd --stdin curltester" 0 "Setting the password for the test user" rlRun "echo $PASSWORD | passwd --stdin curltester" 0 "Setting the password for the test user"
rlRun "su - curltester -c 'echo $CONTENT > ~/testfile'" 0 "Creating ~curltester/testfile" rlRun "su - curltester -c 'echo $CONTENT > ~/testfile'" 0 "Creating ~curltester/testfile"
rlFileBackup --clean --missing-ok $HOME/.ssh /etc/hosts
rlRun "rm -f $HOME/.ssh/*"
[ -d $HOME/.ssh ] || ( mkdir $HOME/.ssh && restorecon HOME/.ssh ) [ -d $HOME/.ssh ] || ( mkdir $HOME/.ssh && restorecon HOME/.ssh )
rlFileBackup $HOME/.ssh/known_hosts /etc/hosts rlRun "rlServiceStart sshd"
ssh-keygen -F localhost -f $HOME/.ssh/known_hosts || rlRun "ssh-keyscan localhost >> $HOME/.ssh/known_hosts" rlRun "ssh-keyscan localhost >> $HOME/.ssh/known_hosts"
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "http download" rlPhaseStartTest "http download"
@ -82,7 +83,7 @@ if ! rlIsRHEL 5; then
fi fi
rlPhaseStartCleanup rlPhaseStartCleanup
rlRun "rm -f $HOME/.ssh/known_hosts" rlRun "rlServiceRestore"
rlFileRestore rlFileRestore
rlRun "popd" rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory" rlRun "rm -r $TmpDir" 0 "Removing tmp directory"

View File

@ -1,64 +0,0 @@
- hosts: '{{ hosts | default("localhost") }}'
vars:
package: "curl"
tasks:
- name: "Set Content variables"
set_fact:
content: "a276e06d244e04b765f0a35532d9036ad84f340b0bdcc32e0233a8fbc31d5bed"
password: "pAssw0rd"
crypt_password: "$6$/5GE87XLYLLfB3qx$w84Kct34UZG/4buTSXWkaaVIsw2xGXSAdmnS2QYdG8TtRgTsBnHdFdSkhoy.tKIE6A6LKlxczIZjQbpB19k7B1"
- name: "Create user curltester"
user:
name: "curltester"
password: "{{ crypt_password }}"
- name: "Copy testfile"
copy:
dest: "/home/curltester/testfile"
content: "{{ content }}"
- block:
- name: "http download"
command: "curl https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/18/Live/x86_64/Fedora-18-x86_64-Live-CHECKSUM"
args:
warn: false
register: http
become: yes
become_user: curltester
- name: "Compare http output"
fail:
msg: "{{ content }} not in {{ http.stdout }}"
when: content not in http.stdout
- name: "ftp download"
command: "curl ftp://ftp.scientificlinux.org/linux/fedora/releases/18/Live/x86_64/Fedora-18-x86_64-Live-CHECKSUM"
args:
warn: false
register: ftp
become: yes
become_user: curltester
- name: "Compare ftp output"
fail:
msg: "{{ content }} not in {{ ftp.stdout }}"
when: content not in ftp.stdout
- name: "scp download"
command: "curl -u curltester:{{ password }} --insecure scp://localhost/home/curltester/testfile"
args:
warn: false
register: scp
- name: "Compare scp output"
fail:
msg: "{{ content }} not in {{ scp.stdout }}"
when: content not in scp.stdout
- name: "sftp download"
command: "curl -u curltester:{{ password }} --insecure sftp://localhost/home/curltester/testfile"
args:
warn: false
register: sftp
- name: "Compare sftp output"
fail:
msg: "{{ content }} not in {{ sftp.stdout }}"
when: content not in sftp.stdout
always:
- name: "Remove user curltester"
user:
name: "curltester"
remove: yes
state: absent

View File

@ -1,63 +0,0 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/curl/Sanity/scp-and-sftp-download-test
# Description: downloads test file through scp and sftp
# Author: Karel Srot <ksrot@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2012 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/curl/Sanity/scp-and-sftp-download-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.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: Karel Srot <ksrot@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: downloads test file through scp and sftp" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 10m" >> $(METADATA)
@echo "RunFor: curl" >> $(METADATA)
@echo "Requires: curl openssh" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -1,12 +0,0 @@
PURPOSE of /CoreOS/curl/Sanity/scp-and-sftp-download-test
Description: downloads test file through scp and sftp
Author: Karel Srot <ksrot@redhat.com>
Test scenario:
- scp download
- sftp download
- scp upload
- sftp upload
When PUBKEY_PARAM global variable is set to 'empty' or 'none', scenarios are executed
with empty --pubkey parameter (--pubkey "") or with the paramiter omitted

View File

@ -0,0 +1,20 @@
summary: downloads test file through scp and sftp
description: |
Test scenario:
- scp download
- sftp download
- scp upload
- sftp upload
When PUBKEY_PARAM global variable is set to 'empty' or 'none', scenarios are executed
with empty --pubkey parameter (--pubkey "") or with the paramiter omitted
contact: Daniel Rusek <drusek@redhat.com>
require:
- findutils
component:
- curl
test: ./runtest.sh
path: /tests/scp-and-sftp-download-test
framework: beakerlib
duration: 10m
enabled: true

3
tests/scp-and-sftp-download-test/runtest.sh Normal file → Executable file
View File

@ -27,8 +27,7 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment # Include Beaker environment
. /usr/bin/rhts-environment.sh . /usr/share/beakerlib/beakerlib.sh || exit 1
. /usr/lib/beakerlib/beakerlib.sh
PACKAGE="curl" PACKAGE="curl"

View File

@ -1,26 +0,0 @@
---
# Tests for Classic
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
tests:
- scp-and-sftp-download-test
- non-root-user-download
required_packages:
- findutils # non-root-user-download needs find command
# scp-and-sftp-download-test needs find command
- passwd # non-root-user-download needs passwd command
- openssh-clients # non-root-user-download needs ssh-keyscan command
# Tests for Atomic
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- atomic
tests:
- scp-and-sftp-download-test
- non-root-user-download