diff --git a/test1.config b/Tester/test1.config similarity index 92% rename from test1.config rename to Tester/test1.config index fc03ed6..e245aaa 100644 --- a/test1.config +++ b/Tester/test1.config @@ -63,8 +63,12 @@ server { root ./Tester/www/test/; } + location /stylesheet { + root ./stylesheet/; + } + location /test/index1.html { - root ./Tester/www/test/; + root ./Tester/www/test/index1.html; index index1.html subdex.html; } @@ -72,14 +76,9 @@ server { redirect 301 https://berniesanders.com/404/; } - location /stylesheet/ { -# root ./www/../; - root ./styelsheet/; - } - location /test/something.html { # allow_methods DELETE; - root ./Tester/www/test/; + root ./Tester/www/test/something.html; } location /test/test_deeper/ { diff --git a/Tester/test_header.sh b/Tester/test_header.sh index 8f8e5ef..60f7974 100644 --- a/Tester/test_header.sh +++ b/Tester/test_header.sh @@ -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 } diff --git a/Tester/test_method.sh b/Tester/test_method.sh index 076d7eb..ca0fb43 100644 --- a/Tester/test_method.sh +++ b/Tester/test_method.sh @@ -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 } diff --git a/Tester/test_path.sh b/Tester/test_path.sh index 3439313..ffd4417 100644 --- a/Tester/test_path.sh +++ b/Tester/test_path.sh @@ -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 diff --git a/Tester/test_template.sh b/Tester/test_template.sh index ffb11e3..99a9821 100644 --- a/Tester/test_template.sh +++ b/Tester/test_template.sh @@ -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 diff --git a/Tester/test_valid_uri.sh b/Tester/test_valid_uri.sh new file mode 100644 index 0000000..ba273a5 --- /dev/null +++ b/Tester/test_valid_uri.sh @@ -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 + + + + diff --git a/Tester/www/test/index1.html b/Tester/www/test/index1.html index f976302..e6ee456 100644 --- a/Tester/www/test/index1.html +++ b/Tester/www/test/index1.html @@ -2,9 +2,7 @@
(˚3˚)
@@ -42,15 +49,30 @@ HTTP/1.1 200 OK Server: Webserv/0.1 Connection: keep-alive Content-Type: text/html; charset=UTF-8 -Content-Length: 290 +Content-Length: 207 + + + + +(˚3˚)
+ + +HTTP/1.1 200 OK +Server: Webserv/0.1 +Connection: keep-alive +Content-Type: text/html; charset=UTF-8 +Content-Length: 227(˚3˚)
-HTTP/1.1 +HTTP/1.1 200 OK Server: Webserv/0.1 Connection: keep-alive Content-Type: text/html; charset=UTF-8 @@ -80,37 +102,13 @@ Content-Length: 1277 rfc2119.html error_pages rfc2119_files -