summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-22 18:31:42 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-22 18:31:42 +0000
commitbc6e55c0846ba668534ad224f516d3fdda16993c (patch)
tree6eb6d0e73f089ea7b4f05359d3ce43a8ac098ef6 /test
parent3b0d490548ed2c718544d55867c2c1466c604191 (diff)
* 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
Diffstat (limited to 'test')
-rw-r--r--test/openssl/test_ssl.rb32
1 files changed, 32 insertions, 0 deletions
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