initial commit of tests from upstreamfirst

This commit is contained in:
Mike Gahagan 2017-10-20 14:03:57 -04:00
parent 3058c2d2f6
commit 9ac07e38c9
10 changed files with 548 additions and 0 deletions

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/passwd/Regression/changing-password-with-stdin-opiton-limits
# Description: Test for changing password with --stdin opiton limits
# Author: Eva Mrakova <emrakova@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 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/passwd/Regression/changing-password-with-stdin-opiton-limits
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: Eva Mrakova <emrakova@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for changing password with --stdin opiton limits" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: passwd" >> $(METADATA)
@echo "Requires: passwd" >> $(METADATA)
@echo "Requires: expect" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,6 @@
PURPOSE of /CoreOS/passwd/Regression/changing-password-with-stdin-opiton-limits
Description: Test for changing password with --stdin opiton limits 512 bytes long
Author: Eva Mrakova <emrakova@redhat.com>
Bug summary: changing password with --stdin opiton limits password size to 79 characters
Tests changing password 511 chars long

View File

@ -0,0 +1,94 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/passwd/Regression/changing-password-with-stdin-opiton-limits
# Description: Test for changing password with --stdin opiton limits
# Author: Eva Mrakova <emrakova@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 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/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="passwd"
TSTUSR="testuser"
# max length password: 512 chars (supported by pam_unix, PAM_MAX_RESP_SIZE)
# such long passwords do not work on RHEL6 for pam <= pam-1.1.1-20.el6
# similarly for RHEL7 and pam-1.1.8-12.el7
TSTPASSWD=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 511)
NEWPASSWD=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 511)
function change_passwd {
# $1 user, $2 user's password, $3 new user's password
expect <<EOF
spawn su -c passwd - $1
set timeout 3
expect "password:"
send "$2\r"
expect "password:"
send "$3\r"
expect "password:"
send "$3\r"
expect "successfully" { exit 0 }
exit 2
EOF
return $?
}
function set_passwd {
# $1 user, $2 passwd
expect <<EOF
spawn passwd $1
set timeout 3
expect "password:"
send "$2\r"
expect "password:"
send "$2\r"
expect "successfully" { exit 0 }
exit 2
EOF
return $?
}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "useradd $TSTUSR"
rlPhaseEnd
rlPhaseStartTest
rlRun "set_passwd $TSTUSR $TSTPASSWD" 0 "root: setting password interactively"
rlRun "change_passwd $TSTUSR $TSTPASSWD $NEWPASSWD" 0 "user: changing password"
rlRun "echo $TSTPASSWD | passwd --stdin $TSTUSR" 0 "root: resetting password via --stdin"
rlRun "change_passwd $TSTUSR $TSTPASSWD $NEWPASSWD" 0 "user: changing password"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "userdel -r $TSTUSR"
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/passwd/Regression/passwd-exit-status-1
# Description: Test for passwd exit status 1
# Author: Ondrej Moris <omoris@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 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/passwd/Regression/passwd-exit-status-1
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)
chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Ondrej Moris <omoris@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for passwd exit status 1" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: passwd" >> $(METADATA)
@echo "Requires: passwd" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,26 @@
PURPOSE of /CoreOS/passwd/Regression/passwd-exit-status-1
Description: Test for passwd exit status 1
Author: Ondrej Moris <omoris@redhat.com>
Bug summary: passwd exit status 1
Description:
Description of problem:
passwd exits with status 1 when argument -S is passed.
Version-Release number of selected component (if applicable):
5.X
How reproducible:
allways
Steps to Reproduce:
1. passwd -S user
2. echo $?
Actual results:
1
Expected results:
0

View File

@ -0,0 +1,55 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/passwd/Regression/passwd-exit-status-1
# Description: Test for passwd exit status 1
# Author: Ondrej Moris <omoris@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/share/beakerlib/beakerlib.sh
PACKAGE="passwd"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlPhaseEnd
rlPhaseStartTest
rlRun "passwd -S root" 0
rlRun "passwd -S nonExistingUser" 1-255
rlPhaseEnd
rlPhaseStartCleanup
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

65
tests/smoke-test/Makefile Normal file
View File

@ -0,0 +1,65 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/passwd/Sanity/smoke-test
# Description: Test basic functionality.
# Author: Ondrej Moris <omoris@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 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/passwd/Sanity/smoke-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)
chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Ondrej Moris <omoris@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic functionality." >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: passwd" >> $(METADATA)
@echo "Requires: passwd" >> $(METADATA)
@echo "Requires: openssh" >> $(METADATA)
@echo "Requires: expect" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

