diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-27 08:17:35 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-27 08:17:35 +0000 |
commit | 674b2526650f317a5a836130631651dbdb019913 (patch) | |
tree | b9c261164d1ac97176f92c33b96f7573d3e98b33 /test | |
parent | 516f8f355e94dd716ac187e86a9bef2e26f1550b (diff) |
merge revision(s) 45863,45871: [Backport #9750]
* ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept):
Consider Socket#accept as well as TCPServer#accept.
Reported by Sam Stelfox. [ruby-core:62064] [Bug #9750]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/openssl/test_pair.rb | 77 |
1 files changed, 63 insertions, 14 deletions
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb index 12af6aeff5..aa492abc11 100644 --- a/test/openssl/test_pair.rb +++ b/test/openssl/test_pair.rb @@ -5,14 +5,14 @@ if defined?(OpenSSL) require 'socket' require_relative '../ruby/ut_eof' -module SSLPair +module OpenSSL::SSLPairM def server host = "127.0.0.1" port = 0 ctx = OpenSSL::SSL::SSLContext.new() ctx.ciphers = "ADH" ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 } - tcps = TCPServer.new(host, port) + tcps = create_tcp_server(host, port) ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx) return ssls end @@ -21,7 +21,7 @@ module SSLPair host = "127.0.0.1" ctx = OpenSSL::SSL::SSLContext.new() ctx.ciphers = "ADH" - s = TCPSocket.new(host, port) + s = create_tcp_client(host, port) ssl = OpenSSL::SSL::SSLSocket.new(s, ctx) ssl.connect ssl.sync_close = true @@ -35,7 +35,7 @@ module SSLPair ssls.close ns } - port = ssls.to_io.addr[1] + port = ssls.to_io.local_address.ip_port c = client(port) s = th.value if block_given? @@ -56,10 +56,31 @@ module SSLPair end end -class OpenSSL::TestEOF1 < Test::Unit::TestCase - include TestEOF - include SSLPair +module OpenSSL::SSLPair + include OpenSSL::SSLPairM + + def create_tcp_server(host, port) + TCPServer.new(host, port) + end + + def create_tcp_client(host, port) + TCPSocket.new(host, port) + end +end + +module OpenSSL::SSLPairLowlevelSocket + include OpenSSL::SSLPairM + + def create_tcp_server(host, port) + Addrinfo.tcp(host, port).listen + end + def create_tcp_client(host, port) + Addrinfo.tcp(host, port).connect + end +end + +module OpenSSL::TestEOF1M def open_file(content) s1, s2 = ssl_pair Thread.new { s2 << content; s2.close } @@ -67,10 +88,7 @@ class OpenSSL::TestEOF1 < Test::Unit::TestCase end end -class OpenSSL::TestEOF2 < Test::Unit::TestCase - include TestEOF - include SSLPair - +module OpenSSL::TestEOF2M def open_file(content) s1, s2 = ssl_pair Thread.new { s1 << content; s1.close } @@ -78,9 +96,7 @@ class OpenSSL::TestEOF2 < Test::Unit::TestCase end end -class OpenSSL::TestPair < Test::Unit::TestCase - include SSLPair - +module OpenSSL::TestPairM def test_getc ssl_pair {|s1, s2| s1 << "a" @@ -243,7 +259,40 @@ class OpenSSL::TestPair < Test::Unit::TestCase sock1.close if sock1 && !sock1.closed? sock2.close if sock2 && !sock2.closed? end +end + +class OpenSSL::TestEOF1 < Test::Unit::TestCase + include TestEOF + include OpenSSL::SSLPair + include OpenSSL::TestEOF1M +end + +class OpenSSL::TestEOF1LowlevelSocket < Test::Unit::TestCase + include TestEOF + include OpenSSL::SSLPairLowlevelSocket + include OpenSSL::TestEOF1M +end + +class OpenSSL::TestEOF2 < Test::Unit::TestCase + include TestEOF + include OpenSSL::SSLPair + include OpenSSL::TestEOF2M +end + +class OpenSSL::TestEOF2LowlevelSocket < Test::Unit::TestCase + include TestEOF + include OpenSSL::SSLPairLowlevelSocket + include OpenSSL::TestEOF2M +end + +class OpenSSL::TestPair < Test::Unit::TestCase + include OpenSSL::SSLPair + include OpenSSL::TestPairM +end +class OpenSSL::TestPairLowlevelSocket < Test::Unit::TestCase + include OpenSSL::SSLPairLowlevelSocket + include OpenSSL::TestPairM end end |