From d8669d9bbca36fcb24c243e4883ace138842843c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20=C5=A0ustr?= Date: Tue, 7 Dec 2010 13:34:40 +0000 Subject: [PATCH] All functionality tests detailed in the testplan. First implementation, considered working. --- .../gridsite/tests/gridsite-test-all.sh | 379 +++++++++++++++++++++ 1 file changed, 379 insertions(+) create mode 100755 org.glite.testsuites.ctb/gridsite/tests/gridsite-test-all.sh diff --git a/org.glite.testsuites.ctb/gridsite/tests/gridsite-test-all.sh b/org.glite.testsuites.ctb/gridsite/tests/gridsite-test-all.sh new file mode 100755 index 0000000..7f5cbf8 --- /dev/null +++ b/org.glite.testsuites.ctb/gridsite/tests/gridsite-test-all.sh @@ -0,0 +1,379 @@ +#!/bin/bash +# +# Copyright (c) Members of the EGEE Collaboration. 2004-2010. +# See http://www.eu-egee.org/partners for details on the copyright holders. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# show help and usage +progname=`basename $0` +showHelp() +{ +cat << EndHelpHeader +Script for testing gridsite functions + +Prerequisities: + - GridSite and httpd with mod_ssl installe + +Returned values: + Exit TEST_OK: Test Passed + Exit TEST_ERROR: Test Failed + Exit 2: Wrong Input + +EndHelpHeader + + echo "Usage: $progname [OPTIONS]" + echo "Options:" + echo " -h | --help Show this help message." + echo " -o | --output 'file' Redirect all output to the 'file' (stdout by default)." + echo " -t | --text Format output as plain ASCII text." + echo " -c | --color Format output as text with ANSI colours (autodetected by default)." + echo " -x | --html Format output as html." +} + +# read common definitions and functions +COMMON=lb-common.sh +if [ ! -r ${COMMON} ]; then + printf "Common definitions '${COMMON}' missing!" + exit 2 +fi +source ${COMMON} + +logfile=$$.tmp +flag=0 +while test -n "$1" +do + case "$1" in + "-h" | "--help") showHelp && exit 2 ;; + "-o" | "--output") shift ; logfile=$1 flag=1 ;; + "-t" | "--text") setOutputASCII ;; + "-c" | "--color") setOutputColor ;; + "-x" | "--html") setOutputHTML ;; + esac + shift +done + +# redirecting all output to $logfile +#touch $logfile +#if [ ! -w $logfile ]; then +# echo "Cannot write to output file $logfile" +# exit $TEST_ERROR +#fi + +DEBUG=2 + +## +# Starting the test +##################### + +{ +test_start + + +# check_binaries +printf "Testing if all binaries are available" +check_binaries curl rm chown openssl htcp htls htmv htcp htrm htls htls htproxydestroy +if [ $? -gt 0 ]; then + test_failed +else + test_done +fi + + printf "READ (Read Permissions)\n" + +cat >/var/www/htdocs/test.html <

Hello Grid

