diff --git a/tests/p_freeradius/0-install_freeradius.sh b/tests/p_freeradius/0-install_freeradius.sh index d0f9ba7..e0f82f2 100755 --- a/tests/p_freeradius/0-install_freeradius.sh +++ b/tests/p_freeradius/0-install_freeradius.sh @@ -4,6 +4,7 @@ # Install freeradius # On C5 both freeradius and freeradius2 are provided, however only freeradius2-utils are provided as well # so we will install freeradius2 on C5 and freeradius (being freeradius2) on C6 + if (t_GetPkgRel basesystem | grep -q el6) then #Install Freeradius (V2) @@ -21,15 +22,30 @@ then t_ServiceControl radiusd start else # C5 has an eap-setting in radiusd.conf and 3 "sites-available" which prevent successfull start (probably missing some dep) - # as the basic test works without these, the eap setting 2 sites-available will be removed for the test and later restored - sed -i 's/.*INCLUDE\ eap\.conf/# INCLUDE eap.conf/g' /etc/raddb/radiusd.conf + # as the basic test works without these, the eap settings and 2 sites-available will be removed for the test and later restored + # Check if we allready did this + if [ ! -e /etc/raddb/radiusd.conf.orig ] + then + # File not yet copied + /bin/cp -a /etc/raddb/radiusd.conf /etc/raddb/radiusd.conf.orig + grep -iv eap /etc/raddb/radiusd.conf.orig > /etc/raddb/radiusd.conf + fi rm -rf /etc/raddb/sites-enabled/control-socket rm -rf /etc/raddb/sites-enabled/inner-tunnel - # /etc/raddb/sites-configured will be changed to remove all traces of eap - /bin/cp -a /etc/raddb/sites-available/default /etc/raddb/sites-available/default.orig - head -n 138 /etc/raddb/sites-available/default.orig | grep -v eap > /etc/raddb/sites-available/default - tail -n 416 /etc/raddb/sites-available/default.orig | grep -v eap >> /etc/raddb/sites-available/default - sed -i 's/.*ok\ \=\ return/# ok = return/g' /etc/raddb/sites-available/default - t_ServiceControl radiusd start + # /etc/raddb/sites-configured will be changed to include only basic files-authentication + # Check if we allready did this + if [ ! -e /etc/raddb/sites-available/default.orig ] + then + # File not yet copied + /bin/cp -a /etc/raddb/sites-available/default /etc/raddb/sites-available/default.orig + fi +cat > /etc/raddb/sites-available/default <> /etc/raddb/users - echo ' Service-Type = Framed-User,' >> /etc/raddb/users +# Make Backup of /etc/raddb/users and add testuser steve +/bin/cp /etc/raddb/users /etc/raddb/users.orig +echo 'steve Cleartext-Password := "centos"' >> /etc/raddb/users +echo ' Service-Type = Framed-User,' >> /etc/raddb/users - # Restart Service - service radiusd restart +# Restart Service +service radiusd restart - #Run test, treat C6 and C5 differently +#Run test, treat C6 and C5 differently if (t_GetPkgRel basesystem | grep -q el6) then @@ -31,18 +31,21 @@ else WORKING=$(radtest steve centos 127.0.0.1:1812 1 testing123 |grep -c 'Access-Accept') if [ $WORKING == 1 ]; then ret_val=0 ; fi fi - # Restore settings - /bin/cp /etc/raddb/users.orig /etc/raddb/users - rm -rf /etc/raddb/users.orig - service radiusd restart -if (t_GetPkgRel basesystem | grep -q el5) - then - sed -i 's/#\ INCLUDE\ eap\.conf/\ \ INCLUDE eap.conf/g' /etc/raddb/radiusd.conf - ln -s /etc/raddb/sites-available/control-socket /etc/raddb/sites-enabled/ - ln -s /etc/raddb/sites-available/inner-tunnel /etc/raddb/sites-enabled/ - /bin/cp -a /etc/raddb/sites-available/default.orig /etc/raddb/sites-available/default - rm -rf /etc/raddb/sites-available/default.orig - service radiusd stop -fi + +# Restore settings +/bin/cp /etc/raddb/users.orig /etc/raddb/users +rm -rf /etc/raddb/users.orig +service radiusd restart + +#if (t_GetPkgRel basesystem | grep -q el5) +# then +# +# sed -i 's/#\ INCLUDE\ eap\.conf/\ \ INCLUDE eap.conf/g' /etc/raddb/radiusd.conf +# ln -s /etc/raddb/sites-available/control-socket /etc/raddb/sites-enabled/ +# ln -s /etc/raddb/sites-available/inner-tunnel /etc/raddb/sites-enabled/ +# /bin/cp -a /etc/raddb/sites-available/default.orig /etc/raddb/sites-available/default +# rm -rf /etc/raddb/sites-available/default.orig +# service radiusd stop +#fi t_CheckExitStatus $ret_val diff --git a/tests/p_mysql/mysqld_grant_test.sh b/tests/p_mysql/mysqld_grant_test.sh index 53e8701..da21c00 100755 --- a/tests/p_mysql/mysqld_grant_test.sh +++ b/tests/p_mysql/mysqld_grant_test.sh @@ -7,5 +7,9 @@ mysql -u root -e 'create database mysql_test;' > /dev/null 2>&1 mysql -u root -e "grant all on mysql_test.* to mysql_test@localhost identified by 'mysqltest'" > /dev/null 2>&1 mysql -u root -e "flush privileges;" > /dev/null 2>&1 mysql -u mysql_test -pmysqltest mysql_test -e 'create table test_table(id int);' > /dev/null 2>&1 +ret_val=$? -t_CheckExitStatus $? +# Clean up +mysql -u root -e 'drop database mysql_test;' > /dev/null 2>&1 + +t_CheckExitStatus $ret_val diff --git a/tests/p_tcpdump/tcp6dump_lo.sh b/tests/p_tcpdump/tcp6dump_lo.sh new file mode 100755 index 0000000..0259806 --- /dev/null +++ b/tests/p_tcpdump/tcp6dump_lo.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Author: Christoph Galuschka +# Athmane Madjoudj + +t_Log "Running $0 - TCPdump test IPv6 to lo" + +# Grabing IPv6 address of lo to checl if IPv6 is enabled +IP=$(ip addr list lo | grep 'inet6 ') +regex='\t*inet6\ (.*)\/.*' +if [[ $IP =~ $regex ]] + then + t_Log "IPv6 seems to be enabled - runing test" + FILE='/var/tmp/lo_test6.pcap' + COUNT='4' + #Dumping ping6s to loopback to file + tcpdump -q -n -p -i lo -w $FILE & + # If we don't wait a short time, the first paket will be missed by tcpdump + sleep 1 + ping6 -q -c $COUNT -i 0.25 ::1 + sleep 1 + killall -s SIGINT tcpdump + + # reading from file, for each ping we should see two pakets + WORKING=$( tcpdump -r $FILE | grep -ci icmp6 ) + if [ $WORKING == $[COUNT*2] ]; then + ret_val=0 + else + t_Log "ping6 to loopback droped pakets!! This should not happen on loopback" + ret_val=1 + fi + # Remove file afterwards + /bin/rm $FILE +else + t_Log "IPv6 seems to be disabled - skipping test" + ret_val=0 +fi + +t_CheckExitStatus $ret_val diff --git a/tests/p_tcpdump/tcpdump_eth0.sh b/tests/p_tcpdump/tcpdump_eth0.sh new file mode 100755 index 0000000..67a7d9a --- /dev/null +++ b/tests/p_tcpdump/tcpdump_eth0.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Author: Christoph Galuschka +# Athmane Madjoudj + +t_Log "Running $0 - TCPdump test to Default-GW with IPv4" + +# Grabing Default-Router of eth0 +IP=$(ip route list default | grep 'default via ') +regex='.*via\ (.*)\ dev.*' +if [[ $IP =~ $regex ]] + then + t_Log "Found Default-GW - starting tcpdump test" + #Dumping 4 pings via eth0 to file + FILE='/var/tmp/eth0_test.pcap' + COUNT='4' + tcpdump -q -n -p -i eth0 -w $FILE & + # If we don't wait a short time, the first paket will be missed by tcpdump + sleep 1 + ping -q -c $COUNT -i 0.25 ${BASH_REMATCH[1]} + sleep 1 + killall -s SIGINT tcpdump + # reading from file, for each ping we should see two pakets + WORKING=$( tcpdump -r $FILE | grep -ci icmp ) + # The script will allways work, but if we the log does not contain + # what we expect, we will log it + if [ $WORKING == $[COUNT*2] ] + then + ret_val=0 + else + t_Log "ping to Default-Gateway droped pakets!! Only "$WORKING" of "$[COUNT*2]" entries were found!!" + ret_val=1 + fi +else + t_Log "Found Default-GW - skiping test" + ret_val=0 +fi +# Remove file afterwards +/bin/rm $FILE + +t_CheckExitStatus $ret_val diff --git a/tests/p_tcpdump/tcpdump_lo.sh b/tests/p_tcpdump/tcpdump_lo.sh new file mode 100755 index 0000000..92516e2 --- /dev/null +++ b/tests/p_tcpdump/tcpdump_lo.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Author: Christoph Galuschka +# Athmane Madjoudj + +t_Log "Running $0 - TCPdump test to lo" + +#Dumping pings to loopback to file +FILE='/var/tmp/lo_test.pcap' +COUNT='4' + +tcpdump -q -n -p -i lo -w $FILE & +# If we don't wait a short time, the first paket will be missed by tcpdump +sleep 1 +ping -q -c $COUNT -i 0.25 127.0.0.1 +sleep 1 +killall -s SIGINT tcpdump + +# reading from file, for each ping we should see two pakets +WORKING=$( tcpdump -r $FILE | grep -ci icmp ) +if [ $WORKING == $[COUNT*2] ] + then + ret_val=0 +else + t_Log "ping to loopback droped pakets!! This should not happen on loopback" + ret_val=1 +fi + +# Remove file afterwards +/bin/rm $FILE + +t_CheckExitStatus $ret_val diff --git a/tests/p_tcpdump/tcpdump_test.sh b/tests/p_tcpdump/tcpdump_test.sh deleted file mode 100755 index ed9ba78..0000000 --- a/tests/p_tcpdump/tcpdump_test.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# Author: Christoph Galuschka -# Athmane Madjoudj - -t_Log "Running $0 - TCPdump can capture ICMP from localhost" - -#Dumping 4 pings to loopback to file -tcpdump -q -n -p -i lo -w /var/tmp/centos_test.pcap & -# If we don't wait a short time, the first paket will be missed by tcpdump -sleep 1 -ping -q -c 4 -i 0.25 127.0.0.1 -killall -s SIGINT tcpdump -sleep 1 - -# reading from file, for each ping we should see two pakets -WORKING=$( tcpdump -r /var/tmp/centos_test.pcap | grep -ci icmp ) -if [ $WORKING == 8 ]; then ret_val=0; fi - -# Remove file afterwards - /bin/rm /var/tmp/centos_test.pcap - -t_CheckExitStatus $ret_val