| 1 |
#!/bin/sh |
|---|
| 2 |
|
|---|
| 3 |
home=/Users/erdnase/www/10kz/shell |
|---|
| 4 |
webclient="lynx --source" |
|---|
| 5 |
#port=5555 |
|---|
| 6 |
port=6667 |
|---|
| 7 |
#server_pattern="[F]iz" |
|---|
| 8 |
server_pattern="[m]ini_httpd" |
|---|
| 9 |
|
|---|
| 10 |
cd $home |
|---|
| 11 |
|
|---|
| 12 |
echo |
|---|
| 13 |
let success=0 |
|---|
| 14 |
let fail=0 |
|---|
| 15 |
|
|---|
| 16 |
###### TEST ######################## |
|---|
| 17 |
|
|---|
| 18 |
ps aux | grep $server_pattern > /dev/null |
|---|
| 19 |
webserver_running=`echo $?` |
|---|
| 20 |
|
|---|
| 21 |
if [ $webserver_running = 0 ] |
|---|
| 22 |
then |
|---|
| 23 |
let success++ |
|---|
| 24 |
echo PASS: webserver is running |
|---|
| 25 |
else |
|---|
| 26 |
let fail++ |
|---|
| 27 |
echo FAIL: webserver is running |
|---|
| 28 |
fi |
|---|
| 29 |
|
|---|
| 30 |
###### TEST ######################## |
|---|
| 31 |
|
|---|
| 32 |
root=/Users/erdnase/www/10kz |
|---|
| 33 |
cd $root |
|---|
| 34 |
$webclient http://localhost:$port/test.html > test-test.html |
|---|
| 35 |
diff test-test.html shell/test.html |
|---|
| 36 |
webserver_serving_static_pages=`echo $?` |
|---|
| 37 |
rm -f test-test.html |
|---|
| 38 |
|
|---|
| 39 |
if [ $webserver_serving_static_pages = 0 ] |
|---|
| 40 |
then |
|---|
| 41 |
let success++ |
|---|
| 42 |
echo PASS: webserver serving static pages |
|---|
| 43 |
else |
|---|
| 44 |
let fail++ |
|---|
| 45 |
echo FAIL: webserver serving static pages |
|---|
| 46 |
fi |
|---|
| 47 |
|
|---|
| 48 |
###### TEST ######################## |
|---|
| 49 |
|
|---|
| 50 |
$webclient http://localhost:$port/test-cgi.jm3 > test-cgi.html |
|---|
| 51 |
diff test-cgi.html tests/test-cgi-ouput.html |
|---|
| 52 |
webserver_serving_CGIs=$? |
|---|
| 53 |
rm -f test-cgi.html |
|---|
| 54 |
|
|---|
| 55 |
if [ $webserver_serving_CGIs = 0 ] |
|---|
| 56 |
then |
|---|
| 57 |
let success++ |
|---|
| 58 |
echo PASS: webserver serving CGIs |
|---|
| 59 |
else |
|---|
| 60 |
let fail++ |
|---|
| 61 |
echo FAIL: webserver serving CGIs |
|---|
| 62 |
fi |
|---|
| 63 |
|
|---|
| 64 |
###### TEST ######################## |
|---|
| 65 |
|
|---|
| 66 |
shell/url-decode.sh "foo.com?p1=simple&p2=two+params¶m3=three+more%20params¶m4=http%3A%2F%2Fencoded-url&punct=%25%5E%26" > tmp-decoded-params.txt |
|---|
| 67 |
diff tests/params-decoded.txt tmp-decoded-params.txt |
|---|
| 68 |
decoded_params_match_test_case=$? |
|---|
| 69 |
rm -f tmp-decoded-params.txt |
|---|
| 70 |
|
|---|
| 71 |
if [ $decoded_params_match_test_case -eq 0 ] |
|---|
| 72 |
then |
|---|
| 73 |
let success++ |
|---|
| 74 |
echo PASS: decode encoded GET request parameters in the shell |
|---|
| 75 |
else |
|---|
| 76 |
let fail++ |
|---|
| 77 |
echo FAIL: decode encoded GET request parameters in the shell |
|---|
| 78 |
fi |
|---|
| 79 |
|
|---|
| 80 |
###### TEST ######################## |
|---|
| 81 |
|
|---|
| 82 |
$webclient "http://localhost:$port/url-decode.jm3?p1=simple&p2=two+params¶m3=three+more%20params¶m4=http%3A%2F%2Fencoded-url&punct=%25%5E%26" > tmp-http-params.txt |
|---|
| 83 |
diff tests/params-decoded.txt tmp-http-params.txt |
|---|
| 84 |
|
|---|
| 85 |
#cat tests/params-decoded.txt |
|---|
| 86 |
#cat tmp-http-params.txt |
|---|
| 87 |
|
|---|
| 88 |
http_decoded_params_match_test_case=$? |
|---|
| 89 |
rm -f tmp-http-params.txt |
|---|
| 90 |
|
|---|
| 91 |
if [ $http_decoded_params_match_test_case -eq 0 ] |
|---|
| 92 |
then |
|---|
| 93 |
let success++ |
|---|
| 94 |
echo PASS: decode encoded GET request parameters over HTTP |
|---|
| 95 |
else |
|---|
| 96 |
let fail++ |
|---|
| 97 |
echo FAIL: decode encoded GET request parameters over HTTP |
|---|
| 98 |
fi |
|---|
| 99 |
|
|---|
| 100 |
###### TEST ######################## |
|---|
| 101 |
shell/parse-decoded-params.jm3 "whatevs?key_id=0x19ACA985&recipients=Philip%20R.%20Zimmermann%20%3Cprz@mit.edu%3E%2C+Aidan%20Dysart%20%3Cadysart@umich.edu%3E&plaintext=%22What+hath+god+wraught%3F%22&passphrase=dis+my+passphrase%21@%23%24%25%5E" > tmp-parsed-params.txt |
|---|
| 102 |
diff tmp-parsed-params.txt tests/parsed-params.txt |
|---|
| 103 |
correctly_parse_input_parameters=$? |
|---|
| 104 |
rm -f tmp-parsed-params.txt |
|---|
| 105 |
if [ $correctly_parse_input_parameters -eq 0 ] |
|---|
| 106 |
then |
|---|
| 107 |
echo PASS: correctly parse \(4\) input parameters in the shell |
|---|
| 108 |
let success++ |
|---|
| 109 |
else |
|---|
| 110 |
echo FAIL: correctly parse \(4\) input parameters in the shell |
|---|
| 111 |
let fail++ |
|---|
| 112 |
fi |
|---|
| 113 |
|
|---|
| 114 |
###### TEST ######################## |
|---|
| 115 |
|
|---|
| 116 |
$webclient "http://localhost:$port/parse-decoded-params.jm3?key_id=0x19ACA985&recipients=Philip%20R.%20Zimmermann%20%3Cprz@mit.edu%3E%2C+Aidan%20Dysart%20%3Cadysart@umich.edu%3E&plaintext=%22What+hath+god+wraught%3F%22&passphrase=dis+my+passphrase%21@%23%24%25%5E" > tmp-parsed-params.txt |
|---|
| 117 |
diff tmp-parsed-params.txt tests/parsed-params.txt |
|---|
| 118 |
correctly_parse_input_parameters=$? |
|---|
| 119 |
rm -f tmp-parsed-params.txt |
|---|
| 120 |
if [ $correctly_parse_input_parameters -eq 0 ] |
|---|
| 121 |
then |
|---|
| 122 |
echo PASS: correctly parse \(4\) input parameters over HTTP |
|---|
| 123 |
let success++ |
|---|
| 124 |
else |
|---|
| 125 |
echo FAIL: correctly parse \(4\) input parameters over HTTP |
|---|
| 126 |
let fail++ |
|---|
| 127 |
fi |
|---|
| 128 |
|
|---|
| 129 |
###### TEST ######################## |
|---|
| 130 |
|
|---|
| 131 |
$webclient http://localhost:$port/get-secret-keys.jm3 > tmp-secret-key-ids.txt |
|---|
| 132 |
diff tmp-secret-key-ids.txt tests/secret-key-ids.txt |
|---|
| 133 |
secret_key_id_list_matches_test_case=$? |
|---|
| 134 |
rm -f tmp-secret-key-ids.txt |
|---|
| 135 |
if [ $secret_key_id_list_matches_test_case -eq 0 ] |
|---|
| 136 |
then |
|---|
| 137 |
let success++ |
|---|
| 138 |
echo PASS: retrieve list of secret key IDs over HTTP |
|---|
| 139 |
else |
|---|
| 140 |
let fail++ |
|---|
| 141 |
echo FAIL: retrieve list of secret key IDs over HTTP |
|---|
| 142 |
fi |
|---|
| 143 |
|
|---|
| 144 |
###### TEST ######################## |
|---|
| 145 |
|
|---|
| 146 |
curl -d @tests/form-post.data http://localhost:$port/raw-post.jm3 > tmp-form-post-output.html 2> /dev/null |
|---|
| 147 |
diff tests/test-form-post-output.html tmp-form-post-output.html |
|---|
| 148 |
HTTP_post_response_matches_test_case=$? |
|---|
| 149 |
rm -f tmp-form-post-output.html |
|---|
| 150 |
|
|---|
| 151 |
if [ $HTTP_post_response_matches_test_case -eq 0 ] |
|---|
| 152 |
then |
|---|
| 153 |
let success++ |
|---|
| 154 |
echo PASS: accept HTTP post request |
|---|
| 155 |
else |
|---|
| 156 |
let fail++ |
|---|
| 157 |
echo FAIL: accept HTTP post request |
|---|
| 158 |
fi |
|---|
| 159 |
|
|---|
| 160 |
###### TEST ######################## |
|---|
| 161 |
|
|---|
| 162 |
curl -d @tests/form-post.data http://localhost:$port/decode-form-post.jm3 > tmp-decoded-form-post-output.html 2> /dev/null |
|---|
| 163 |
diff tests/test-form-post-output.html tmp-decoded-form-post-output.html |
|---|
| 164 |
decoded_HTTP_form_post=$? |
|---|
| 165 |
rm -f tmp-decoded-form-post-output.html |
|---|
| 166 |
|
|---|
| 167 |
if [ $decoded_HTTP_form_post -eq 0 ] |
|---|
| 168 |
then |
|---|
| 169 |
let success++ |
|---|
| 170 |
echo PASS: decode HTTP form POST request |
|---|
| 171 |
else |
|---|
| 172 |
let fail++ |
|---|
| 173 |
echo FAIL: decode HTTP form POST request |
|---|
| 174 |
fi |
|---|
| 175 |
|
|---|
| 176 |
###### TEST ######################## |
|---|
| 177 |
|
|---|
| 178 |
echo FAIL: correctly assign POST\'ed params to variables |
|---|
| 179 |
let fail++ |
|---|
| 180 |
|
|---|
| 181 |
###### TEST ######################## |
|---|
| 182 |
echo FAIL: sign message |
|---|
| 183 |
let fail++ |
|---|
| 184 |
|
|---|
| 185 |
let total=success+fail |
|---|
| 186 |
let percent=success/total |
|---|
| 187 |
|
|---|
| 188 |
echo |
|---|
| 189 |
echo $success / $total tests passed with $fail failures |
|---|
| 190 |
exit 1 |
|---|
| 191 |
|
|---|