-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·54 lines (49 loc) · 4.37 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·54 lines (49 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
set -eu
cd "$(dirname "$0")"
key="selftest-$$"
count_dir=$(mktemp -d "${TMPDIR:-/tmp}/awkward-counts.XXXXXX")
place_dir=$(mktemp -d "${TMPDIR:-/tmp}/awkward-place.XXXXXX")
guestbook_dir=$(mktemp -d "${TMPDIR:-/tmp}/awkward-guestbook.XXXXXX")
trap 'rm -rf "$count_dir" "$place_dir" "$guestbook_dir"' EXIT
env INCREM_DATA_DIR="$count_dir" REQUEST_METHOD=GET QUERY_STRING="key=$key" ./cgi-bin/increment.awk | grep -q ">0<"
env INCREM_DATA_DIR="$count_dir" REQUEST_METHOD=POST QUERY_STRING="key=$key" ./cgi-bin/increment.awk | grep -q ">1<"
env INCREM_DATA_DIR="$count_dir" REQUEST_METHOD=GET QUERY_STRING="key=../../bad key" ./cgi-bin/increment.awk | grep -q "/cgi-bin/increment.awk?key=.._.._bad_key"
env INCREM_DATA_DIR="$count_dir" REQUEST_METHOD=DELETE QUERY_STRING="key=$key" ./cgi-bin/increment.awk | grep -q "405 Method Not Allowed"
for _ in 1 2 3 4 5 6 7 8 9 10; do
env INCREM_DATA_DIR="$count_dir" REQUEST_METHOD=POST QUERY_STRING="key=$key" ./cgi-bin/increment.awk >/dev/null &
done
wait
env INCREM_DATA_DIR="$count_dir" REQUEST_METHOD=GET QUERY_STRING="key=$key" ./cgi-bin/increment.awk | grep -q ">11<"
env PLACE_DATA_DIR="$place_dir" REQUEST_METHOD=GET QUERY_STRING="" ./cgi-bin/place.awk | grep -q "Location: /"
env PLACE_DATA_DIR="$place_dir" REQUEST_METHOD=GET QUERY_STRING="x=2&y=3&c=R" ./cgi-bin/place.awk | grep -q "405 Method Not Allowed"
env PLACE_DATA_DIR="$place_dir" REQUEST_METHOD=POST QUERY_STRING="x=2&y=3&c=R" ./cgi-bin/place.awk | grep -q "ok"
awk 'NR == 4 { ok = (substr($0, 3, 1) == "R") } END { exit ok ? 0 : 1 }' "$place_dir/badge.txt"
env PLACE_DATA_DIR="$place_dir" REQUEST_METHOD=GET QUERY_STRING="badge=1" ./cgi-bin/place.awk | grep -q "Content-Type: image/svg+xml"
env PLACE_DATA_DIR="$place_dir" REQUEST_METHOD=POST QUERY_STRING="x=88&y=3&c=R" ./cgi-bin/place.awk | grep -q "400 Bad Request"
(env PLACE_DATA_DIR="$place_dir" REQUEST_METHOD=POST QUERY_STRING="x=4&y=4&c=G" ./cgi-bin/place.awk >/dev/null) &
(env PLACE_DATA_DIR="$place_dir" REQUEST_METHOD=POST QUERY_STRING="x=5&y=4&c=B" ./cgi-bin/place.awk >/dev/null) &
wait
awk 'NR == 5 { ok = (substr($0, 5, 1) == "G" && substr($0, 6, 1) == "B") } END { exit ok ? 0 : 1 }' "$place_dir/badge.txt"
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=GET QUERY_STRING="" ./cgi-bin/guestbook.awk | grep -q "No entries yet"
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=GET QUERY_STRING="name=Me&date=2026-07-05&message=Hello+awk" ./cgi-bin/guestbook.awk | grep -q "No entries yet"
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=POST QUERY_STRING="name=Me&date=2026-07-05&message=Hello+awk" ./cgi-bin/guestbook.awk | grep -q "2026-07-05"
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=GET QUERY_STRING="" ./cgi-bin/guestbook.awk | grep -q "Hello awk"
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=POST QUERY_STRING='name=%3Cme%3E&message=%3Cscript%3E' ./cgi-bin/guestbook.awk | grep -q "<script>"
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=POST QUERY_STRING="name=Me&message=" ./cgi-bin/guestbook.awk | grep -q "400 Bad Request"
(env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=POST QUERY_STRING="name=A&message=one" ./cgi-bin/guestbook.awk >/dev/null) &
(env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=POST QUERY_STRING="name=B&message=two" ./cgi-bin/guestbook.awk >/dev/null) &
wait
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=GET QUERY_STRING="" ./cgi-bin/guestbook.awk | grep -q "one"
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=GET QUERY_STRING="" ./cgi-bin/guestbook.awk | grep -q "two"
for n in 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025; do
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=POST QUERY_STRING="name=T&message=m$n" ./cgi-bin/guestbook.awk >/dev/null
done
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=GET QUERY_STRING="" ./cgi-bin/guestbook.awk | grep -q "m025"
if env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=GET QUERY_STRING="" ./cgi-bin/guestbook.awk | grep -q "m001"; then
exit 1
fi
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=GET QUERY_STRING="full=1" ./cgi-bin/guestbook.awk | grep -q "<!doctype html>"
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=GET QUERY_STRING="full=1" ./cgi-bin/guestbook.awk | grep -q "m001"
env GUESTBOOK_DATA_DIR="$guestbook_dir" REQUEST_METHOD=GET QUERY_STRING="full=1" ./cgi-bin/guestbook.awk | grep -q "m025"
echo "ok"