baseline tests of Telnet Test are ready

This commit is contained in:
Eric LAZO
2022-08-17 20:44:17 +02:00
parent 72b12132d4
commit 3763249a3e
15 changed files with 324 additions and 33 deletions

View File

@@ -0,0 +1,29 @@
telnet> Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 405 Method Not Allowed
Allow: GET
Content-Type: text/html; charset=UTF-8
Content-Length: 199
<!DOCTYPE html><html><head><title>405 Method Not Allowed</title></head><body><h1 style="text-align:center">405 Method Not Allowed</h1><hr><p style="text-align:center">Le Webserv/0.1</p></body></html>HTTP/1.1 204 No Content
Server: Webserv/0.1
Connection: keep-alive
HTTP/1.1 404 Not Found
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Content-Length: 210
<!DOCTYPE html>
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1 style="text-align:center">Check it UP 404 Not Found</h1>
<hr>
<p style=\"text-align:center\">Le Webserv/0.1</p>
</body>
</html>

View File

@@ -0,0 +1,15 @@
telnet> Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 501 Not Implemented
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Content-Length: 193
<!DOCTYPE html><html><head><title>501 Not Implemented</title></head><body><h1 style="text-align:center">501 Not Implemented</h1><hr><p style="text-align:center">Le Webserv/0.1</p></body></html>HTTP/1.1 415 Unsupported Media Type
Accept-Encoding:
Content-Type: text/html; charset=UTF-8
Content-Length: 207
<!DOCTYPE html><html><head><title>415 Unsupported Media Type</title></head><body><h1 style="text-align:center">415 Unsupported Media Type</h1><hr><p style="text-align:center">Le Webserv/0.1</p></body></html>

View File

@@ -0,0 +1,37 @@
telnet> Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 200 OK
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Content-Length: 193
<!DOCTYPE html>
<html>
<head>
<title>Le Webserv</title>
</head>
<body>
<h1 style="text-align:center">Le index (˘ ͜ʖ˘)</h1>
<hr>
<p style="text-align:center">(˚3˚)</p>
</body>
</html>
HTTP/1.1 405 Method Not Allowed
Allow: GET
Content-Type: text/html; charset=UTF-8
Content-Length: 199
<!DOCTYPE html><html><head><title>405 Method Not Allowed</title></head><body><h1 style="text-align:center">405 Method Not Allowed</h1><hr><p style="text-align:center">Le Webserv/0.1</p></body></html>HTTP/1.1 405 Method Not Allowed
Allow: GET
Content-Type: text/html; charset=UTF-8
Content-Length: 199
<!DOCTYPE html><html><head><title>405 Method Not Allowed</title></head><body><h1 style="text-align:center">405 Method Not Allowed</h1><hr><p style="text-align:center">Le Webserv/0.1</p></body></html>HTTP/1.1 501 Not Implemented
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Content-Length: 193
<!DOCTYPE html><html><head><title>501 Not Implemented</title></head><body><h1 style="text-align:center">501 Not Implemented</h1><hr><p style="text-align:center">Le Webserv/0.1</p></body></html>

View File

