mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
new crl test using server and client instead
This commit is contained in:
149
scripts/crl.test
149
scripts/crl.test
@@ -2,74 +2,85 @@
|
|||||||
|
|
||||||
#crl.test
|
#crl.test
|
||||||
|
|
||||||
dir="certs/crl"
|
log_file="scripts/client_result.txt"
|
||||||
log_file="tests/unit.log"
|
|
||||||
result_file="make_test_result.txt"
|
|
||||||
success_line="err = -361, CRL Cert revoked"
|
success_line="err = -361, CRL Cert revoked"
|
||||||
exit_code="0"
|
exit_code="-1"
|
||||||
allowed_to_run="1"
|
|
||||||
script_1="testsuite/testsuite.test"
|
crl_port=11113
|
||||||
script_2="scripts/*.test"
|
no_pid=-1
|
||||||
|
server_pid=$no_pid
|
||||||
|
|
||||||
|
function remove_ready_file() {
|
||||||
|
if test -e /tmp/wolfssl_server_ready; then
|
||||||
|
echo -e "removing exisitng server_ready file"
|
||||||
|
rm /tmp/wolfssl_server_ready
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# trap this function so if user aborts with ^C or other kill signal we still
|
||||||
|
# get an exit that will in turn clean up the file system
|
||||||
|
function abort_trap() {
|
||||||
|
$exit_code = "-1"
|
||||||
|
echo "got abort signal, exiting with $exit_code"
|
||||||
|
exit $exit_code
|
||||||
|
}
|
||||||
|
trap abort_trap INT TERM
|
||||||
|
|
||||||
|
|
||||||
# trap this function so that if we exit on an error the file system will still
|
# trap this function so that if we exit on an error the file system will still
|
||||||
# be restored and the other tests may still pass. Never call this function
|
# be restored and the other tests may still pass. Never call this function
|
||||||
# instead use "exit <some value>" and this function will run automatically
|
# instead use "exit <some value>" and this function will run automatically
|
||||||
function restore_file_system() {
|
function restore_file_system() {
|
||||||
move_bad_crl_out
|
echo "in cleanup"
|
||||||
put_in_good_crl
|
|
||||||
|
if [ $server_pid != $no_pid ]
|
||||||
|
then
|
||||||
|
echo "killing server"
|
||||||
|
kill -9 $server_pid
|
||||||
|
fi
|
||||||
|
remove_ready_file
|
||||||
}
|
}
|
||||||
trap restore_file_system EXIT
|
trap restore_file_system EXIT
|
||||||
|
|
||||||
function can_start() {
|
|
||||||
|
|
||||||
# NICK: need a better way of controlling when this script executes
|
|
||||||
# I.E. force it to be last or force it to be first
|
|
||||||
|
|
||||||
# grep for any other test scripts that may be running
|
|
||||||
$allowed_to_run=`ps aux | grep -i "$script_1" | grep -v "grep" | wc -l`
|
|
||||||
if [ $allowed_to_run -ge 1 ]
|
|
||||||
then
|
|
||||||
echo "script is running"
|
|
||||||
else
|
|
||||||
echo "script is not running"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function move_good_crl_out() {
|
|
||||||
if test -e $dir/crl.pem; then
|
|
||||||
echo "moving good crl out of the way"
|
|
||||||
mv $dir/crl.pem $dir/crl.unrevoked
|
|
||||||
else
|
|
||||||
echo "file not found: $dir/crl.pem"
|
|
||||||
echo "Please make sure you're running from wolfSSL_root directory"
|
|
||||||
$exit_code = -1
|
|
||||||
echo "exiting with $exit_code"
|
|
||||||
exit $exit_code
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function put_in_bad_crl() {
|
|
||||||
if test -e $dir/crl.revoked; then
|
|
||||||
echo "moving crl with server revoked into place"
|
|
||||||
mv $dir/crl.revoked $dir/crl.pem
|
|
||||||
else
|
|
||||||
echo "file not found: $dir/crl.revoked"
|
|
||||||
echo "Please make sure you're running from wolfSSL_root directory"
|
|
||||||
$exit_code = -1
|
|
||||||
echo "exiting with $exit_code"
|
|
||||||
exit $exit_code
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
|
echo -e "\nStarting example server for crl test...\n"
|
||||||
|
|
||||||
|
remove_ready_file
|
||||||
|
./examples/server/server -R -p $crl_port &
|
||||||
|
server_pid=$!
|
||||||
|
|
||||||
|
while [ ! -s /tmp/wolfssl_server_ready ]; do
|
||||||
|
echo -e "waiting for server_ready file..."
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
|
||||||
|
./examples/client/client -p $crl_port &> $log_file
|
||||||
|
client_result=$?
|
||||||
|
|
||||||
|
if [ $client_result != 0 ]
|
||||||
|
then
|
||||||
|
echo -e "client failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
wait $server_pid
|
||||||
|
server_result=$?
|
||||||
|
|
||||||
|
if [ $server_result != 0 ]
|
||||||
|
then
|
||||||
|
echo -e "client failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\nSuccess!\n"
|
||||||
|
|
||||||
# NICK: is there a better way then scrubbing the .log file to get the
|
# NICK: is there a better way then scrubbing the .log file to get the
|
||||||
# error code -361 thoughts?
|
# error code -361 thoughts?
|
||||||
#consider how we might abstract this up one layer perhaps a c program.
|
#consider how we might abstract this up one layer perhaps a c program.
|
||||||
|
|
||||||
# Redirect stdout and stderr to reduce "noise"
|
# Redirect stdout and stderr to reduce "noise"
|
||||||
./testsuite/testsuite.test &> scripts/ignore.txt
|
# ./testsuite/testsuite.test &> scripts/ignore.txt
|
||||||
rm scripts/ignore.txt
|
# rm scripts/ignore.txt
|
||||||
|
|
||||||
if test -e $log_file
|
if test -e $log_file
|
||||||
then
|
then
|
||||||
@@ -83,44 +94,12 @@ function run_test() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function move_bad_crl_out() {
|
|
||||||
if test -e $dir/crl.pem; then
|
|
||||||
echo "moving crl with server revoked out of the way"
|
|
||||||
mv $dir/crl.pem $dir/crl.revoked
|
|
||||||
else
|
|
||||||
echo "file system corrupted. $dir/crl.pem missing after test"
|
|
||||||
$exit_code = -2
|
|
||||||
echo "exiting with $exit_code"
|
|
||||||
exit $exit_code
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function put_in_good_crl() {
|
|
||||||
if test -e $dir/crl.unrevoked; then
|
|
||||||
echo "moving good crl back into place"
|
|
||||||
mv $dir/crl.unrevoked $dir/crl.pem
|
|
||||||
else
|
|
||||||
echo "file system corrupted. $dir/crl.unrevoked missing after test"
|
|
||||||
$exit_code = -2
|
|
||||||
echo "exiting with $exit_code"
|
|
||||||
exit $exit_code
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
######### begin program #########
|
######### begin program #########
|
||||||
|
|
||||||
# check if testsuite is currently running
|
|
||||||
#can_start
|
|
||||||
|
|
||||||
# move good crl to crl.unrevoked
|
|
||||||
move_good_crl_out
|
|
||||||
|
|
||||||
# move revoked crl into place
|
|
||||||
put_in_bad_crl
|
|
||||||
|
|
||||||
# run the test
|
# run the test
|
||||||
run_test
|
run_test
|
||||||
|
$exit_code=0
|
||||||
echo "exiting with $exit_code"
|
echo "exiting with $exit_code"
|
||||||
exit $exit_code
|
exit $exit_code
|
||||||
########## end program ##########
|
########## end program ##########
|
||||||
|
Reference in New Issue
Block a user