Add pre-test before running test [PKGS-7388]

This commit is contained in:
mboelen 2014-09-15 11:17:26 +02:00
parent bce234fa00
commit 35d32fb5e4

View File

@ -592,50 +592,47 @@
# #
# Test : PKGS-7388 # Test : PKGS-7388
# Description : Check security repository in Debian/ubuntu apt sources.list file # Description : Check security repository in Debian/ubuntu apt sources.list file
Register --test-no PKGS-7388 --os Linux --weight L --network NO --description "Check security repository in Debian/ubuntu apt sources.list file" if [ -f /etc/apt/sources.list -a -d /etc/apt/sources.list.d ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no PKGS-7388 --os preqs-met ${PREQS_MET} --weight L --network NO --description "Check security repository in Debian/ubuntu apt sources.list file"
if [ $SKIPTEST -eq 0 ]; then if [ $SKIPTEST -eq 0 ]; then
FOUND=0 FOUND=0
if [ -f /etc/apt/sources.list -o -d /etc/apt/sources.list.d ]; then if [ ! "${OPTION_DEBIAN_SKIP_SECURITY_REPOSITORY}" = "yes" ]; then
if [ ! "${OPTION_DEBIAN_SKIP_SECURITY_REPOSITORY}" = "yes" ]; then if [ -f /etc/apt/sources.list ]; then
if [ -f /etc/apt/sources.list ]; then logtext "Searching for security.debian.org/security.ubuntu.com or security repositories in /etc/apt/sources.list file"
logtext "Searching for security.debian.org/security.ubuntu.com or security repositories in /etc/apt/sources.list file" FIND=`egrep "security.debian.org|security.ubuntu.com|-security " /etc/apt/sources.list | grep -v '#' | sed 's/ /!space!/g'`
FIND=`egrep "security.debian.org|security.ubuntu.com|-security " /etc/apt/sources.list | grep -v '#' | sed 's/ /!space!/g'` if [ ! "${FIND}" = "" ]; then
if [ ! "${FIND}" = "" ]; then FOUND=1
FOUND=1 Display --indent 2 --text "- Checking security repository in sources.list file" --result OK --color GREEN
Display --indent 2 --text "- Checking security repository in sources.list file" --result OK --color GREEN logtext "Result: Found security repository in /etc/apt/sources.list"
logtext "Result: Found security repository in /etc/apt/sources.list" for I in ${FIND}; do
for I in ${FIND}; do I=`echo ${I} | sed 's/!space!/ /g'`
I=`echo ${I} | sed 's/!space!/ /g'` logtext "Output: ${I}"
logtext "Output: ${I}" done
done
fi
fi fi
if [ -d /etc/apt/sources.list.d ]; then fi
logtext "Searching for security.debian.org/security.ubuntu.com or security repositories in /etc/apt/sources.list.d directory" if [ -d /etc/apt/sources.list.d ]; then
FIND=`egrep "security.debian.org|security.ubuntu.com|-security " /etc/apt/sources.list.d/* | grep -v '#' | sed 's/ /!space!/g'` logtext "Searching for security.debian.org/security.ubuntu.com or security repositories in /etc/apt/sources.list.d directory"
if [ ! "${FIND}" = "" ]; then FIND=`egrep "security.debian.org|security.ubuntu.com|-security " /etc/apt/sources.list.d/* | grep -v '#' | sed 's/ /!space!/g'`
FOUND=1 if [ ! "${FIND}" = "" ]; then
Display --indent 2 --text "- Checking security repository in sources.list.d directory" --result OK --color GREEN FOUND=1
logtext "Result: Found security repository in one or more files in directory /etc/apt/sources.list.d" Display --indent 2 --text "- Checking security repository in sources.list.d directory" --result OK --color GREEN
for I in ${FIND}; do logtext "Result: Found security repository in one or more files in directory /etc/apt/sources.list.d"
I=`echo ${I} | sed 's/!space!/ /g'` for I in ${FIND}; do
logtext "Output: ${I}" I=`echo ${I} | sed 's/!space!/ /g'`
done logtext "Output: ${I}"
fi done
fi
if [ ${FOUND} -eq 1 ]; then
logtext "Result: security repository was found"
AddHP 3 3
else
Display --indent 2 --text "- Checking security repository in sources.list file or directory" --result WARNING --color RED
ReportWarning ${TEST_NO} "M" "Can't find any security repository in /etc/apt/sources.list or sources.list.d directory"
AddHP 0 3
fi fi
fi
if [ ${FOUND} -eq 1 ]; then
logtext "Result: security repository was found"
AddHP 3 3
else else
logtext "Skipped as option is set to ignore security repository" Display --indent 2 --text "- Checking security repository in sources.list file or directory" --result WARNING --color RED
ReportWarning ${TEST_NO} "M" "Can't find any security repository in /etc/apt/sources.list or sources.list.d directory"
AddHP 0 3
fi fi
else else
logtext "Result: skipping test as sources.list or sources.list.d is not found" logtext "Skipped as option is set to ignore security repository"
fi fi
fi fi
# #