@@ -22,15 +22,13 @@ HTTP/1.1 200 OK
Server: Webserv/0.1 Server: Webserv/0.1
Connection: keep-alive Connection: keep-alive
Content-Type: text/html; charset=UTF-8 Content-Type: text/html; charset=UTF-8
Content-Length: 290 Content-Length: 227
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Webserv test index</title> <title>Webserv test index</title>
<!-- <link rel="stylesheet" href="stylesheet/style.css"> -->
<link rel="stylesheet" href="/stylesheet/style.css"> <link rel="stylesheet" href="/stylesheet/style.css">
</head> </head>
<body> <body>
<h1>Webserv Test Index</h1> <h1>Webserv Test Index</h1>
@@ -42,15 +40,13 @@ HTTP/1.1 200 OK
Server: Webserv/0.1 Server: Webserv/0.1
Connection: keep-alive Connection: keep-alive
Content-Type: text/html; charset=UTF-8 Content-Type: text/html; charset=UTF-8
Content-Length: 290 Content-Length: 227
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Webserv test index</title> <title>Webserv test index</title>
<!-- <link rel="stylesheet" href="stylesheet/style.css"> -->
<link rel="stylesheet" href="/stylesheet/style.css"> <link rel="stylesheet" href="/stylesheet/style.css">
</head> </head>
<body> <body>
<h1>Webserv Test Index</h1> <h1>Webserv Test Index</h1>
@@ -58,13 +54,13 @@ Content-Length: 290
<p style="text-align:center">(˚3˚)</p> <p style="text-align:center">(˚3˚)</p>
</body> </body>
</html> </html>
HTTP/1.1 HTTP/1.1 200 OK
Server: Webserv/0.1 Server: Webserv/0.1
Connection: keep-alive Connection: keep-alive
Content-Type: text/html; charset=UTF-8 Content-Type: text/html; charset=UTF-8
Content-Length: 1277 Content-Length: 1281
<!DOCTYPE html><html><head><title>Index of ./Tester/www/</title></head><body><h1>Index of ./Tester/www/</h1><hr><pre><a style="font-size:1.5em" href="/list/..">..</a> <!DOCTYPE html><html><head><title>Index of ./Tester/www/</title></head><body><h1>Index of ./Tester/www/</h1><hr><pre><a style="font-size:1.5em" href="/list/..">../</a>
<a style="font-size:1.5em" href="/list/upload_form.html">upload_form.html</a> <a style="font-size:1.5em" href="/list/upload_form.html">upload_form.html</a>
<a style="font-size:1.5em" href="/list/form_get.html">form_get.html</a> <a style="font-size:1.5em" href="/list/form_get.html">form_get.html</a>
<a style="font-size:1.5em" href="/list/kermit.ico">kermit.ico</a> <a style="font-size:1.5em" href="/list/kermit.ico">kermit.ico</a>
@@ -72,14 +68,14 @@ Content-Length: 1277
<a style="font-size:1.5em" href="/list/Cagneyc_intro.gif">Cagneyc_intro.gif</a> <a style="font-size:1.5em" href="/list/Cagneyc_intro.gif">Cagneyc_intro.gif</a>
<a style="font-size:1.5em" href="/list/Van_Eyck_Portrait_Arnolfini.jpg">Van_Eyck_Portrait_Arnolfini.jpg</a> <a style="font-size:1.5em" href="/list/Van_Eyck_Portrait_Arnolfini.jpg">Van_Eyck_Portrait_Arnolfini.jpg</a>
<a style="font-size:1.5em" href="/list/root.png">root.png</a> <a style="font-size:1.5em" href="/list/root.png">root.png</a>
<a style="font-size:1.5em" href="/list/test">test</a> <a style="font-size:1.5em" href="/list/test">test/</a>
<a style="font-size:1.5em" href="/list/drill.jpg">drill.jpg</a> <a style="font-size:1.5em" href="/list/drill.jpg">drill.jpg</a>
<a style="font-size:1.5em" href="/list/punpun.png">punpun.png</a> <a style="font-size:1.5em" href="/list/punpun.png">punpun.png</a>
<a style="font-size:1.5em" href="/list/favicon.ico">favicon.ico</a> <a style="font-size:1.5em" href="/list/favicon.ico">favicon.ico</a>
<a style="font-size:1.5em" href="/list/index.html">index.html</a> <a style="font-size:1.5em" href="/list/index.html">index.html</a>
<a style="font-size:1.5em" href="/list/rfc2119.html">rfc2119.html</a> <a style="font-size:1.5em" href="/list/rfc2119.html">rfc2119.html</a>
<a style="font-size:1.5em" href="/list/error_pages">error_pages</a> <a style="font-size:1.5em" href="/list/error_pages">error_pages/</a>
<a style="font-size:1.5em" href="/list/rfc2119_files">rfc2119_files</a> <a style="font-size:1.5em" href="/list/rfc2119_files">rfc2119_files/</a>
</pre><hr></body></html>HTTP/1.1 404 Not Found </pre><hr></body></html>HTTP/1.1 404 Not Found
Server: Webserv/0.1 Server: Webserv/0.1
Connection: keep-alive Connection: keep-alive

View File

