better telnet tester
This commit is contained in:
125
telnet_test.sh
125
telnet_test.sh
@@ -2,11 +2,6 @@
|
||||
|
||||
# you need to put absolutely everything in ""
|
||||
|
||||
#port="80"
|
||||
port="4040"
|
||||
path="/"
|
||||
#host="duckduckgo.com"
|
||||
host="localhost"
|
||||
|
||||
##########
|
||||
# Colors
|
||||
@@ -24,30 +19,30 @@ _WHITE='\033[37m'
|
||||
_END='\033[0m'
|
||||
|
||||
|
||||
test_file=$1
|
||||
source $test_file
|
||||
|
||||
connect_to_telnet="open $host $port"
|
||||
|
||||
|
||||
|
||||
|
||||
methods=(GET POST DELETE GUMBALL)
|
||||
|
||||
#ports=($port ($port + 1))
|
||||
|
||||
https=(HTTP/1.1 HTTP/1.0)
|
||||
|
||||
|
||||
|
||||
run_telnet()
|
||||
start_telnet()
|
||||
{
|
||||
echo "open $host $port"
|
||||
sleep 1
|
||||
echo "$l1"
|
||||
echo "$header"
|
||||
}
|
||||
|
||||
run_telnet()
|
||||
{
|
||||
echo "$connect_to_telnet"
|
||||
sleep 1
|
||||
echo -e "$request"
|
||||
# echo "$l1"
|
||||
# echo "$header"
|
||||
# echo
|
||||
## echo $body
|
||||
# echo $body
|
||||
# echo
|
||||
# echo
|
||||
|
||||
echo
|
||||
echo
|
||||
sleep 1
|
||||
|
||||
@@ -55,69 +50,83 @@ run_telnet()
|
||||
|
||||
}
|
||||
|
||||
run()
|
||||
{
|
||||
echo "$connect_to_telnet"
|
||||
sleep 1
|
||||
|
||||
run_this_test
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
run_a_test()
|
||||
{
|
||||
{
|
||||
echo "----- $test_name -----"
|
||||
echo
|
||||
echo -e "$_RED$request$_END"
|
||||
} &> test.log
|
||||
|
||||
# run_telnet
|
||||
# echo ${pid}
|
||||
# echo -e "$_END---"
|
||||
|
||||
run_telnet | telnet
|
||||
echo -e "$request" | telnet
|
||||
# run_telnet | telnet
|
||||
# run_telnet
|
||||
|
||||
echo
|
||||
echo "----- end of test -----"
|
||||
# echo
|
||||
# echo "----- end of test -----"
|
||||
}
|
||||
|
||||
run_all()
|
||||
{
|
||||
# open_a_connection
|
||||
echo
|
||||
|
||||
# run_a_test | telnet
|
||||
# ./webserv $config_file 2>&1 > webserv.log &
|
||||
|
||||
|
||||
test_to_run="$valid_get"
|
||||
test_name=$valid_get_name
|
||||
|
||||
# l1="$test_to_run"
|
||||
header="Host: $host"
|
||||
body=
|
||||
|
||||
|
||||
#while something i change headers
|
||||
|
||||
for i in "${methods[@]}"
|
||||
do
|
||||
test_name="Test Method $i"
|
||||
l1="$i $path ${https[0]}"
|
||||
expected_result="something"
|
||||
run_a_test
|
||||
echo -e "${_RED}$expected_result${_END}"
|
||||
echo
|
||||
done
|
||||
|
||||
# do a thing where you pass an array as parameter and based on that it
|
||||
# decides which test to run and then you can loop through the arrays you pass
|
||||
|
||||
|
||||
# consider running several tests in a single telnet connection
|
||||
|
||||
# for i in "${methods[@]}"
|
||||
# do
|
||||
# expected_result="something"
|
||||
# run_a_test
|
||||
# echo -e "${_GREEN}$expected_result${_END}"
|
||||
## echo
|
||||
# done
|
||||
|
||||
}
|
||||
|
||||
|
||||
# open telnet localhost 4040
|
||||
# GET / HTTP/1.1
|
||||
# Host: localhost
|
||||
# more header stuff
|
||||
#
|
||||
# maybe a body
|
||||
#######
|
||||
# This is where stuff is launched
|
||||
#######
|
||||
|
||||
rm -rf test.log
|
||||
rm -rf telnet.out
|
||||
|
||||
#./webserv $config_file 2>&1 > webserv.log & run_all
|
||||
#./webserv $config_file 2>&1 > webserv.log &
|
||||
#./webserv $config_file &> /dev/null &
|
||||
./webserv $config_file &> webserv.log &
|
||||
#./webserv $config_file 1>&1 > webserv.log &
|
||||
|
||||
|
||||
#run_all
|
||||
#run_this_test
|
||||
|
||||
echo -e "${_GREEN}Running Telnet Test on '$test_name'${_END}"
|
||||
|
||||
run_all
|
||||
|
||||
|
||||
sleep 1
|
||||
|
||||
run | telnet >> telnet.out
|
||||
#run | telnet
|
||||
|
||||
pkill webserv
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user