unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob 31636902d8f1071c087487b661353117aa6ebf05 688 bytes (raw)
$ git show v3.4.0:t/t0016-trust-x-forwarded-false.sh	# shows this blob on the CLI

 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
 
#!/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

git clone https://yhbt.net/unicorn.git