@@ -0,0 +1,110 @@
telnet> Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 200 OK
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Content-Length: 193
<!DOCTYPE html>
<html>
<head>
<title>Le Webserv</title>
</head>
<body>
<h1 style="text-align:center">Le index (˘ ͜ʖ˘)</h1>
<hr>
<p style="text-align:center">(˚3˚)</p>
</body>
</html>
HTTP/1.1 200 OK
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/css; charset=UTF-8
Content-Length: 43
h1 {
color: red;
text-align: center;
}
HTTP/1.1 200 OK
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Content-Length: 207
<!DOCTYPE html>
<html>
<head>
<title>Webserv test Something</title>
</head>
<body>
<h1 style="text-align:center">Webserv Test Something</h1>
<hr>
<p style="text-align:center">(˚3˚)</p>
</body>
</html>
HTTP/1.1 200 OK
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Content-Length: 207
<!DOCTYPE html>
<html>
<head>
<title>Webserv test Something</title>
</head>
<body>
<h1 style="text-align:center">Webserv Test Something</h1>
<hr>
<p style="text-align:center">(˚3˚)</p>
</body>
</html>
HTTP/1.1 200 OK
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Content-Length: 227
<!DOCTYPE html>
<html>
<head>
<title>Webserv test index</title>
<link rel="stylesheet" href="/stylesheet/style.css">
</head>
<body>
<h1>Webserv Test Index</h1>
<hr>
<p style="text-align:center">(˚3˚)</p>
</body>
</html>
HTTP/1.1 200 OK
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Content-Length: 1281
<!DOCTYPE html><html><head><title>Index of ./Tester/www/</title></head><body><h1>Index of ./Tester/www/</h1><hr><pre><a style="font-size:1.5em" href="/list/..">../</a>
<a style="font-size:1.5em" href="/list/upload_form.html">upload_form.html</a>
<a style="font-size:1.5em" href="/list/form_get.html">form_get.html</a>
<a style="font-size:1.5em" href="/list/kermit.ico">kermit.ico</a>
<a style="font-size:1.5em" href="/list/upload_form_single.html">upload_form_single.html</a>
<a style="font-size:1.5em" href="/list/Cagneyc_intro.gif">Cagneyc_intro.gif</a>
<a style="font-size:1.5em" href="/list/Van_Eyck_Portrait_Arnolfini.jpg">Van_Eyck_Portrait_Arnolfini.jpg</a>
<a style="font-size:1.5em" href="/list/root.png">root.png</a>
<a style="font-size:1.5em" href="/list/test">test/</a>
<a style="font-size:1.5em" href="/list/drill.jpg">drill.jpg</a>
<a style="font-size:1.5em" href="/list/punpun.png">punpun.png</a>
<a style="font-size:1.5em" href="/list/favicon.ico">favicon.ico</a>
<a style="font-size:1.5em" href="/list/index.html">index.html</a>
<a style="font-size:1.5em" href="/list/rfc2119.html">rfc2119.html</a>
<a style="font-size:1.5em" href="/list/error_pages">error_pages/</a>
<a style="font-size:1.5em" href="/list/rfc2119_files">rfc2119_files/</a>
</pre><hr></body></html>HTTP/1.1 301 Moved Permanently
Location: https://berniesanders.com/404/
HTTP/1.1 307 Temporary Redirect
Location: https://fr.wikipedia.org/wiki/Ketchup

View File

