diff --git a/tests/p_anaconda/anaconda_centos_patch.sh b/tests/p_anaconda/anaconda_centos_patch.sh index b89e92f..aae402e 100755 --- a/tests/p_anaconda/anaconda_centos_patch.sh +++ b/tests/p_anaconda/anaconda_centos_patch.sh @@ -13,6 +13,9 @@ fi if [ "$centos_ver" = "7" ];then ANACONDA_PATH=/usr/lib64/python2.7/site-packages/pyanaconda/ ANACONDA_FILE="centos.py" +elif [ "$centos_ver" = "8" ];then + ANACONDA_PATH=/usr/lib64/python3.6/site-packages/pyanaconda/ + ANACONDA_FILE="centos.py" else ANACONDA_PATH=/usr/lib/anaconda/ ANACONDA_FILE="rhel.py" diff --git a/tests/p_autofs/0-install_autofs.sh b/tests/p_autofs/0-install_autofs.sh index 3ef8c7a..348649e 100755 --- a/tests/p_autofs/0-install_autofs.sh +++ b/tests/p_autofs/0-install_autofs.sh @@ -16,6 +16,9 @@ echo '/var/lib/ 127.0.0.1(ro)' >> /etc/exports if [ "$centos_ver" = "5" ] ; then t_ServiceControl portmap restart t_ServiceControl nfs restart +elif [ "$centos_ver" -ge 8 ] ; then + t_ServiceControl rpcbind restart + t_ServiceControl nfs-server restart else t_ServiceControl rpcbind restart t_ServiceControl nfs restart @@ -24,7 +27,7 @@ fi t_Log 'verify if NFS is mountable' mount -t nfs 127.0.0.1:/var/lib /mnt -ls -al /mnt | grep -q yum +ls -al /mnt | egrep -q '(dnf|yum)' t_CheckExitStatus $? umount /mnt diff --git a/tests/p_autofs/10-autofs-nfs-mount.sh b/tests/p_autofs/10-autofs-nfs-mount.sh index 440399d..939a37e 100755 --- a/tests/p_autofs/10-autofs-nfs-mount.sh +++ b/tests/p_autofs/10-autofs-nfs-mount.sh @@ -12,7 +12,7 @@ t_ServiceControl autofs restart t_Log 'Running test - accessing /var/lib via autofs' -ls -al /autofs/nfs | grep -q yum +ls -al /autofs/nfs | egrep -q '(dnf|yum)' t_CheckExitStatus $? # return everything to previous state @@ -21,4 +21,5 @@ rm -rf /etc/auto.autofs cat /dev/null > /etc/exports t_ServiceControl autofs stop t_ServiceControl nfs stop +t_ServiceControl nfs-server stop t_ServiceControl rpcbind stop diff --git a/tests/p_bridge-utils/00-install_bridge-utils.sh b/tests/p_bridge-utils/00-install_bridge-utils.sh index 69045ed..6ae9b1b 100755 --- a/tests/p_bridge-utils/00-install_bridge-utils.sh +++ b/tests/p_bridge-utils/00-install_bridge-utils.sh @@ -4,4 +4,8 @@ # Install bridge_utils package t_Log "Running $0 - bridge-utils: Installation" +if [ "$centos_ver" -ge 8 ] ; then +t_InstallPackage iproute +else t_InstallPackage bridge-utils +fi diff --git a/tests/p_bridge-utils/05-add_bridge.sh b/tests/p_bridge-utils/05-add_bridge.sh index e21c60b..21ec278 100755 --- a/tests/p_bridge-utils/05-add_bridge.sh +++ b/tests/p_bridge-utils/05-add_bridge.sh @@ -8,20 +8,11 @@ else bridge=$1 fi +. "$(dirname "$0")"/p_bridge-utils-functions + t_Log "Running $0 - Adding a dummy Bridge: $bridge" -bridge_present=`brctl show | grep $bridge` -if ! [ "$bridge_present" ] - then - brctl addbr $bridge - bridge_present=`brctl show | grep $bridge` - if [ "$bridge_present" ] - then - ret_val=0 - else - ret_val=1 - fi -else - ret_val=0 -fi +ret_val=$(bru_add_bridge $bridge) t_CheckExitStatus $ret_val +bru_del_bridge $bridge >/dev/null +exit $ret_val diff --git a/tests/p_bridge-utils/10-delete_bridge.sh b/tests/p_bridge-utils/10-delete_bridge.sh index 1472401..046db4a 100755 --- a/tests/p_bridge-utils/10-delete_bridge.sh +++ b/tests/p_bridge-utils/10-delete_bridge.sh @@ -1,24 +1,14 @@ #!/bin/bash # Author : Madhurranjan Mohaan + +. "$(dirname "$0")"/p_bridge-utils-functions #add bridge bridge=testbridge2 -./tests/p_bridge-utils/05-add_bridge.sh $bridge -#delete the bridge created -bridge_present=`brctl show | grep $bridge` +bru_add_bridge $bridge >/dev/null + t_Log "Running $0 - Deleting the dummy bridge: $bridge" -if ! [ "$bridge_present" ] - then - ret_val=1 -else - t_Log "Deleting bridge $bridge" - brctl delbr $bridge - bridge_present=`brctl show | grep $bridge` - if [ $bridge_present ] - then - ret_val=1 - else - ret_val=0 - fi -fi +t_Log "Deleting bridge $bridge" +ret_val=$(bru_del_bridge $bridge) + t_CheckExitStatus $ret_val diff --git a/tests/p_bridge-utils/p_bridge-utils-functions b/tests/p_bridge-utils/p_bridge-utils-functions new file mode 100644 index 0000000..9f66c02 --- /dev/null +++ b/tests/p_bridge-utils/p_bridge-utils-functions @@ -0,0 +1,96 @@ +#!/bin/bash + +function bru_add_bridge_7 +{ + bridge=$1 + bridge_present=`brctl show | grep $bridge` + if ! [ "$bridge_present" ] + then + brctl addbr $bridge + bridge_present=`brctl show | grep $bridge` + if [ "$bridge_present" ] + then + ret_val=0 + else + ret_val=1 + fi + else + ret_val=0 + fi + echo $ret_val +} +function bru_add_bridge_8 +{ + bridge=$1 + bridge_present=`cat /proc/net/dev | grep $bridge` + if ! [ "$bridge_present" ] + then + ip link add name $bridge type bridge + bridge_present=`cat /proc/net/dev | grep $bridge` + if [ "$bridge_present" ] + then + ret_val=0 + else + ret_val=1 + fi + else + ret_val=0 + fi + echo $ret_val +} + +function bru_del_bridge_7 +{ + bridge=$1 + bridge_present=`brctl show | grep $bridge` + if ! [ "$bridge_present" ] + then + ret_val=1 + else + brctl delbr $bridge + bridge_present=`brctl show | grep $bridge` + if [ $bridge_present ] + then + ret_val=1 + else + ret_val=0 + fi + fi +} +function bru_del_bridge_8 +{ + bridge=$1 + bridge_present=`cat /proc/net/dev | grep $bridge` + if ! [ "$bridge_present" ] + then + ret_val=1 + else + ip link del name $bridge + bridge_present=`cat /proc/net/dev | grep $bridge` + if [ $bridge_present ] + then + ret_val=1 + else + ret_val=0 + fi + fi + echo $ret_val +} + +function bru_add_bridge +{ + if [ "$centos_ver" -ge 8 ] ; then + bru_add_bridge_8 $1 + else + bru_add_bridge_7 $1 + fi +} + +function bru_del_bridge +{ + if [ "$centos_ver" -ge 8 ] ; then + bru_del_bridge_8 $1 + else + bru_del_bridge_7 $1 + fi +} diff --git a/tests/p_centos-release/centos-release_issue.sh b/tests/p_centos-release/centos-release_issue.sh index 02c2ce3..36d84b2 100755 --- a/tests/p_centos-release/centos-release_issue.sh +++ b/tests/p_centos-release/centos-release_issue.sh @@ -2,7 +2,7 @@ # Author: Athmane Madjoudj t_Log "Running $0 - /etc/issue* has correct branding" -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" -ge 7 ] ; then t_Log "CentOS $centos_ver -> SKIP" exit 0 else diff --git a/tests/p_centos-release/centos-release_os-release.sh b/tests/p_centos-release/centos-release_os-release.sh index 9cfb673..cd9d09b 100755 --- a/tests/p_centos-release/centos-release_os-release.sh +++ b/tests/p_centos-release/centos-release_os-release.sh @@ -1,10 +1,10 @@ #!/bin/bash # Author: Fabian Arrotin -t_Log "Running $0 - /etc/os-release has correct ABRT string for CentOS 7" +t_Log "Running $0 - /etc/os-release has correct ABRT string for CentOS $centos_ver" -if [ "$centos_ver" = "7" ];then - for string in CENTOS_MANTISBT_PROJECT=\"CentOS-7\" CENTOS_MANTISBT_PROJECT_VERSION=\"7\" REDHAT_SUPPORT_PRODUCT=\"centos\" REDHAT_SUPPORT_PRODUCT_VERSION=\"7\" +if [ "$centos_ver" -ge 7 ];then + for string in CENTOS_MANTISBT_PROJECT=\"CentOS-$centos_ver\" CENTOS_MANTISBT_PROJECT_VERSION=\"$centos_ver\" REDHAT_SUPPORT_PRODUCT=\"centos\" REDHAT_SUPPORT_PRODUCT_VERSION=\"$centos_ver\" do grep -q $string /etc/os-release if [ $? -ne "0" ];then diff --git a/tests/p_centos-release/centos-release_release_compat_symlinks.sh b/tests/p_centos-release/centos-release_release_compat_symlinks.sh index c8357af..b82b616 100755 --- a/tests/p_centos-release/centos-release_release_compat_symlinks.sh +++ b/tests/p_centos-release/centos-release_release_compat_symlinks.sh @@ -2,13 +2,11 @@ # Author: Athmane Madjoudj t_Log "Running $0 - /etc/centos-release compatibility symbolic links test." -if (t_GetPkgRel basesystem | grep -q el6) +if [ "$centos_ver" -ge 6 ] then - -grep "CentOS" /etc/centos-release >/dev/null 2>&1 -(file /etc/redhat-release | grep "symbolic link to .centos-release." >/dev/null 2>&1) &&\ -(file /etc/system-release | grep "symbolic link to .centos-release." >/dev/null 2>&1) - + grep "CentOS" /etc/centos-release >/dev/null 2>&1 + (file /etc/redhat-release | grep -E "symbolic link to .?centos-release.?" >/dev/null 2>&1) &&\ + (file /etc/system-release | grep -E "symbolic link to .?centos-release.?" >/dev/null 2>&1) else echo "This test is not comptatible with CentOS <= 5" fi diff --git a/tests/p_dovecot/1-config_dovecot.sh b/tests/p_dovecot/1-config_dovecot.sh index 70818bf..43b4b11 100755 --- a/tests/p_dovecot/1-config_dovecot.sh +++ b/tests/p_dovecot/1-config_dovecot.sh @@ -1,7 +1,7 @@ #!/bin/bash # Author: Athmane Madjoudj -if (t_GetPkgRel dovecot | egrep -q 'el6|7') +if (t_GetPkgRel dovecot | egrep -q 'el6|7|8') then t_Log "Running $0 - Configuration of Dovecot" diff --git a/tests/p_dovecot/dovecot_imap_login.sh b/tests/p_dovecot/dovecot_imap_login.sh index b486eca..949d34c 100755 --- a/tests/p_dovecot/dovecot_imap_login.sh +++ b/tests/p_dovecot/dovecot_imap_login.sh @@ -16,7 +16,7 @@ t_Log "Dovecot IMAP login test" # EL7 comes with nmap-nc , different from nc so different options to use -if [ "$centos_ver" = "7" ];then +if [ "$centos_ver" -ge 7 ];then nc_options="-d 3 -w 5" else nc_options="-i 3 -w 5" diff --git a/tests/p_dovecot/dovecot_pop3_login.sh b/tests/p_dovecot/dovecot_pop3_login.sh index a12056e..0ce53fc 100755 --- a/tests/p_dovecot/dovecot_pop3_login.sh +++ b/tests/p_dovecot/dovecot_pop3_login.sh @@ -13,7 +13,7 @@ chown -R pop3test:pop3test /home/pop3test/mail/.imap/INBOX t_Log "Dovecot POP3 login test" # EL7 comes with nmap-nc , different from nc so different options to use -if [ "$centos_ver" = "7" ];then +if [ "$centos_ver" -ge 7 ];then nc_options="-d 3 -w 5" else nc_options="-i 3 -w 5" diff --git a/tests/p_grub/grub_dir_layout_test.sh b/tests/p_grub/grub_dir_layout_test.sh index f968d8a..1b44d37 100755 --- a/tests/p_grub/grub_dir_layout_test.sh +++ b/tests/p_grub/grub_dir_layout_test.sh @@ -5,8 +5,8 @@ t_Log "Running $0 - check that grub file layout is the same with upstream." -if [ "$centos_ver" = "7" ] ; then - t_Log "el7 comes with grub2, skipping grub test ..." +if [ "$centos_ver" -ge 7 ] ; then + t_Log "el$centos_ver comes with grub2, skipping grub test ..." t_CheckExitStatus 0 exit 0 fi diff --git a/tests/p_grub2/01_grub2_secureboot_signed.sh b/tests/p_grub2/01_grub2_secureboot_signed.sh index a92f326..fc5bd8c 100755 --- a/tests/p_grub2/01_grub2_secureboot_signed.sh +++ b/tests/p_grub2/01_grub2_secureboot_signed.sh @@ -5,7 +5,11 @@ t_Log "Running $0 - Verifying that grub2-efi is correctly signed with correct c arch=$(uname -m) -if [[ "$centos_ver" = "7" && "$arch" = "x86_64" ]] ; then +if [[ "$centos_ver" -ge 7 && "$arch" = "x86_64" ]] ; then + if [ ! -f /boot/efi/EFI/centos/grubx64.efi ];then + t_Log "grub2-efi not installed, can't test... skipping" + exit 0 + fi t_InstallPackage pesign grub2-efi pesign --show-signature --in /boot/efi/EFI/centos/grubx64.efi|egrep -q 'Red Hat Inc.|CentOS Secure Boot \(key 1\)' t_CheckExitStatus $? diff --git a/tests/p_httpd/httpd_centos_brand_server_tokens.sh b/tests/p_httpd/httpd_centos_brand_server_tokens.sh index 14cf3f8..e81f35b 100755 --- a/tests/p_httpd/httpd_centos_brand_server_tokens.sh +++ b/tests/p_httpd/httpd_centos_brand_server_tokens.sh @@ -3,6 +3,6 @@ t_Log "Running $0 - httpd: centos branding / Server tokens value " -curl -sI http://localhost/ | grep "Server:\ Apache.*\ (CentOS)" > /dev/null 2>&1 +curl -sI http://localhost/ | grep -i "Server:\ Apache.*\ (CentOS)" > /dev/null 2>&1 t_CheckExitStatus $? diff --git a/tests/p_iptraf/5-test_iptraf.sh b/tests/p_iptraf/5-test_iptraf.sh index 40b0acd..8697c4f 100755 --- a/tests/p_iptraf/5-test_iptraf.sh +++ b/tests/p_iptraf/5-test_iptraf.sh @@ -11,7 +11,7 @@ trap "[ -e ${TMP} ] && { /bin/rm ${TMP}; }" EXIT # iptraf only be run by root [ ${EUID} -eq 0 ] || { t_Log "Not running as root, skipping this test. Non-fatal."; exit $PASS; } -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" -ge 7 ] ; then IPTRAF=`which iptraf-ng` else IPTRAF=`which iptraf` diff --git a/tests/p_jwhois/0-install_jwhois.sh b/tests/p_jwhois/0-install_jwhois.sh index f9f9ad1..5f5b3fa 100755 --- a/tests/p_jwhois/0-install_jwhois.sh +++ b/tests/p_jwhois/0-install_jwhois.sh @@ -3,7 +3,11 @@ # nc (netcat) is required for the test -if [ "$centos_ver" = "7" ] ;then +if [ "$centos_ver" -ge 8 ] ;then + t_Log "No whois package for CentOS $centos_ver -> SKIP" + t_CheckExitStatus 0 + exit 0 +elif [ "$centos_ver" = "7" ] ;then whois_pkg="whois" else whois_pkg="jwhois" diff --git a/tests/p_jwhois/jwhois_test.sh b/tests/p_jwhois/jwhois_test.sh index 0afac83..097328e 100755 --- a/tests/p_jwhois/jwhois_test.sh +++ b/tests/p_jwhois/jwhois_test.sh @@ -1,6 +1,9 @@ #!/bin/sh # Author: Athmane Madjoudj +if [ "$centos_ver" -ge 8 ] ;then + exit 0 +fi t_Log "Running $0 - check that jwhois can connect to whois server and get the info." # Dummy whois server diff --git a/tests/p_kernel/01_kernel_centos_keyring.sh b/tests/p_kernel/01_kernel_centos_keyring.sh index eeb33c5..6797457 100755 --- a/tests/p_kernel/01_kernel_centos_keyring.sh +++ b/tests/p_kernel/01_kernel_centos_keyring.sh @@ -11,11 +11,16 @@ if [ "$uname_arch" == "aarch64" ] || [ "$uname_arch" == "armv7l" ] || [ "$uname_ exit 0 fi -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" -ge 7 ] ; then + if [ "$centos_ver" -eq 7 ];then + ring=.system_keyring + else + ring=.builtin_trusted_keys + fi for id in kpatch "Driver update" kernel do t_Log "Verifying x.509 CentOS ${id}" - keyctl list %:.system_keyring | grep -i "CentOS Linux ${id} signing key" > /dev/null 2>&1 + keyctl list %:$ring | grep -i "CentOS Linux ${id} signing key" > /dev/null 2>&1 t_CheckExitStatus $? done else diff --git a/tests/p_kernel/02_kernel_secureboot_signed.sh b/tests/p_kernel/02_kernel_secureboot_signed.sh index 3a4df63..404d06d 100755 --- a/tests/p_kernel/02_kernel_secureboot_signed.sh +++ b/tests/p_kernel/02_kernel_secureboot_signed.sh @@ -3,7 +3,7 @@ t_Log "Running $0 - Verifying that kernel is correctly signed with correct cert" -if [[ "$centos_ver" = "7" && "$arch" = "x86_64" ]] ; then +if [[ "$centos_ver" -ge 7 && "$arch" = "x86_64" ]] ; then t_InstallPackage pesign for kernel in $(rpm -q kernel --queryformat '%{version}-%{release}.%{arch}\n') do diff --git a/tests/p_lftp/20_lftp_ftp.sh b/tests/p_lftp/20_lftp_ftp.sh index b0104c1..0fe0186 100755 --- a/tests/p_lftp/20_lftp_ftp.sh +++ b/tests/p_lftp/20_lftp_ftp.sh @@ -6,8 +6,15 @@ # Christoph Galuschka t_Log "Running $0 - installing vsFTPd for local lftp test." -t_InstallPackage vsftpd +t_InstallPackage vsftpd +if [ "$centos_ver" -ge 8 ] ; then +cp -fp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.tf_p_lftp +sed -i 's/anonymous_enable=NO/anonymous_enable=YES/g' /etc/vsftpd/vsftpd.conf +fi t_ServiceControl vsftpd restart +if [ "$centos_ver" -ge 8 ] ; then +mv -f /etc/vsftpd/vsftpd.conf.tf_p_lftp /etc/vsftpd/vsftpd.conf +fi # Destination File TESTFILE=/tmp/t_functional-lftp-test.txt diff --git a/tests/p_libxml2-python/0-install-libxml2-python.sh b/tests/p_libxml2-python/0-install-libxml2-python.sh index 6e2b2a2..edf9dec 100755 --- a/tests/p_libxml2-python/0-install-libxml2-python.sh +++ b/tests/p_libxml2-python/0-install-libxml2-python.sh @@ -4,4 +4,8 @@ # Install libxml2-python t_Log "Running $0 - installing libxml2-python." +if [ "$centos_ver" -ge 8 ] ; then +t_InstallPackage python3-libxml2 +else t_InstallPackage libxml2-python +fi diff --git a/tests/p_libxml2-python/1-test-XmlTextReader.sh b/tests/p_libxml2-python/1-test-XmlTextReader.sh index f873255..d040b17 100755 --- a/tests/p_libxml2-python/1-test-XmlTextReader.sh +++ b/tests/p_libxml2-python/1-test-XmlTextReader.sh @@ -4,13 +4,22 @@ t_Log "Running $0 - test XmlTextReader of libxml2-python" -cat << 'EOF' | python - | grep -q 'test succeeded' +if [ "$centos_ver" -ge 8 ] ; then +PYTHON=python3 +else +PYTHON=python +fi + +cat << 'EOF' | $PYTHON - | grep -q 'test succeeded' import libxml2 import sys -import StringIO +try: + from StringIO import StringIO +except ImportError: + from io import StringIO # Load a small xml structure -xmlStr = StringIO.StringIO(""" +xmlStr = StringIO(""" val1val2""") xmlBuf = libxml2.inputBuffer(xmlStr) xmlReader = xmlBuf.newTextReader("reader") @@ -45,5 +54,5 @@ checkRead(xmlReader, "key2", 0, 15, 0) checkRead(xmlReader, "key3", 1, 1, 0) checkRead(xmlReader, "test", 0, 15, 1) checkRead(xmlReader, "tests", 0, 15, 0) -print "test succeeded" +print ("test succeeded") EOF diff --git a/tests/p_logwatch/logwatch_test.sh b/tests/p_logwatch/logwatch_test.sh index fe25128..333887a 100755 --- a/tests/p_logwatch/logwatch_test.sh +++ b/tests/p_logwatch/logwatch_test.sh @@ -3,7 +3,7 @@ t_Log "Running $0 - logwatch test." -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" -ge 7 ] ; then lw_options="--range Today" else lw_options="--range Today --print" diff --git a/tests/p_mod_wsgi/mod_wsgi_test.sh b/tests/p_mod_wsgi/mod_wsgi_test.sh index 88857a3..7dc7587 100755 --- a/tests/p_mod_wsgi/mod_wsgi_test.sh +++ b/tests/p_mod_wsgi/mod_wsgi_test.sh @@ -13,11 +13,16 @@ then WSGIScriptAlias /tfapp /var/www/html/tf_app.wsgi EOF + +if [ $centos_ver -ge 8 ] +then +outputformat=b +fi cat > /var/www/html/tf_app.wsgi < # Ref.: http://bugs.centos.org/view.php?id=4943 +if [ "$centos_ver" -ge 8 ] ; then + exit 0 +fi t_Log "Running $0 - NTP is using CentOS server pool test." grep ".centos.pool.ntp.org" /etc/ntp.conf > /dev/null 2>&1 diff --git a/tests/p_openssh/sshd_user_login-with-key.sh b/tests/p_openssh/sshd_user_login-with-key.sh index b07a680..d3e7887 100755 --- a/tests/p_openssh/sshd_user_login-with-key.sh +++ b/tests/p_openssh/sshd_user_login-with-key.sh @@ -1,6 +1,11 @@ #!/bin/sh -for KeyType in rsa dsa; do +keytypes="rsa" +if [ "$centos_ver" -lt 8 ] ; then +keytypes="$keytypes dsa" +fi + +for KeyType in $keytypes; do userdel -rf sshtest; useradd sshtest && echo sshtest | passwd --stdin sshtest runuser -l sshtest -c "echo | ssh-keygen -q -t ${KeyType} -b 1024 -f ~/.ssh/id_${KeyType}" > /dev/null runuser -l sshtest -c "cat ~/.ssh/*pub > ~/.ssh/authorized_keys && chmod 600 ~/.ssh/*keys" > /dev/null diff --git a/tests/p_passwd/_password_complexity.expect b/tests/p_passwd/_password_complexity.expect index d0babe4..abd65ad 100755 --- a/tests/p_passwd/_password_complexity.expect +++ b/tests/p_passwd/_password_complexity.expect @@ -7,7 +7,7 @@ set timeout 10 match_max 6000 spawn su passtest -c passwd -expect "UNIX password:" { send -- "passtest\r" } +expect -re "(UNIX|Current) password:" { send -- "passtest\r" } expect { "password:" { send "$testpassword\r" diff --git a/tests/p_passwd/_user_password.expect b/tests/p_passwd/_user_password.expect index 04a78c2..4629858 100755 --- a/tests/p_passwd/_user_password.expect +++ b/tests/p_passwd/_user_password.expect @@ -1,10 +1,10 @@ -#!/usr/bin/expect -f +#!/usr/bin/expect -d # Author: Iain Douglas set timeout 10 match_max 6000 spawn su passtest -c passwd -expect "UNIX password:" { send -- "passtest\r" } +expect -re "(UNIX|Current) password:" { send -- "passtest\r" } expect { "You must wait longer to change your password" { diff --git a/tests/p_php/20-php-mysql-test.sh b/tests/p_php/20-php-mysql-test.sh index db9544d..5417f1d 100755 --- a/tests/p_php/20-php-mysql-test.sh +++ b/tests/p_php/20-php-mysql-test.sh @@ -41,15 +41,15 @@ INSERT='/var/tmp/test.php' cat >$INSERT < EOF @@ -64,15 +64,15 @@ fi READ='/var/tmp/read.php' cat >$READ < EOF diff --git a/tests/p_postgresql/1-config-postgresql.sh b/tests/p_postgresql/1-config-postgresql.sh index 6f51a5c..8058422 100755 --- a/tests/p_postgresql/1-config-postgresql.sh +++ b/tests/p_postgresql/1-config-postgresql.sh @@ -4,12 +4,13 @@ t_Log "Running $0 - initializing and starting PostgreSQL" t_Log "Initialize PostgreSQL DB " -if (t_GetPkgRel postgresql | grep -q el7) then +if (t_GetPkgRel postgresql | grep -q el8) then + postgresql-setup --initdb +elif (t_GetPkgRel postgresql | grep -q el7) then postgresql-setup initdb -else if (t_GetPkgRel postgresql | grep -q el6) then +elif (t_GetPkgRel postgresql | grep -q el6) then service postgresql initdb fi -fi t_ServiceControl postgresql start sleep 15 diff --git a/tests/p_postgresql/postgresql_create_user_test.sh b/tests/p_postgresql/postgresql_create_user_test.sh index b1c47da..3af7278 100755 --- a/tests/p_postgresql/postgresql_create_user_test.sh +++ b/tests/p_postgresql/postgresql_create_user_test.sh @@ -3,7 +3,7 @@ t_Log "Running $0 - PostgreSQL create user test" -su - postgres -c 'createuser -S -R -D pg_test_user' > /dev/null 2>&1 +su - postgres -c 'createuser -S -R -D test_user' > /dev/null 2>&1 t_CheckExitStatus $? diff --git a/tests/p_postgresql/postgresql_drop_user_test.sh b/tests/p_postgresql/postgresql_drop_user_test.sh index 0028c43..a0debe3 100755 --- a/tests/p_postgresql/postgresql_drop_user_test.sh +++ b/tests/p_postgresql/postgresql_drop_user_test.sh @@ -3,6 +3,6 @@ t_Log "Running $0 - PostgreSQL drop user test" -su - postgres -c 'dropuser pg_test_user' > /dev/null 2>&1 +su - postgres -c 'dropuser test_user' > /dev/null 2>&1 t_CheckExitStatus $? diff --git a/tests/p_python-iniparse/0-install-python-iniparse.sh b/tests/p_python-iniparse/0-install-python-iniparse.sh index 98f61ca..789b391 100755 --- a/tests/p_python-iniparse/0-install-python-iniparse.sh +++ b/tests/p_python-iniparse/0-install-python-iniparse.sh @@ -4,4 +4,8 @@ # Install python-iniparse: required by yum so a quite important package in CentOS t_Log "Running $0 - installing python-iniparse." +if [ "$centos_ver" -ge 8 ] ; then +t_InstallPackage python3-iniparse +else t_InstallPackage python-iniparse +fi diff --git a/tests/p_python-iniparse/1-test-python-iniparse.sh b/tests/p_python-iniparse/1-test-python-iniparse.sh index 73887cd..848117d 100755 --- a/tests/p_python-iniparse/1-test-python-iniparse.sh +++ b/tests/p_python-iniparse/1-test-python-iniparse.sh @@ -3,6 +3,12 @@ t_Log "Running $0 - test python-iniparse" +if [ "$centos_ver" -ge 8 ] ; then +PYTHON=python3 +else +PYTHON=python +fi + TESTINI=`mktemp` # Test contents: a part of /etc/yum.conf @@ -14,12 +20,12 @@ debuglevel=2 logfile=/var/log/yum.log EOF -cat << EOF | python - $TESTINI | grep -q '/var/log/yum.log' +cat << EOF | $PYTHON - $TESTINI | grep -q '/var/log/yum.log' import sys from iniparse import INIConfig cfg = INIConfig(open(sys.argv[1])) -print cfg.main.logfile +print (cfg.main.logfile) EOF t_CheckExitStatus $? @@ -36,12 +42,12 @@ section3var1=val2 section3var2=val3 EOF -cat << EOF | python - $TESTINI | grep -q "\['section1', 'section2', 'section3'\] val1 val2 val3" +cat << EOF | $PYTHON - $TESTINI | grep -q "\['section1', 'section2', 'section3'\] val1 val2 val3" import sys from iniparse import INIConfig cfg = INIConfig(open(sys.argv[1])) -print str(list(cfg)) + ' ' + cfg.section1.section1var1 + ' ' + cfg.section3.section3var1 + ' ' + cfg.section3.section3var2 +print (str(list(cfg)) + ' ' + cfg.section1.section1var1 + ' ' + cfg.section3.section3var1 + ' ' + cfg.section3.section3var2) EOF t_CheckExitStatus $? diff --git a/tests/p_python/0-install-python.sh b/tests/p_python/0-install-python.sh index d102bb6..3ba2adc 100755 --- a/tests/p_python/0-install-python.sh +++ b/tests/p_python/0-install-python.sh @@ -4,4 +4,8 @@ # Install python t_Log "Running $0 - installing python." +if [ "$centos_ver" -ge 8 ] ; then +t_InstallPackage python36 +else t_InstallPackage python +fi diff --git a/tests/p_python/10-test_python.sh b/tests/p_python/10-test_python.sh index 52f27ef..57fec65 100755 --- a/tests/p_python/10-test_python.sh +++ b/tests/p_python/10-test_python.sh @@ -4,15 +4,21 @@ t_Log "Running $0 - python can print Hello World" +if [ "$centos_ver" -ge 8 ] ; then +PYTHON=python3 +else +PYTHON=python +fi + # creating source file FILE='/var/tmp/python-test.py' cat > $FILE </dev/null 2>&1 # Installing additional python/mysql module +if [ "$centos_ver" -ge 8 ] ; then +t_InstallPackage python3-PyMySQL +importcomponent="pymysql" +else t_InstallPackage MySQL-python +importcomponent="MySQLdb" +fi # create python Scrip SCRIPT='/var/tmp/test.py' cat >$SCRIPT < t_Log "Running $0 - attempting to install ruby, ruby-irb, ruby-ri and ruby-rdoc4" +if [ "$centos_ver" -ge 8 ] ; then +t_InstallPackage ruby ruby-irb rubygem-rdoc +else t_InstallPackage ruby ruby-irb ruby-ri ruby-rdoc +fi diff --git a/tests/p_ruby/20-ruby-version-test.sh b/tests/p_ruby/20-ruby-version-test.sh index 7ff529f..961e17a 100755 --- a/tests/p_ruby/20-ruby-version-test.sh +++ b/tests/p_ruby/20-ruby-version-test.sh @@ -7,7 +7,10 @@ t_Log "Running $0 - Check version of ruby." -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" = "8" ] ; then + ruby -v | grep -q '2.5' + ret_val=$? +elif [ "$centos_ver" = "7" ] ; then ruby -v | grep -q '2.0' ret_val=$? elif [ "$centos_ver" = "6" ] ; then diff --git a/tests/p_ruby/30-irb-version-test.sh b/tests/p_ruby/30-irb-version-test.sh index ac7a88e..853e73f 100755 --- a/tests/p_ruby/30-irb-version-test.sh +++ b/tests/p_ruby/30-irb-version-test.sh @@ -8,7 +8,7 @@ t_Log "Running $0 - Check version of irb." #allready prepared just in case versions should change between C5 and C6 -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" = "7" -o "$centos_ver" = "8" ] ; then irb -v | grep -q '0.9.6' ret_val=$? else diff --git a/tests/p_ruby/40-ri-version-test.sh b/tests/p_ruby/40-ri-version-test.sh index 75acf70..4378892 100755 --- a/tests/p_ruby/40-ri-version-test.sh +++ b/tests/p_ruby/40-ri-version-test.sh @@ -8,7 +8,10 @@ t_Log "Running $0 - Check version of ruby ri." #allready prepared just in case versions should change between C5 and C6 -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" = "8" ] ; then + ri -v | grep -q '6.0' + ret_val=$? +elif [ "$centos_ver" = "7" ] ; then ri -v | grep -q '4.0' ret_val=$? else diff --git a/tests/p_ruby/50-rdoc-version-test.sh b/tests/p_ruby/50-rdoc-version-test.sh index cf7a440..666d290 100755 --- a/tests/p_ruby/50-rdoc-version-test.sh +++ b/tests/p_ruby/50-rdoc-version-test.sh @@ -8,7 +8,10 @@ t_Log "Running $0 - Check version of rdoc." #allready prepared just in case versions should change between C5 and C6 -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" = "8" ] ; then + rdoc -v | grep -q '6.0' + ret_val=$? +elif [ "$centos_ver" = "7" ] ; then t_Log "CentOS $centos_ver rdoc has no version in cli -> SKIP" t_CheckExitStatus 0 exit 0 diff --git a/tests/p_selinux/0_install_tools.sh b/tests/p_selinux/0_install_tools.sh index 814f096..1e852dc 100755 --- a/tests/p_selinux/0_install_tools.sh +++ b/tests/p_selinux/0_install_tools.sh @@ -4,6 +4,8 @@ t_Log "Running $0 - install package selinux policycoreutils tools" if [ "$centos_ver" = "6" ] ; then t_InstallPackage policycoreutils-python +elif [ "$centos_ver" = "8" ] ; then + t_InstallPackage python3-libselinux else t_InstallPackage libselinux-python fi diff --git a/tests/p_selinux/selinux_enforce.sh b/tests/p_selinux/selinux_enforce.sh index b3c90d2..0a065e1 100755 --- a/tests/p_selinux/selinux_enforce.sh +++ b/tests/p_selinux/selinux_enforce.sh @@ -3,14 +3,14 @@ t_Log "Running $0 - check if SELinux is in enforcing mode" -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" -ge 7 ] ; then selinux_file=/sys/fs/selinux/enforce else selinux_file=/selinux/enforce fi if [ "$SKIP_QA_HARNESS" = "1" ] ; then - echo "Skipping this test ..." + t_Log "Skipping this test ..." else cat $selinux_file | grep 1 > /dev/null 2>&1 t_CheckExitStatus $? diff --git a/tests/p_selinux/selinux_policy_mismatch.py b/tests/p_selinux/selinux_policy_mismatch.py deleted file mode 100755 index 11d7186..0000000 --- a/tests/p_selinux/selinux_policy_mismatch.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -import sys -import selinux.audit2why as audit2why - -print "Testing audit2why for policy mismatch ..." - -try: - audit2why.init() -except: - sys.exit(1) - -sys.exit(0) - diff --git a/tests/p_selinux/selinux_policy_mismatch.sh b/tests/p_selinux/selinux_policy_mismatch.sh new file mode 100755 index 0000000..b6f0af2 --- /dev/null +++ b/tests/p_selinux/selinux_policy_mismatch.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +if [ "$centos_ver" -ge 8 ] ; then +PYTHON=python3 +else +PYTHON=python +fi + +t_Log "Running $0 - Testing audit2why for policy mismatch ..." + +cat << __EOF__ | $PYTHON - +import sys +import selinux.audit2why as audit2why + +try: + audit2why.init() +except: + sys.exit(1) +sys.exit(0) +__EOF__ + +t_CheckExitStatus $? diff --git a/tests/p_tftp-server/0-install_tftp-server.sh b/tests/p_tftp-server/0-install_tftp-server.sh index 137d964..ccaa166 100755 --- a/tests/p_tftp-server/0-install_tftp-server.sh +++ b/tests/p_tftp-server/0-install_tftp-server.sh @@ -4,6 +4,24 @@ t_InstallPackage tftp-server xinetd tftp # Enable tftp +if [ "$centos_ver" -ge "8" ] ; then +cat <<__EOF__ >/etc/xinetd.d/tftp +service tftp +{ + socket_type = dgram + protocol = udp + wait = yes + user = root + server = /usr/sbin/in.tftpd + server_args = -s /var/lib/tftpboot + disable = no + per_source = 11 + cps = 100 2 + flags = IPv4 +} +__EOF__ +else sed -i 's/\(disable\s*=\ \)yes/\1no/' /etc/xinetd.d/tftp +fi t_ServiceControl xinetd restart diff --git a/tests/p_tomcat/0-install_tomcat.sh b/tests/p_tomcat/0-install_tomcat.sh index bcbcc13..6a6a680 100755 --- a/tests/p_tomcat/0-install_tomcat.sh +++ b/tests/p_tomcat/0-install_tomcat.sh @@ -1,6 +1,10 @@ #!/bin/bash # Author: Athmane Madjoudj +if [ "$centos_ver" -eq "8" ] ; then + t_Log "Tomcat is not available in CentOS$centos_ver. SKIP" + exit 0 +fi yum -y remove java\* if [ "$centos_ver" = "7" ] ;then diff --git a/tests/p_tomcat/1-config_tomcat.sh b/tests/p_tomcat/1-config_tomcat.sh index 10fc2ec..40ae553 100755 --- a/tests/p_tomcat/1-config_tomcat.sh +++ b/tests/p_tomcat/1-config_tomcat.sh @@ -1,5 +1,8 @@ #!/bin/bash # Author: Athmane Madjoudj +if [ "$centos_ver" -ge "8" ] ; then + exit 0 +fi uname_arch=$(uname -m) t_Log "$0 - Configuring Tomcat" diff --git a/tests/p_tomcat/tomcat_manager_test.sh b/tests/p_tomcat/tomcat_manager_test.sh index a576f28..9ea95f0 100755 --- a/tests/p_tomcat/tomcat_manager_test.sh +++ b/tests/p_tomcat/tomcat_manager_test.sh @@ -1,5 +1,8 @@ #!/bin/sh # Author: Athmane Madjoudj +if [ "$centos_ver" -ge "8" ] ; then + exit 0 +fi #uname_arch=$(uname -m) #if [ "$uname_arch" == "i686" ] ; then #t_Log "Skipping $0 on $uname_arch" diff --git a/tests/p_tomcat/tomcat_test.sh b/tests/p_tomcat/tomcat_test.sh index ee6e83a..352d088 100755 --- a/tests/p_tomcat/tomcat_test.sh +++ b/tests/p_tomcat/tomcat_test.sh @@ -1,6 +1,9 @@ #!/bin/sh # Author: Athmane Madjoudj +if [ "$centos_ver" -ge "8" ] ; then + exit 0 +fi uname_arch=$(uname -m) #if [ "$uname_arch" == "i686" ] ; then #t_Log "Skipping $0 on $uname_arch" diff --git a/tests/p_vsftpd/0-install_vsftpd.sh b/tests/p_vsftpd/0-install_vsftpd.sh index e53e192..274b2bc 100755 --- a/tests/p_vsftpd/0-install_vsftpd.sh +++ b/tests/p_vsftpd/0-install_vsftpd.sh @@ -2,5 +2,12 @@ # Author: Athmane Madjoudj t_Log "Running $0 - installing vsFTPd." -t_InstallPackage vsftpd -t_ServiceControl vsftpd start +t_InstallPackage vsftpd +if [ "$centos_ver" -ge 8 ] ; then +cp -fp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.tf_p_vsftpd +sed -i 's/anonymous_enable=NO/anonymous_enable=YES/g' /etc/vsftpd/vsftpd.conf +fi +t_ServiceControl vsftpd restart +if [ "$centos_ver" -ge 8 ] ; then +mv -f /etc/vsftpd/vsftpd.conf.tf_p_vsftpd /etc/vsftpd/vsftpd.conf +fi diff --git a/tests/p_webalizer/0-install_webalizer.sh b/tests/p_webalizer/0-install_webalizer.sh index 94e360a..49a247a 100755 --- a/tests/p_webalizer/0-install_webalizer.sh +++ b/tests/p_webalizer/0-install_webalizer.sh @@ -3,7 +3,7 @@ t_Log "Running $0 - attempting to install webalizer" -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" -ge 7 ] ; then t_Log "No webalizer package for CentOS $centos_ver -> SKIP" t_CheckExitStatus 0 exit 0 diff --git a/tests/p_webalizer/webalizer_test.sh b/tests/p_webalizer/webalizer_test.sh index 041d835..d914faa 100755 --- a/tests/p_webalizer/webalizer_test.sh +++ b/tests/p_webalizer/webalizer_test.sh @@ -3,7 +3,7 @@ t_Log "Running $0 - Webalizer test." -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" -ge 7 ] ; then t_Log "No webalizer package for CentOS $centos_ver -> SKIP" t_CheckExitStatus 0 exit 0 diff --git a/tests/p_yum/yum_bugtracker.sh b/tests/p_yum/yum_bugtracker.sh index 72a15a2..09ec68a 100755 --- a/tests/p_yum/yum_bugtracker.sh +++ b/tests/p_yum/yum_bugtracker.sh @@ -3,6 +3,10 @@ t_Log "Running $0 - Yum is using CentOS' bugtracker test." +if [ "$centos_ver" -ge "8" ] ; then + t_Log "CentOS$ver, SKIP" + exit 0 +fi grep "http://bugs.centos.org" /etc/yum.conf >/dev/null 2>&1 t_CheckExitStatus $? diff --git a/tests/p_yum/yum_distroverpkg.sh b/tests/p_yum/yum_distroverpkg.sh index 7fd0e4a..92cafc9 100755 --- a/tests/p_yum/yum_distroverpkg.sh +++ b/tests/p_yum/yum_distroverpkg.sh @@ -2,6 +2,10 @@ t_Log "Running $0 - Yum configuration has the correct distroverpkg value test." +if [ "$centos_ver" -ge "8" ] ; then + t_Log "CentOS$ver, SKIP" + exit 0 +fi #add centos-userland-release for armhfp uname_arch=$(uname -m) if [ "$uname_arch" == "armv7l" ]; then diff --git a/tests/r_lamp/0_lamp_install.sh b/tests/r_lamp/0_lamp_install.sh index a8555cf..a1aedd8 100755 --- a/tests/r_lamp/0_lamp_install.sh +++ b/tests/r_lamp/0_lamp_install.sh @@ -9,6 +9,9 @@ t_Log "Running $0 - attempting to install LAMP stack." if [ $centos_ver = 5 ] then t_InstallPackage mysql-server mysql55-mysql-server httpd php +elif [ $centos_ver -ge 8 ] +then + t_InstallPackage mariadb-server httpd php else t_InstallPackage mysql-server httpd php fi diff --git a/tests/r_lamp/40_basic_lamp.sh b/tests/r_lamp/40_basic_lamp.sh index ca176bd..11a20a8 100755 --- a/tests/r_lamp/40_basic_lamp.sh +++ b/tests/r_lamp/40_basic_lamp.sh @@ -15,8 +15,11 @@ then elif [ $centos_ver = 6 ] then t_InstallPackage httpd mysql mysql-server php php-mysql wget -else +elif [ $centos_ver = 7 ] +then t_InstallPackage httpd mysql mysql-server php php-mysqlnd wget +else + t_InstallPackage httpd mariadb mariadb-server php php-mysqlnd wget fi t_ServiceControl mysqld restart t_ServiceControl httpd restart @@ -37,18 +40,18 @@ mysql /var/www/html/mysql.php < EOF diff --git a/tests/r_lamp/45_basic_lamp_mysql55.sh b/tests/r_lamp/45_basic_lamp_mysql55.sh index 04c48e3..0c8ecbc 100755 --- a/tests/r_lamp/45_basic_lamp_mysql55.sh +++ b/tests/r_lamp/45_basic_lamp_mysql55.sh @@ -12,6 +12,8 @@ if [ $centos_ver = 5 ] then t_ServiceControl mysqld stop t_ServiceControl mysql55-mysqld start +else + exit 0 fi t_ServiceControl httpd restart diff --git a/tests/r_lamp/50_lamp_check_mysql55.sh b/tests/r_lamp/50_lamp_check_mysql55.sh index d81edd4..064f066 100755 --- a/tests/r_lamp/50_lamp_check_mysql55.sh +++ b/tests/r_lamp/50_lamp_check_mysql55.sh @@ -9,7 +9,7 @@ # starting with 5.10, we have to differ between mysql55 and mysql -if [ "$centos_ver" = "7" ] ; then +if [ "$centos_ver" -ge 7 ] ; then t_Log "no mysql55 on CentOS 7 ... SKIP" exit 0 fi