From 2f18e21ef53a82397bc5021b669946375b8fb70e Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 15 Jan 2023 22:16:11 +0900 Subject: [PATCH] added a cgi test case --- t/s-001.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/t/s-001.sh b/t/s-001.sh index 271f20f..daf57ce 100644 --- a/t/s-001.sh +++ b/t/s-001.sh @@ -62,7 +62,7 @@ test_file_list_dir() test_cgi() { - local msg="hio-webs file-list-dir" + local msg="hio-webs cgi" local srvaddr=127.0.0.1:54321 local tmpdir="/tmp/s-001.$$" @@ -74,9 +74,29 @@ test_cgi() local jid=$! sleep 0.5 - local hc=$(curl -s -w '%{http_code}\n' -o /dev/null "http://${srvaddr}/t.cgi?abc=def#qq") + local hc=$(curl -s -w '%{http_code}\n' -o "${tmpdir}/t.out" "http://${srvaddr}/t.cgi?abc=def ") tap_ensure "$hc" "200" "$msg - got $hc" + local request_method=$(grep -E "^REQUEST_METHOD:" "${tmpdir}/t.out" | cut -d: -f2) + local request_uri=$(grep -E "^REQUEST_URI:" "${tmpdir}/t.out" | cut -d: -f2) + local query_string=$(grep -E "^QUERY_STRING:" "${tmpdir}/t.out" | cut -d: -f2) + + tap_ensure "$request_method", "GET", "$msg - request_method" + tap_ensure "$request_uri", "/t.cgi", "$msg - request_uri" + tap_ensure "$query_string", "abc=def", "$msg - query_string" + + local hc=$(curl -s -w '%{http_code}\n' -X POST --data-binary "hello world" -o "${tmpdir}/t.out" "http://${srvaddr}/t.cgi?abc=def ") + tap_ensure "$hc" "200" "$msg - got $hc" + + local request_method=$(grep -E "^REQUEST_METHOD:" "${tmpdir}/t.out" | cut -d: -f2) + local request_uri=$(grep -E "^REQUEST_URI:" "${tmpdir}/t.out" | cut -d: -f2) + local query_string=$(grep -E "^QUERY_STRING:" "${tmpdir}/t.out" | cut -d: -f2) + + tap_ensure "$request_method", "POST", "$msg - request_method" + tap_ensure "$request_uri", "/t.cgi", "$msg - request_uri" + tap_ensure "$query_string", "abc=def", "$msg - query_string" + +## TODO: write more... rm -rf "${tmpdir}" kill -TERM ${jid}