89 lines
4.6 KiB
Bash
89 lines
4.6 KiB
Bash
#! /bin/bash
|
|
|
|
test_name="Body Test"
|
|
|
|
config_file="./Tester/test2.config"
|
|
port=8080
|
|
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 \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\n" "Content-Length: 14" "Content-Length: 25")
|
|
#header_cycle=("Content-Length: 17\n" "\n")
|
|
#header_cycle=("Content-Length: 17\n")
|
|
#header_cycle=()
|
|
#header+="Content-Length: 8\n"
|
|
|
|
run_this_test()
|
|
{
|
|
echo size is ${#body} >> telnet.log
|
|
|
|
# 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"
|
|
## if you add an extra \n after header send you get a status code 200 OK and 400 bad request, but like both
|
|
# request="$l1\n$header_send\n$body\n"
|
|
request="$l1\n$header_send\n$body"
|
|
{
|
|
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
|
|
|
|
|
|
|
|
|