about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-21 01:28:23 +0000
committerEric Wong <normalperson@yhbt.net>2010-12-21 01:28:23 +0000
commit1f5bac15cd8e4393c6da98eb7bb4532133dc6259 (patch)
tree4d230cdb233014230714d021a00e40ffad93f595 /t
parentbf64b9aa855cf3590a4d5b4eca853aef33ba90cc (diff)
downloadunicorn-1f5bac15cd8e4393c6da98eb7bb4532133dc6259.tar.gz
More config bloat, sadly this is necessary for Rainbows! :<
Diffstat (limited to 't')
-rwxr-xr-xt/t0016-trust-x-forwarded-false.sh30
-rwxr-xr-xt/t0017-trust-x-forwarded-true.sh30
2 files changed, 60 insertions, 0 deletions
diff --git a/t/t0016-trust-x-forwarded-false.sh b/t/t0016-trust-x-forwarded-false.sh
new file mode 100755
index 0000000..3163690
--- /dev/null
+++ b/t/t0016-trust-x-forwarded-false.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+. ./test-lib.sh
+t_plan 5 "trust_x_forwarded=false configuration test"
+
+t_begin "setup and start" && {
+        unicorn_setup
+        echo "trust_x_forwarded false" >> $unicorn_config
+        unicorn -D -c $unicorn_config env.ru
+        unicorn_wait_start
+}
+
+t_begin "spoofed request with X-Forwarded-Proto does not trigger" && {
+        curl -H 'X-Forwarded-Proto: https' http://$listen/ | \
+                grep -F '"rack.url_scheme"=>"http"'
+}
+
+t_begin "spoofed request with X-Forwarded-SSL does not trigger" && {
+        curl -H 'X-Forwarded-SSL: on' http://$listen/ | \
+                grep -F '"rack.url_scheme"=>"http"'
+}
+
+t_begin "killing succeeds" && {
+        kill $unicorn_pid
+}
+
+t_begin "check stderr has no errors" && {
+        check_stderr
+}
+
+t_done
diff --git a/t/t0017-trust-x-forwarded-true.sh b/t/t0017-trust-x-forwarded-true.sh
new file mode 100755
index 0000000..11103c5
--- /dev/null
+++ b/t/t0017-trust-x-forwarded-true.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+. ./test-lib.sh
+t_plan 5 "trust_x_forwarded=true configuration test"
+
+t_begin "setup and start" && {
+        unicorn_setup
+        echo "trust_x_forwarded true " >> $unicorn_config
+        unicorn -D -c $unicorn_config env.ru
+        unicorn_wait_start
+}
+
+t_begin "spoofed request with X-Forwarded-Proto sets 'https'" && {
+        curl -H 'X-Forwarded-Proto: https' http://$listen/ | \
+                grep -F '"rack.url_scheme"=>"https"'
+}
+
+t_begin "spoofed request with X-Forwarded-SSL sets 'https'" && {
+        curl -H 'X-Forwarded-SSL: on' http://$listen/ | \
+                grep -F '"rack.url_scheme"=>"https"'
+}
+
+t_begin "killing succeeds" && {
+        kill $unicorn_pid
+}
+
+t_begin "check stderr has no errors" && {
+        check_stderr
+}
+
+t_done