Files
42_INT_12_webserv/telnet_test.sh
2022-08-13 22:38:31 +02:00

132 lines
1.3 KiB
Bash
Executable File

#! /bin/bash
# you need to put absolutely everything in ""
#port="80"
port="4040"
path="/"
#host="duckduckgo.com"
host="localhost"
##########
# Colors
##########
_GREY='\033[30m'
_RED='\033[0;31m'
_GREEN='\033[32m'
_YELLOW='\033[33m'
_BLUE='\033[34m'
_PURPLE='\033[35m'
_CYAN='\033[36m'
_WHITE='\033[37m'
_END='\033[0m'
methods=(GET POST DELETE GUMBALL)
#ports=($port ($port + 1))
https=(HTTP/1.1 HTTP/1.0)
run_telnet()
{
echo "open $host $port"
sleep 1
echo "$l1"
echo "$header"
# echo
## echo $body
# echo
# echo
echo
echo
sleep 1
# ret = $(arg | telnet)
}
run_a_test()
{
echo "----- $test_name -----"
echo
# run_telnet
# echo ${pid}
run_telnet | telnet
# run_telnet
echo
echo "----- end of test -----"
}
run_all()
{
# open_a_connection
# run_a_test | telnet
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
# consider running several tests in a single telnet connection
}
# open telnet localhost 4040
# GET / HTTP/1.1
# Host: localhost
# more header stuff
#
# maybe a body
run_all