about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-09-07 00:36:58 +0000
committerEric Wong <normalperson@yhbt.net>2011-09-15 21:37:40 +0000
commitac346b5abcfa6253bd792091e5fb011774c40d49 (patch)
treeb304b96f42c3ba2cde396de8ed626754ae9d78cc /test
parentb48c6659b294b37f2c6ff3e75c1c9245522d48d1 (diff)
downloadunicorn-ac346b5abcfa6253bd792091e5fb011774c40d49.tar.gz
This will also be the foundation of SSL support in Rainbows!
and Zbatery.  Some users may also want to use this in
Unicorn on LANs to meet certain security/auditing requirements.
Of course, Nightmare! (in whatever form) should also be able to
use it.
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_sni_hostnames.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/unit/test_sni_hostnames.rb b/test/unit/test_sni_hostnames.rb
new file mode 100644
index 0000000..457afee
--- /dev/null
+++ b/test/unit/test_sni_hostnames.rb
@@ -0,0 +1,47 @@
+# -*- encoding: binary -*-
+require "test/unit"
+require "unicorn"
+
+# this tests an implementation detail, it may change so this test
+# can be removed later.
+class TestSniHostnames < Test::Unit::TestCase
+  include Unicorn::SSLServer
+
+  def setup
+    GC.start
+  end
+
+  def teardown
+    GC.start
+  end
+
+  def test_host_name_detect_one
+    app = Rack::Builder.new do
+      map "http://sni1.example.com/" do
+        use Rack::ContentLength
+        use Rack::ContentType, "text/plain"
+        run lambda { |env| [ 200, {}, [] ] }
+      end
+    end.to_app
+    hostnames = rack_sni_hostnames(app)
+    assert hostnames.include?("sni1.example.com")
+  end
+
+  def test_host_name_detect_multiple
+    app = Rack::Builder.new do
+      map "http://sni2.example.com/" do
+        use Rack::ContentLength
+        use Rack::ContentType, "text/plain"
+        run lambda { |env| [ 200, {}, [] ] }
+      end
+      map "http://sni3.example.com/" do
+        use Rack::ContentLength
+        use Rack::ContentType, "text/plain"
+        run lambda { |env| [ 200, {}, [] ] }
+      end
+    end.to_app
+    hostnames = rack_sni_hostnames(app)
+    assert hostnames.include?("sni2.example.com")
+    assert hostnames.include?("sni3.example.com")
+  end
+end