mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
206 lines
5.8 KiB
Bash
Executable File
206 lines
5.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
. ../.function
|
|
|
|
# set -x
|
|
|
|
## web_server_ssl.test -- Test web_server feature
|
|
|
|
start_msg web_server_ssl
|
|
|
|
(cd benchmark; rm -f db; creat_link FrameworkBenchmarks/ULib/db db; sync)
|
|
(cd ..; rm -rf db; creat_link examples/benchmark/db db; sync)
|
|
creat_link benchmark/db db
|
|
creat_link benchmark/libraries libraries
|
|
|
|
DOC_ROOT=docroot
|
|
|
|
rm -f db/session.ssl* /tmp/ssl_session.txt /tmp/byterange* /tmp/*.memusage.* /tmp/*.hpack.* \
|
|
$DOC_ROOT/webserver_ssl*.log* $DOC_ROOT/uploads/* /var/log/httpd/access_log \
|
|
out/userver_ssl.out err/userver_ssl.err web_server_ssl.err \
|
|
trace.*userver_ssl*.[0-9]* object.*userver_ssl*.[0-9]* stack.*userver_ssl*.[0-9]* mempool.*userver_ssl*.[0-9]* \
|
|
$DOC_ROOT/trace.*userver_ssl*.[0-9]* $DOC_ROOT/object.*userver_ssl*.[0-9]* $DOC_ROOT/stack.*userver_ssl*.[0-9]* $DOC_ROOT/mempool.*userver_ssl*.[0-9]*
|
|
|
|
#UTRACE="0 110M 0"
|
|
#UTRACE_SIGNAL="0 50M 0"
|
|
#UOBJDUMP="0 10M 500"
|
|
#USIMERR="error.sim"
|
|
export UTRACE UOBJDUMP USIMERR UTRACE_SIGNAL
|
|
|
|
if [ "$TERM" = "msys" ]; then
|
|
export TMPDIR="c:/tmp"
|
|
fi
|
|
|
|
DIR_CMD="../../examples/userver"
|
|
|
|
compile_usp
|
|
|
|
check_for_netcat
|
|
|
|
mkdir -p /var/log/httpd 2>/dev/null
|
|
|
|
# function : upload_test
|
|
upload_test() {
|
|
|
|
rm -rf uploads
|
|
mkdir -p uploads
|
|
$CHOWN nobody: uploads docroot 2>/dev/null
|
|
chmod 777 uploads
|
|
|
|
$CURL -m 5 -s -k -F 'file=@vuoto.txt' -F "name=prova" https://$1/cgi-bin/uploader.sh >>out/web_server_ssl.out 2>>err/web_server_ssl.err
|
|
$CURL -m 5 -s -k -F 'file=@inp/xml2txt/operazione.xml;type=text/xml' -F "name=prova" https://$1/cgi-bin/uploader.sh >>out/web_server_ssl.out 2>>err/web_server_ssl.err
|
|
$CURL -m 5 -s -k -T web_server.test https://$1/uploads/web_server.test >>out/web_server_ssl.out 2>>err/web_server_ssl.err
|
|
|
|
if [ $? -ne 0 ]; then
|
|
kill_server userver_ssl
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# function : start_test
|
|
start_test() {
|
|
|
|
#STRACE=$TRUSS
|
|
start_prg_background userver_ssl -c inp/webserver.cfg
|
|
|
|
wait_server_ready localhost 4443
|
|
|
|
CAPATH="../ulib/CA/CApath"
|
|
CACERT="../ulib/CA/username.crt"
|
|
USER_KEY="../ulib/CA/username.key"
|
|
LCMD="$OPENSSL s_client -quiet -cert $CACERT -key $USER_KEY -pass pass:caciucco -CApath $CAPATH -connect"
|
|
LCMD1="$LCMD localhost:4443"
|
|
|
|
#LS=tst_90
|
|
#LS=`ls inp/http/and`
|
|
#mkdir -p /tmp/web_server
|
|
#for i in $LS; do
|
|
# TIMEOUT 5 $LCMD1 <inp/http/and/$i >/tmp/web_server/$i
|
|
#done
|
|
|
|
#TIMEOUT 5 $LCMD 10.30.1.111:4443 <inp/http/all6.inp >>out/web_server_ssl.out 2>>err/web_server_ssl.err
|
|
#exit 0
|
|
#TIMEOUT 5 $LCMD1 <inp/http/all5.inp >>out/web_server_ssl.out 2>>err/web_server_ssl.err
|
|
#return
|
|
|
|
LS=`ls inp/http/close`
|
|
for i in $LS; do
|
|
TIMEOUT 2 $LCMD1 <inp/http/close/$i >>out/web_server_ssl.out 2>>err/web_server_ssl.err
|
|
done
|
|
|
|
TIMEOUT 5 $LCMD1 <inp/http/all.inp >>out/web_server_ssl.out 2>>err/web_server_ssl.err
|
|
TIMEOUT 5 $LCMD1 <inp/http/all1.inp >>out/web_server_ssl.out 2>>err/web_server_ssl.err
|
|
TIMEOUT 5 $LCMD1 <inp/http/post.inp >>out/web_server_ssl.out 2>>err/web_server_ssl.err
|
|
|
|
upload_test $2:4443
|
|
|
|
kill_server userver_ssl
|
|
}
|
|
|
|
# function : creat_config
|
|
creat_config() {
|
|
|
|
if [ -z "$2" ]; then
|
|
N=$1
|
|
else
|
|
N=$2
|
|
fi
|
|
|
|
cat <<EOF >inp/webserver.cfg
|
|
userver {
|
|
PORT 4443
|
|
RUN_AS_USER nobody
|
|
REQ_TIMEOUT 30
|
|
#MIN_SIZE_FOR_SENDFILE 2k
|
|
DOS_WHITE_LIST 127.0.0.1,10.30.0.0/16
|
|
LOG_FILE webserver_ssl$1.log
|
|
LOG_FILE_SZ 1M
|
|
LOG_MSG_SIZE -1
|
|
DOCUMENT_ROOT $DOC_ROOT
|
|
PLUGIN "ssi http"
|
|
PLUGIN_DIR ../../../src/ulib/net/server/plugin/.libs
|
|
ORM_DRIVER_DIR ../../../src/ulib/orm/driver/.libs
|
|
PREFORK_CHILD $N
|
|
CRASH_COUNT 1
|
|
CRASH_EMAIL_NOTIFY mail.unirel.com:stefano.casazza@unirel.com
|
|
CERT_FILE ../../ulib/CA/server.crt
|
|
KEY_FILE ../../ulib/CA/server.key
|
|
PASSWORD caciucco
|
|
CA_PATH ../../ulib/CA/CApath
|
|
CA_FILE ../../ulib/CA/cacert.pem
|
|
VERIFY_MODE 0
|
|
}
|
|
http {
|
|
ENABLE_INOTIFY yes
|
|
ALIAS @FILE:../alias.txt
|
|
LIMIT_REQUEST_BODY 700K
|
|
REQUEST_READ_TIMEOUT 30
|
|
DIGEST_AUTHENTICATION no
|
|
APACHE_LIKE_LOG /var/log/httpd/access_log
|
|
CACHE_FILE_MASK inp/http/data/file1|*.flv|*.svgz
|
|
CACHE_AVOID_MASK www.sito1.com|ruby
|
|
}
|
|
EOF
|
|
}
|
|
|
|
# ---------------------------------------------------------
|
|
# virtual host
|
|
# ---------------------------------------------------------
|
|
rm -rf $DOC_ROOT/www.sito1.com 2>/dev/null
|
|
|
|
grep 'www.sito1.com' /etc/hosts >/dev/null 2>/dev/null
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo '# virtual host userver' >> /etc/hosts 2>/dev/null
|
|
echo localhost www.sito1.com >> /etc/hosts 2>/dev/null
|
|
echo localhost www.sito2.com >> /etc/hosts 2>/dev/null
|
|
fi
|
|
|
|
mkdir -p $DOC_ROOT/benchmark/docroot $DOC_ROOT/www.sito1.com/benchmark/docroot
|
|
|
|
creat_link ../ok $DOC_ROOT/ok
|
|
creat_link ../tmp $DOC_ROOT/tmp
|
|
creat_link ../uploads $DOC_ROOT/uploads
|
|
creat_link ../../../benchmark/docroot/servlet $DOC_ROOT/benchmark/docroot/servlet
|
|
creat_link ../../inp $DOC_ROOT/www.sito1.com/inp
|
|
creat_link ../../tmp $DOC_ROOT/www.sito1.com/tmp
|
|
creat_link ../SSI $DOC_ROOT/www.sito1.com/SSI
|
|
creat_link ../cgi-bin $DOC_ROOT/www.sito1.com/cgi-bin
|
|
creat_link ../../uploads $DOC_ROOT/www.sito1.com/uploads
|
|
creat_link ../../../../benchmark/docroot/servlet $DOC_ROOT/www.sito1.com/benchmark/docroot/servlet
|
|
|
|
touch vuoto.txt $DOC_ROOT/vuoto.txt $DOC_ROOT/www.sito1.com/vuoto.txt
|
|
cat << EOF >tmp/c
|
|
c
|
|
c
|
|
EOF
|
|
|
|
pkill userver_ssl 2>/dev/null
|
|
|
|
# webserver_ssl0
|
|
creat_config 0
|
|
start_test $NCAT localhost
|
|
# webserver_ssl1 - openssl s_client close the connection in pipeline...
|
|
#creat_config 1
|
|
#start_test
|
|
# webserver_ssl2
|
|
creat_config 2
|
|
start_test $NCAT localhost
|
|
# webserver_sslN
|
|
creat_config N 2
|
|
start_test $NCAT localhost
|
|
|
|
kill_server userver_ssl
|
|
|
|
diff inp/xml2txt/operazione.xml uploads/operazione.xml
|
|
RESULT=$?
|
|
if [ "$RESULT" = "0" ]; then
|
|
diff web_server.test uploads/web_server.test
|
|
RESULT=$?
|
|
fi
|
|
|
|
mv err/userver_ssl.err err/web_server_ssl.err
|
|
|
|
# Test against expected output
|
|
test_output_wc l web_server_ssl
|