1 # -*- encoding: binary -*-
5 # this tests an implementation detail, it may change so this test
6 # can be removed later.
7 class TestSniHostnames < Test::Unit::TestCase
8 include Unicorn::SSLServer
18 def test_host_name_detect_one
19 app = Rack::Builder.new do
20 map "http://sni1.example.com/" do
21 use Rack::ContentLength
22 use Rack::ContentType, "text/plain"
23 run lambda { |env| [ 200, {}, [] ] }
26 hostnames = rack_sni_hostnames(app)
27 assert hostnames.include?("sni1.example.com")
30 def test_host_name_detect_multiple
31 app = Rack::Builder.new do
32 map "http://sni2.example.com/" do
33 use Rack::ContentLength
34 use Rack::ContentType, "text/plain"
35 run lambda { |env| [ 200, {}, [] ] }
37 map "http://sni3.example.com/" do
38 use Rack::ContentLength
39 use Rack::ContentType, "text/plain"
40 run lambda { |env| [ 200, {}, [] ] }
43 hostnames = rack_sni_hostnames(app)
44 assert hostnames.include?("sni2.example.com")
45 assert hostnames.include?("sni3.example.com")