+EOF + + $SYS_RM /var/www/htdocs/.gacl + + printf "Plain read... " + code=`curl --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --output /dev/null --silent --write-out '%{http_code}\n' https://$(hostname -f)/test.html` + printf "Return code $code" + if [ "$code" = "403" ]; then + test_done + else + test_failed + fi + +cat >/var/www/htdocs/.gacl < + + + + + +EOF + + + printf "With gacl... " + code=`curl --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --output /dev/null --silent --write-out '%{http_code}\n' https://$(hostname -f)/test.html` + printf "Return code $code" + if [ "$code" = "200" ]; then + test_done + else + test_failed + fi + + + printf "Get index (list & read permissions)\n" + + printf "Plain read... " + code=`curl --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --output /dev/null --silent --write-out '%{http_code}\n' https://$(hostname -f)/` + printf "Return code $code" + if [ "$code" = "403" ]; then + test_done + else + test_failed + fi + +cat >/var/www/htdocs/.gacl < + + + `openssl x509 -noout -subject -in /etc/grid-security/hostcert.pem | sed -e 's/^subject= //'` + + + + +EOF + + printf "With gacl... " + code=`curl --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --output /dev/null --silent --write-out '%{http_code}\n' \ +https://$(hostname -f)/` + printf "Return code $code" + if [ "$code" = "200" ]; then + test_done + else + test_failed + fi + + + + + printf "WRITE & DELETE (write permissions)\n" + + rm -f /var/www/htdocs/.gacl /var/www/htdocs/test.txt + date > /tmp/test.txt + chown apache /var/www/htdocs/ + + printf "Plain write... " + code=`curl --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --output /dev/null --silent --write-out '%{http_code}\n' --upload-file /tmp/test.txt https://$(hostname -f)/test.txt` + printf "Return code $code" + if [ "$code" = "403" ]; then + test_done + else + test_failed + fi + +cat >/var/www/htdocs/.gacl < + + + `openssl x509 -noout -subject -in /etc/grid-security/hostcert.pem | sed -e 's/^subject= //'` + + + + +EOF + + printf "With gacl... " + code=`curl --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --output /dev/null --silent --write-out '%{http_code}\n' --upload-file /tmp/test.txt https://$(hostname -f)/test.txt` + cmp -s /tmp/test.txt /var/www/htdocs/test.txt + printf "Return code $code" + if [ $? -eq 0 -a "$code" = "201" ]; then + test_done + else + test_failed + fi + + printf "Try deletion... " + mv /var/www/htdocs/.gacl /var/www/htdocs/.gacl.bak + code=`curl --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --output /dev/null --silent --write-out '%{http_code}\n' -X DELETE https://$(hostname -f)/test.txt` + printf "Return code $code" + if [ $? -eq 0 -a "$code" = "403" ]; then + test_done + else + test_failed + fi + + mv /var/www/htdocs/.gacl.bak /var/www/htdocs/.gacl + + printf "With gacl... " + code=`curl --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --output /dev/null --silent --write-out '%{http_code}\n' -X DELETE https://$(hostname -f)/test.txt` + printf "Return code $code" + if [ $? -eq 0 -a "$code" = "200" ]; then + test_done + else + test_failed + fi + chown root /var/www/htdocs + + + printf "Checking attributes passed on to the environment\n" + +cat >/var/www/htdocs/.gacl < + + + `openssl x509 -noout -subject -in /etc/grid-security/hostcert.pem | sed -e 's/^subject= //'` + + + + +EOF + +cat >/var/www/htdocs/test.cgi </dev/null 2>/dev/null + if [ $? -eq 0 ]; then + test_done + else + test_failed + fi + + + printf "Test the basic commands (htcp, htls, htmkdir, htmv, htrm)\n" + +cat >/var/www/htdocs/.gacl < + + + `openssl x509 -noout -subject -in /etc/grid-security/hostcert.pem | sed -e 's/^subject= //'` + + + + +EOF + + chown apache /var/www/htdocs/ + + date > /tmp/test.txt + + printf "Testing htcp... " + htcp --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates/ /tmp/test.txt https://$(hostname -f)/ + if [ $? -eq 0 ]; then + test_done + else + test_failed + fi + printf "Checking by htls... " + htls --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates/ https://$(hostname -f)/test.txt > /dev/null + if [ $? -eq 0 ]; then + test_done + else + test_failed + fi + printf "Testing htmv... " + htmv --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates/ https://$(hostname -f)/test.txt https://$(hostname -f)/test2.txt + if [ $? -eq 0 ]; then + test_done + else + test_failed + fi + printf "htcp, file 2... " + htcp --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates/ https://$(hostname -f)/test2.txt /tmp + if [ $? -eq 0 ]; then + test_done + else + test_failed + fi + printf "Testing htrm... " + htrm --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates/ https://$(hostname -f)/test2.txt + if [ $? -eq 0 ]; then + test_done + else + test_failed + fi + printf "Checking by htls... " + htls --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates/ https://$(hostname -f)/test2.txt 2> /dev/null + if [ $? -eq 22 ]; then + test_done + else + test_failed + fi + printf "Checking directory contents with htls... " + htls --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates/ https://$(hostname -f)/ > /dev/null + if [ $? -eq 0 ]; then + test_done + else + test_failed + fi + printf "File compare... " + cmp /tmp/test.txt /tmp/test2.txt + if [ $? -eq 0 ]; then + test_done + else + test_failed + fi + + chown root /var/www/htdocs/ + + printf "Test proxy delegation\n" + + if [ ! -e /var/www/proxycache ]; then + mkdir /var/www/proxycache + fi + chown apache /var/www/proxycache + + #delegation + id=`htproxyput --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates https://$(hostname -f)/gridsite-delegation.cgi` + printf "id: $id" + if [ $? -eq 0 -a -n "$id" ]; then + test_done + else + test_failed + fi + + expiry=`htproxyunixtime --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --delegation-id $id https://$(hostname -f)/gridsite-delegation.cgi` + + newid=`htproxyrenew --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --delegation-id $id https://$(hostname -f)/gridsite-delegation.cgi` + printf "newid: $newid" + if [ $? -eq 0 -a -n "$newid" ]; then + test_done + else + test_failed + fi + + htproxydestroy --cert /etc/grid-security/hostcert.pem --key /etc/grid-security/hostkey.pem --capath /etc/grid-security/certificates --delegation-id $id https://$(hostname -f)/gridsite-delegation.cgi + + + + +test_end +} +#} &> $logfile + +#if [ $flag -ne 1 ]; then +# cat $logfile +# $SYS_RM $logfile +#fi +exit $TEST_OK + -- 1.8.2.3