Files
42_INT_12_webserv/Tester/test_body.sh
2022-08-16 23:54:30 +02:00

85 lines
4.4 KiB
Bash

#! /bin/bash
test_name="Body Test"
config_file="./Tester/test2.config"
port=4040
host="localhost"
#paths=("/" "/test" "/test/" "/list" "list" "/wrong") # you can add many
paths=("/") # you can add many
#methods=("GET" "POST" "DELETE")
methods=("GET")
httpz=("HTTP/1.1")
l1="${methods[0]} ${paths[0]} ${httpz[0]}"
header="Host: $host\n"
body="this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message this is a message \n"
# turns out this does nothing...
#header_cycle=("Content-Length: 17" "Content-Length: 14" "Content-Length: 25")
#header_cycle=("Content-Length: 17" "")
#header_cycle=("Content-Length: 17")
#header_cycle=()
header+="Content-Length: 15"
run_this_test()
{
# for i in "${header_cycle[@]}"
for i in "${paths[@]}"
do
# l1="${methods[0]} ${paths[0]} ${httpz[0]}"
l1="${methods[0]} $i ${httpz[0]}"
# header_send="$header$i"
header_send="$header"
request="$l1\n$header_send\n\n$body\n"
{
echo "----- $test_name -----"
echo -e "$_RED$request$_END"
} >> telnet.log
echo -e "$request"
sleep 1
echo -e "\n" >> telnet.log
done
}
# expected result...
files=()
file="expected_body_test.txt"
files+=("expected_body_test.txt")
#files+=("expected_path_root_test.txt")
#files+=("expected_path_testnoslash_test.txt")
#files+=("expected_path_testslash_test.txt")
#files+=("expected_path_list_test.txt")
#files+=("expected_path_badlist_test.txt")
#files+=("expected_path_wrong_test.txt")
#local_expected_test_file=$file
local_expected_test_files=()
test_path=""
add_path()
{
for i in "${files[@]}"
do
local_expected_test_files+=("$test_path$i")
done
}
#add_path