a few small fixes here and there, more telnet tests, starting Siege load testing

This commit is contained in:
Eric LAZO
2022-08-16 20:41:57 +02:00
parent ff443c80b1
commit 1b7d388231
17 changed files with 163 additions and 94 deletions

97
Tester/test1.config Normal file
View File

@@ -0,0 +1,97 @@
server {
# this is a comment
server_name server1;
listen 0.0.0.0:4040;
# client_body_limit asdfa;
client_body_limit 5000;
# Max == 18446744073709551615 / 1024 == 18014398509481984
index index.html; # this is another comment
#index mdr.html; # this is another comment
root ./Tester/www/;
error_page 404 ./Tester/www/error_pages/error_404.html;
location / {
allow_methods GET;
root ./Tester/www/;
}
location /srcs/cgi-bin/ {
root ./srcs/cgi-bin/;
allow_methods POST;
cgi_ext php;
}
location /list {
autoindex on;
}
location /cgi-bin {
root ./srcs/cgi-bin/;
cgi_ext out php sh;
}
location /upload {
allow_methods POST;
autoindex on;
upload_dir ./Tester/www/user_files/;
# root doesnt matter if used only with POST and no CGI
}
location /the_dump {
allow_methods GET DELETE;
root ./Tester/www/user_files;
autoindex on;
}
location /redirect {
redirect 307 https://fr.wikipedia.org/wiki/Ketchup;
# redirect 307 https://www.youtube.com/watch?v=rG6b8gjMEkw;
}
location /test {
index index1.html subdex.html;
root ./Tester/www/test/;
}
location /stylesheet {
root ./stylesheet/;
}
location /test/index1.html {
root ./Tester/www/test/index1.html;
index index1.html subdex.html;
}
location /hilarious_404/ {
redirect 301 https://berniesanders.com/404/;
}
location /test/something.html {
# allow_methods DELETE;
root ./Tester/www/test/something.html;
}
location /test/test_deeper/ {
# allow_methods
root ./Tester/www/test/test_deeper/;
}
location /test/test_deeper/super_deep {
root ./Tester/www/test/test_deeper/super_deep/;
}
# location /test/test_deeper/something.html {
# allow_methods DELETE;
# }
}

View File

@@ -2,7 +2,7 @@
test_name="Header Test"
config_file="test1.config"
config_file="./Tester/test1.config"
port=4040
host="localhost"
@@ -41,10 +41,10 @@ run_this_test()
{
echo "----- $test_name -----"
echo -e "$_RED$request$_END"
} >> telnet.out
} >> telnet.log
echo -e "$request"
sleep 1
echo -e "\n\n" >> telnet.out
echo -e "\n\n" >> telnet.log
done
}

View File

@@ -2,7 +2,7 @@
test_name="Method Test"
config_file="test1.config"
config_file="./Tester/test1.config"
port=4040
host="localhost"
@@ -41,10 +41,10 @@ run_this_test()
{
echo "----- $test_name -----"
echo -e "$_RED$request$_END"
} >> telnet.out
} >> telnet.log
echo -e "$request"
sleep 1
echo -e "\n\n" >> telnet.out
echo -e "\n\n" >> telnet.log
done
}

View File

@@ -2,7 +2,7 @@
test_name="Path Test"
config_file="test1.config"
config_file="./Tester/test1.config"
port=4040
host="localhost"
@@ -31,7 +31,6 @@ run_this_test()
echo "----- $test_name -----"
echo -e "$_RED$request$_END"
} >> telnet.log
# echo -e "$request" > compare.txt >> telnet.out
echo -e "$request"
sleep 1
echo -e "\n" >> telnet.log

View File

@@ -2,7 +2,7 @@
test_name="Template test all good"
config_file="default.config"
config_file="./Tester/test1.config"
port=4040
host="localhost"
@@ -35,7 +35,7 @@ run_this_test()
{
echo "----- $test_name -----"
echo -e "$_RED$request$_END"
} >> telnet.out
} >> telnet.log
# } &>> test.log
# } 2>>&1
# } &>> /dev/stdout
@@ -47,7 +47,7 @@ run_this_test()
# } > /dev/stdout
# echo -e "\n\n\n------\n\n\n" >> telnet.out
# echo -e "\n\n\n------\n\n\n" &> /dev/stdout
echo -e "\n\n" >> telnet.out
echo -e "\n\n" >> telnet.log
# echo -e "\n\n------\n\n" >> telnet.out
# echo -e "\n------\n" > /dev/stdout
# run_a_test

74
Tester/test_valid_uri.sh Normal file
View File

@@ -0,0 +1,74 @@
#! /bin/bash
test_name="Valid URIs Test"
config_file="./Tester/test1.config"
port=4040
host="localhost"
paths=("/" "/stylesheet/style.css" "/test/something.html" "/test/something.html/" "/test/" "/list" "/hilarious_404" "/redirect") # 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"
body=
run_this_test()
{
for i in "${paths[@]}"
do
l1="${methods[0]} $i ${httpz[0]}"
request="$l1\n$header\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_valid_uri_test.txt"
files+=("expected_valid_files_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

View File

@@ -2,9 +2,7 @@
<html>
<head>
<title>Webserv test index</title>
<!-- <link rel="stylesheet" href="stylesheet/style.css"> -->
<link rel="stylesheet" href="/stylesheet/style.css">
</head>
<body>
<h1>Webserv Test Index</h1>