Author: rmeggins
Update of /cvs/dirsec/dsgw/tests
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv23442/dsgw/tests
Added Files:
setup.sh
Log Message:
added manuals; fixed code that displays manuals; added initial tests
--- NEW FILE setup.sh ---
#!/bin/sh
testdir="$1"
sroot=/home/$USER/11srv
port=1100
secport=1101
rootdn="cn=directory manager"
rootpw=password
adminpw=admin
#needinstance=1
#needdata=1
usessl=1
PATH=/usr/lib64/mozldap:/usr/lib/mozldap:$PATH
export PATH
suffix="dc=example,dc=com"
hostname=vmhost
inst=slapd-$hostname
if [ "$needinstance" ] ; then
$sroot/sbin/setup-ds.pl - <<EOF
[General]
FullMachineName= localhost.localdomain
SuiteSpotUserID= $USER
ServerRoot= $sroot/lib/dirsrv
[slapd]
ServerPort= $port
ServerIdentifier= localhost
Suffix= o=NetscapeRoot
RootDN= $rootdn
RootDNPwd= $rootpw
EOF
fi
if [ "$needdata" ] ; then
$sroot/lib/dirsrv/slapd-localhost/ldif2db.pl -D "$rootdn" -w "$rootpw"
-n userRoot -i $testdir/nsroot.ldif
sleep 10
fi
rm -rf testtmp
mkdir testtmp
if [ "$usessl" ] ; then
ldapurl="ldaps://$hostname:$secport/$suffix"
# grab CA cert
certutil -L -d $sroot/etc/dirsrv/$inst -n "CA certificate" -a >
testtmp/cacert.asc
# pin file
echo "passwordpassword" > testtmp/pwdfile.txt
# create sec db
certutil -N -d testtmp -f testtmp/pwdfile.txt
# import CA cert
certutil -A -d testtmp -n "CA certificate" -t "CT,," -a -i
testtmp/cacert.asc
port=$secport
else
ldapurl="ldap://localhost:$port/$suffix"
hostname=localhost
fi
DSGW_CONTEXT_DIR=`pwd`/testtmp ; export DSGW_CONTEXT_DIR
sed -e "s#@host@#$hostname#g" \
-e "s#@port@#$port#g" \
-e "s#@suffix@#$suffix#g" \
-e "s#@dirmgr@#cn=directory manager#g" \
-e "s#@contextdir@#$DSGW_CONTEXT_DIR#g" \
-e "s#@htmldir@#$sroot/share/dirsrv/dsgw/html#g" \
-e "s#@configdir@#$sroot/share/dirsrv/dsgw/config#g" \
config/dsgw.tmpl > testtmp/dsgw.conf
sed -e "s#@host@#$hostname#g" \
-e "s#@port@#$port#g" \
-e "s#@suffix@#$suffix#g" \
-e "s#@dirmgr@#cn=directory manager#g" \
-e "s#@contextdir@#$DSGW_CONTEXT_DIR#g" \
-e "s#@pbhtmldir@#$sroot/share/dirsrv/dsgw/pbhtml#g" \
-e "s#@pbconfigdir@#$sroot/share/dirsrv/dsgw/pbconfig#g" \
pbconfig/pb.tmpl > testtmp/pb.conf
dir=`pwd`
# CGI env. vars
#ADMSERV_CONF_DIR=$dir/testtmp
#ADMSERV_CONF_DIR=$sroot/etc/fedora-ds/admin-serv
#export ADMSERV_CONF_DIR
#ADMSERV_LOG_DIR=$dir/testtmp
#export ADMSERV_LOG_DIR
HTTP_ACCEPT_LANGUAGE=en
export HTTP_ACCEPT_LANGUAGE
SERVER_URL=http://localhost
export SERVER_URL
pwpfile=/tmp/pwp.$$
cat > $pwpfile <<EOF
User: admin
Password: $adminpw
UserDN: uid=admin, ou=Administrators, ou=TopologyManagement, o=NetscapeRoot
SIEPWD: $adminpw
EOF
VGPREFIX="valgrind --tool=memcheck --leak-check=yes
--suppressions=$HOME/valgrind.supp --num-callers=40 "
GDB="gdb -x .gdbinit "
DEBUGCMD=VALGRIND
#DEBUGCMD="$GDB"
PROGS="lang"
# use scripts for orgchart perl scripts
SCRIPTS=""
runATest() {
prog="$1"
shift
type="$1"
shift
mytest="$1" # this is the test filename, not the test name
shift
varnum="$1" # which variant
shift
variant="$1"
set -x
if [ ! -d results/$prog ] ; then mkdir -p results/$prog ; fi
basetest=`basename $mytest`$varnum
echo "Running test $mytest$varnum . . ."
if [ -n "$varnum" ] ; then
testtmpfile=/tmp/$prog.$basetest
cp $mytest $testtmpfile
echo -n "$variant" >> $testtmpfile
mytest=$testtmpfile
else
testtmpfile=
fi
REQUEST_METHOD=$type ; export REQUEST_METHOD
if [ $type = "GET" ] ; then
QUERY_STRING="`cat $mytest`" ; export QUERY_STRING
else
CONTENT_LENGTH=`wc -c $mytest | cut -f1 -d' '` ; export CONTENT_LENGTH
fi
SCRIPT_NAME=/clients/dsgw/bin/$prog ; export SCRIPT_NAME
exec 4<$pwpfile
PASSWORD_PIPE=4 ; export PASSWORD_PIPE
if [ -n "$DEBUGCMD" -a "$DEBUGCMD" = "$GDB" ] ; then
echo "break main" > .gdbinit
if [ $type = "POST" ] ; then
echo "run < $mytest > results/$prog/$basetest.html" >>
.gdbinit
else
echo "run > results/$prog/$basetest.html" >> .gdbinit
fi
./libtool --mode execute $GDB ./$prog
elif [ "$DEBUGCMD" = "VALGRIND" ] ; then
VALGRIND="$VGPREFIX --log-file-exactly=results/$prog/$basetest.vg"
if [ $type = "POST" ] ; then
./libtool --mode execute $VALGRIND ./$prog < $mytest >
results/$prog/$basetest.html
else
./libtool --mode execute $VALGRIND ./$prog > results/$prog/$basetest.html
fi
else
if [ $type = "POST" ] ; then
./libtool --mode execute ./$prog < $mytest > results/$prog/$basetest.html
else
./libtool --mode execute ./$prog > results/$prog/$basetest.html
fi
fi
4<&- # close the pwpfile
if [ -n "$testtmpfile" -a -f "$testtmpfile" ] ; then
rm -f "$testtmpfile"
fi
set +x
}
runGetTestsForProg() {
prog="$1" # test must be in dir of same name
shift
getlist=/tmp/gettests.$$
find $testdir/$prog -name testget.\* -print 2> /dev/null | sort -n > $getlist
for test in `cat $getlist` ; do
runATest "$prog" GET "$test"
ctxnum=1
for ctx in "" "/" "." "../../../"
"somebogusvalue" "pb" "dsgw" ; do
if [ -s "$test" ] ; then
runATest "$prog" GET "$test" .$ctxnum "&context=$ctx"
else
runATest "$prog" GET "$test" .$ctxnum "context=$ctx"
fi
ctxnum=`expr $ctxnum + 1`
done
done
rm -f $getlist
}
runPostTestsForProg() {
prog="$1" # test must be in dir of same name
shift
postlist=/tmp/posttests.$$
find $testdir/$prog -name testpost.\* -print 2> /dev/null | sort -n > $postlist
for test in `cat $postlist` ; do
runATest "$prog" POST "$test"
ctxnum=1
for ctx in "" "/" "." "../../../"
"somebogusvalue" "pb" "dsgw" ; do
runATest "$prog" POST "$test" .$ctxnum
"&context=$ctx"
ctxnum=`expr $ctxnum + 1`
done
done
rm -f $postlist
}
# each prog has a subdir containing the GET/POST args and any other test data
for prog in $PROGS ; do
runGetTestsForProg "$prog"
runPostTestsForProg "$prog"
done
for prog in $SCRIPTS ; do
getlist=/tmp/gettests.$$
find $testdir/$prog -name testget.\* -print 2> /dev/null | sort -n > $getlist
for test in `cat $getlist` ; do
if [ ! -d results/$prog ] ; then mkdir -p results/$prog ; fi
basetest=`basename $test`
echo "Running test $test"
REQUEST_METHOD=GET ; export REQUEST_METHOD
QUERY_STRING="`cat $test`" ; export QUERY_STRING
SCRIPT_NAME=slapd/Tasks/Operation/$prog ; export SCRIPT_NAME
# open pwpfile for reading as file desc 4 - CGIs have to use stdin (0) for POST
exec 4<$pwpfile
PASSWORD_PIPE=4 ; export PASSWORD_PIPE
if [ -n "$DEBUGCMD" -a "$DEBUGCMD" = "$GDB" ] ;
then
perl -d orgchart/$prog
else
perl -w orgchart/$prog
fi
done
rm -f $getlist
done
rm -rf $pwpfile .gdbinit
Show replies by date