configurator: validate :reuseport for boolean-ess
[unicorn.git] / test / unit / test_sni_hostnames.rb
blob457afeeff055fe8c8e093693f892409617c1ae6a
1 # -*- encoding: binary -*-
2 require "test/unit"
3 require "unicorn"
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
10   def setup
11     GC.start
12   end
14   def teardown
15     GC.start
16   end
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, {}, [] ] }
24       end
25     end.to_app
26     hostnames = rack_sni_hostnames(app)
27     assert hostnames.include?("sni1.example.com")
28   end
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, {}, [] ] }
36       end
37       map "http://sni3.example.com/" do
38         use Rack::ContentLength
39         use Rack::ContentType, "text/plain"
40         run lambda { |env| [ 200, {}, [] ] }
41       end
42     end.to_app
43     hostnames = rack_sni_hostnames(app)
44     assert hostnames.include?("sni2.example.com")
45     assert hostnames.include?("sni3.example.com")
46   end
47 end