5
tests/smoke-test/PURPOSE Normal file
View File

@ -0,0 +1,5 @@
PURPOSE of /CoreOS/passwd/Sanity/smoke-test
Description: Test basic functionality.
Author: Ondrej Moris <omoris@redhat.com>
tests basic passwd command usage scenarios

141
tests/smoke-test/runtest.sh Normal file
View File

@ -0,0 +1,141 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/passwd/Sanity/smoke-test
# Description: Test basic functionality.
# Author: Ondrej Moris <omoris@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/share/beakerlib/beakerlib.sh
PACKAGE="passwd"
function set_password {
expect >/tmp/out 2>&1 <<EOF
spawn passwd $1
set timeout 3
expect "password:"
send "$2\r"
expect "password:"
send "$2\r"
expect "successfully" { exit 0 }
exit 2
EOF
ret=$?
cat /tmp/out
return $ret
}
function check_password {
expect >/tmp/out 2>&1 <<EOF
spawn ssh $1@`hostname` echo -n "XYZ" && whoami
set timeout 3
expect "(yes/no)" { send "yes\r" }
expect "password" {
send "$2\r"
expect "XYZ${1}" { exit 0 }
exit 2
}
exit 3
EOF
ret=$?
cat /tmp/out
return $ret
}
rlJournalStart
rlPhaseStartSetup
I=0
while true; do
getent passwd t${I} || break
I=$[$I+1]
done
U=t${I}
rlRun "useradd $U" 0 "Creating testing account"
rlPhaseEnd
rlPhaseStartTest
rlRun "set_password $U a" 0 "Setting initial password to 'a'"
sleep 3
rlRun "check_password $U a" 0 "Checking good password"
rlRun "check_password $U x" 1-255 "Checking wrong password"
rlRun "echo b | passwd --stdin $U" 0 "Changing password via stdin to 'b'"
sleep 3
rlRun "check_password $U b" 0 "Checking good password"
rlRun "check_password $U x" 1-255 "Checking wrong password"
rlRun "passwd -l $U" 0 "Locking account"
sleep 3
rlRun "check_password $U b" 1-255 "Checking good password"
rlRun "check_password $U x" 1-255 "Checking wrong password"
rlRun "passwd -u $U" 0 "Unlocking account"
sleep 3
rlRun "check_password $U b" 0 "Checking good password"
rlRun "check_password $U x" 1-255 "Checking wrong password"
rlRun "passwd -d $U" 0 "Disabling account"
sleep 3
rlRun "check_password $U b" 1-255 "Checking good password"
rlRun "check_password $U x" 1-255 "Checking wrong password"
rlRun "passwd -l $U" 0 "Locking account"
sleep 3
rlRun "check_password $U x" 1-255 "Checking wrong password"
rlRun "passwd -u $U > /tmp/out 2>&1" 1-255 "Unlocking account"
rlRun "grep \"Unsafe\" /tmp/out" 0 "Checking warning message"
rlRun "passwd -uf $U" 0 "Force Unlocking account"
sleep 3
rlRun "echo c | passwd --stdin $U" 0 "Changing password via stdin to 'c'"
sleep 3
rlRun "check_password $U c" 0 "Checking good password"
rlRun "check_password $U x" 1-255 "Checking wrong password"
rlRun "passwd -d $U" 0 "Disabling account"
sleep 3
rlRun "check_password $U c" 1-255 "Checking good password"
rlRun "check_password $U x" 1-255 "Checking wrong password"
rlRun "echo d | passwd --stdin $U" 0 "Changing password via stdin to 'd'"
sleep 3
rlRun "check_password $U d" 0 "Checking good password"
rlRun "check_password $U x" 1-255 "Checking wrong password"
rlRun "passwd -S $U" 0 "Checking good account information"
rlRun "passwd -S nonexistinguser" 1-255 "Checking wrong account information"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "userdel -r $U" 0 "Removing testing account"
rlRun "rm -f /tmp/out" 0 "Removing output file"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

30
tests/tests.yml Normal file
View File

@ -0,0 +1,30 @@
---
# Tests that run in classic context
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
tests:
- changing-password-with-stdin-opiton-limits
- passwd-exit-status-1
- smoke-test
required_packages:
- expect
- findutils # beakerlib needs find command
- openssh # smoke-test needs openssh
- passwd
# Tests that run in container context
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- container
tests:
- changing-password-with-stdin-opiton-limits
- passwd-exit-status-1
required_packages:
- expect
- findutils # beakerlib needs find command
- passwd