Basic openssh-server installation including custom port set-up.
Signed-off-by: Karel Valek kvalek@redhat.com
From: Karel Valek kvalek@redhat.com
Basic openssh-server installation including custom port set-up.
Signed-off-by: Karel Valek kvalek@redhat.com --- tests/kickstart_tests/openssh_server.ks | 53 +++++++++++++++++++++++++++++++++ tests/kickstart_tests/openssh_server.sh | 39 ++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 tests/kickstart_tests/openssh_server.ks create mode 100755 tests/kickstart_tests/openssh_server.sh
diff --git a/tests/kickstart_tests/openssh_server.ks b/tests/kickstart_tests/openssh_server.ks new file mode 100644 index 0000000..320bb6b --- /dev/null +++ b/tests/kickstart_tests/openssh_server.ks @@ -0,0 +1,53 @@ +url --url="http://dl.fedoraproject.org/pub/fedora/linux/development/$releasever/$basear..." +install +network --bootproto=dhcp +# Set hostname for testing +network --hostname=testhostname.example.com + +bootloader --timeout=1 +zerombr +clearpart --all +autopart + +keyboard cz +lang cz +timezone Europe/Prague +rootpw qweqwe + +%packages +openssh-server +%end + +%post +NEWSSH="Port 22001" +SSHPACKAGE="openssh-server" + +## Check if the openssh-server package is installed. +RESULT=`dnf list installed | grep -Eo 'openssh-server'` + +if [[ "$RESULT" != "$SSHPACKAGE" ]]; then + echo "$SSHPACKAGE installation failed" >> /root/RESULT +fi + +## Perform sshd_config file check, if it exists.. +ls /etc/ssh/sshd_config +if [[ $? != 0 ]]; then + echo "SSHD_CONFIG file does not exist" >> /root/RESULT +fi + +## ...if so, perform appendation to the file... +if [[ "$RESULT" == "$SSHPACKAGE" ]]; then + echo "$NEWSSH" >> /etc/ssh/sshd_config +fi + +## ...and perform appended data check. +RESULTAPPEND=`cat /etc/ssh/sshd_config | grep Port` +if [[ $? != 0 ]]; then + echo "$NEWSSH check failed" >> /root/RESULT +fi + +## If nothing fails, append success statement. +if [[ ! -e /root/RESULT ]]; then + echo SUCCESS > /root/RESULT +fi +%end diff --git a/tests/kickstart_tests/openssh_server.sh b/tests/kickstart_tests/openssh_server.sh new file mode 100755 index 0000000..5aa73e5 --- /dev/null +++ b/tests/kickstart_tests/openssh_server.sh @@ -0,0 +1,39 @@ +# +# Copyright (C) 2015 Red Hat, Inc. +# +# 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 v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties 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. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Chris Lumens clumens@redhat.com + +. ${KSTESTDIR}/functions.sh + +validate() { + disksdir=$1 + args=$(for d in ${disksdir}/*img; do echo -a ${d}; done) + + # There should be a /root/RESULT file with results in it. Check + # its contents and decide whether the test finally succeeded or + # not. + result=$(virt-cat ${args} -m /dev/mapper/fedora_testhostname-root /root/RESULT) + if [[ $? != 0 ]]; then + status=1 + echo '*** /root/RESULT does not exist in VM image.' + elif [[ "${result}" != "SUCCESS" ]]; then + status=1 + echo "${result}" + fi + + return ${status} +}
Thank you for contributing a test case! We need a lot more of this.
I am wondering, however, what aspect of anaconda is being tested here. We already have a test case for individual packages (see packages-and-groups-1.ks). It looks to me like you are more testing that the ssh config can be modified in a %post, which anaconda isn't really involved in at all.
Closed.
I am sorry for this, this test's purpose was to confirm that I successfully understood the basics regarding to kickstart test.
I am sorry for this, this test's purpose was to confirm that I successfully understood the basics regarding to kickstart test.
Well, than it worked well! :)
anaconda-patches@lists.fedorahosted.org