@@ -25,6 +25,16 @@ server {
root ./Tester/www/; root ./Tester/www/;
} }
location /to_delete.txt {
allow_methods GET DELETE;
root ./Tester/www/to_delete.txt;
}
location /i_do_not_exist.txt {
allow_methods GET DELETE;
root ./Tester/www/to_delete.txt;
}
location /srcs/cgi-bin/ { location /srcs/cgi-bin/ {
root ./srcs/cgi-bin/; root ./srcs/cgi-bin/;
allow_methods POST; allow_methods POST;

View File

@@ -25,7 +25,7 @@ body+="this is a message this is a message this is a message this is a message t
#header_cycle=("Content-Length: 17\n" "\n") #header_cycle=("Content-Length: 17\n" "\n")
#header_cycle=("Content-Length: 17\n") #header_cycle=("Content-Length: 17\n")
#header_cycle=() #header_cycle=()
#header+="Content-Length: 8\n" header+="Content-Length: 8\n"
run_this_test() run_this_test()
{ {

75
Tester/test_delete.sh Normal file
View File

@@ -0,0 +1,75 @@
#! /bin/bash
test_name="Delete Test"
config_file="./Tester/test1.config"
port=4040
host="localhost"
#paths=("/" "/test" "/test/" "/list" "list" "/wrong") # you can add many
paths=("/" "/to_delete.txt" "/i_do_not_exist.txt") # you can add many
#methods=("GET" "POST" "DELETE")
methods=("DELETE")
httpz=("HTTP/1.1")
l1="${methods[0]} ${paths[0]} ${httpz[0]}"
header="Host: $host"
body=
run_this_test()
{
echo "we will delete" > ./Tester/www/to_delete.txt
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_delete_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

@@ -17,7 +17,6 @@ httpz=("HTTP/1.1")
# the parts we will send to webserv # the parts we will send to webserv
# let main.sh handle the l1
@@ -26,8 +25,6 @@ header+="Nonsense: fu\n"
#header_cycle=("Transfer-encoding: fu" "Content-encoding: fu") #header_cycle=("Transfer-encoding: fu" "Content-encoding: fu")
#header+="Transfer-encoding: fu\n"
#header+="Content-endcoding: fu\n"
body= body=

View File

@@ -16,7 +16,7 @@ httpz=("HTTP/1.1")
l1="${methods[0]} ${paths[0]} ${httpz[0]}" l1="${methods[0]} ${paths[0]} ${httpz[0]}"
header="Host: $host" header="Host: $host\n"
body= body=

View File

@@ -45,8 +45,7 @@ run_this_test()
files=() files=()
file="expected_path_test.txt" file="expected_port_test.txt"
files+=("expected_path_test.txt")
#files+=("expected_path_root_test.txt") #files+=("expected_path_root_test.txt")
#files+=("expected_path_testnoslash_test.txt") #files+=("expected_path_testnoslash_test.txt")
#files+=("expected_path_testslash_test.txt") #files+=("expected_path_testslash_test.txt")

View File

@@ -1,4 +1,29 @@
telnet> Trying 127.0.0.1... telnet> Trying 127.0.0.1...
telnet> ?Invalid command Connected to localhost.
telnet> ?Invalid command Escape character is '^]'.
telnet> telnet> telnet> HTTP/1.1 405 Method Not Allowed
Allow: GET
Content-Type: text/html; charset=UTF-8
Content-Length: 199
<!DOCTYPE html><html><head><title>405 Method Not Allowed</title></head><body><h1 style="text-align:center">405 Method Not Allowed</h1><hr><p style="text-align:center">Le Webserv/0.1</p></body></html>HTTP/1.1 204 No Content
Server: Webserv/0.1
Connection: keep-alive
HTTP/1.1 404 Not Found
Server: Webserv/0.1
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Content-Length: 210
<!DOCTYPE html>
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1 style="text-align:center">Check it UP 404 Not Found</h1>
<hr>
<p style=\"text-align:center\">Le Webserv/0.1</p>
</body>
</html>

View File

@@ -11,12 +11,14 @@ server {
client_body_limit 5000; client_body_limit 5000;
# Max == 18446744073709551615 / 1024 == 18014398509481984 # Max == 18446744073709551615 / 1024 == 18014398509481984
index index.html; # this is another comment index index.html; # this is another comment
#index mdr.html; # this is another comment #index mdr.html; # this is another comment
root ./www/; root ./www/;
error_page 404 ./www/error_pages/error_404.html; error_page 404 ./www/error_pages/error_404.html;
# error_page 403 ./www/error_pages/error_404.html;
@@ -103,10 +105,6 @@ server {
index something.html; index something.html;
} }
# location /test/test_deeper/something.html {
# allow_methods DELETE;
# }
} }
server { server {

View File

@@ -21,11 +21,13 @@ _END='\033[0m'
#test_file_names=("test_template.sh" "test_header.sh" "test_path.sh") #test_file_names=("test_template.sh" "test_header.sh" "test_path.sh")
#test_file_names=("test_method.sh" "test_header.sh" "test_path.sh") test_file_names=("test_method.sh" "test_header.sh" "test_path.sh" "test_valid_uri.sh" "test_delete.sh")
test_file_names=("test_port.sh")
# Run this separately cuz of the content length subtlty
#test_file_names=("test_body.sh") #test_file_names=("test_body.sh")
#test_file_names=("test_valid_uri.sh")
#test_file_names=("test_path.sh") # kinda fucking useless, easier to test IRL
#test_file_names=("test_port.sh")
test_files=() test_files=()
expected_result_files=() expected_result_files=()
@@ -54,7 +56,6 @@ test_all()
{ {
arg=${1} arg=${1}
c=0
make make
@@ -102,8 +103,6 @@ test_all()
cat compare.txt > $expected_result_file cat compare.txt > $expected_result_file
fi fi
c+=1
done done
if [ "$arg" = "" ]; if [ "$arg" = "" ];

1
www/to_delete.txt Normal file
View File

@@ -0,0 +1 @@
we will delete