unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob 11103c50197ae207d23ebf99ffc6af18a6db9fd0 681 bytes (raw)
$ git show httpdate-nogvl:t/t0017-trust-x-forwarded-true.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=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

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