From bc6e55c0846ba668534ad224f516d3fdda16993c Mon Sep 17 00:00:00 2001 From: tenderlove Date: Wed, 22 Jul 2015 18:31:42 +0000 Subject: * ext/openssl/ossl_ssl.c: add ALPN support. [Feature #9390] * ext/openssl/extconf.rb: detect ALPN support in OpenSSL * test/openssl/test_ssl.rb: test for ALPN git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/openssl/test_ssl.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/openssl') diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index f2a64ca7c6..d02f186ecd 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -795,6 +795,38 @@ end } end +if OpenSSL::OPENSSL_VERSION_NUMBER >= 0x10002000 + def test_alpn_protocol_selection_ary + advertised = ["http/1.1", "spdy/2"] + ctx_proc = Proc.new { |ctx| + ctx.alpn_select_cb = -> (protocols) { + protocols.first + } + ctx.alpn_protocols = advertised + } + start_server_version(:SSLv23, ctx_proc) { |server, port| + ctx = OpenSSL::SSL::SSLContext.new + ctx.alpn_protocols = advertised + server_connect(port, ctx) { |ssl| + assert_equal(advertised.first, ssl.alpn_protocol) + } + } + end + + def test_alpn_protocol_selection_cancel + ctx_proc = Proc.new { |ctx| + ctx.alpn_select_cb = -> (protocols) { nil } + } + assert_raises(MiniTest::Assertion) do # minitest/assertion comes from `assert_join_threads` + start_server_version(:SSLv23, ctx_proc) { |server, port| + ctx = OpenSSL::SSL::SSLContext.new + ctx.alpn_protocols = ["http/1.1"] + assert_raise(OpenSSL::SSL::SSLError) { server_connect(port, ctx) } + } + end + end +end + if OpenSSL::OPENSSL_VERSION_NUMBER > 0x10001000 def test_npn_protocol_selection_ary -- cgit v1.2.3