ruby-changes:36151
From: akr <ko1@a...>
Date: Sun, 2 Nov 2014 01:33:12 +0900 (JST)
Subject: [ruby-changes:36151] akr:r48232 (trunk): * test/openssl/test_ssl.rb: Don't ignore errors on listener threads,
akr 2014-11-02 01:32:59 +0900 (Sun, 02 Nov 2014) New Revision: 48232 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48232 Log: * test/openssl/test_ssl.rb: Don't ignore errors on listener threads, as much as possible. * test/openssl/test_ssl_session.rb: Ditto. * test/openssl/test_partial_record_read.rb: Ditto. Modified files: trunk/ChangeLog trunk/test/openssl/test_partial_record_read.rb trunk/test/openssl/test_ssl.rb trunk/test/openssl/test_ssl_session.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 48231) +++ ChangeLog (revision 48232) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Nov 2 01:30:32 2014 Tanaka Akira <akr@f...> + + * test/openssl/test_ssl.rb: Don't ignore errors on listener threads, + as much as possible. + + * test/openssl/test_ssl_session.rb: Ditto. + + * test/openssl/test_partial_record_read.rb: Ditto. + Sat Nov 1 23:11:05 2014 Tanaka Akira <akr@f...> * test/openssl/utils.rb (start_server): Don't close sockets before Index: test/openssl/test_partial_record_read.rb =================================================================== --- test/openssl/test_partial_record_read.rb (revision 48231) +++ test/openssl/test_partial_record_read.rb (revision 48232) @@ -14,7 +14,8 @@ if defined?(OpenSSL) https://github.com/ruby/ruby/blob/trunk/test/openssl/test_partial_record_read.rb#L14 ensure server_ssl.close end - end + end, + :ignore_listener_error => false ) do |server, port| sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) Index: test/openssl/test_ssl.rb =================================================================== --- test/openssl/test_ssl.rb (revision 48231) +++ test/openssl/test_ssl.rb (revision 48232) @@ -34,7 +34,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L34 end def test_ssl_gets - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true) { |server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false) { |server, port| server_connect(port) { |ssl| ssl.write "abc\n" IO.select [ssl] @@ -48,7 +48,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L48 end def test_ssl_read_nonblock - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true) { |server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false) { |server, port| server_connect(port) { |ssl| assert_raise(IO::WaitReadable) { ssl.read_nonblock(100) } ssl.write("abc\n") @@ -61,7 +61,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L61 end def test_connect_and_close - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false){|server, port| sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) assert(ssl.connect) @@ -79,7 +79,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L79 end def test_read_and_write - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false){|server, port| server_connect(port) { |ssl| # syswrite and sysread ITERATIONS.times{|i| @@ -126,7 +126,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L126 } end - def test_client_auth + def test_client_auth_failure vflag = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT start_server(PORT, vflag, true){|server, port| assert_raise(OpenSSL::SSL::SSLError, Errno::ECONNRESET){ @@ -139,7 +139,12 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L139 ssl.close end } + } + end + def test_client_auth_success + vflag = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT + start_server(PORT, vflag, true, :ignore_listener_error => false){|server, port| ctx = OpenSSL::SSL::SSLContext.new ctx.key = @cli_key ctx.cert = @cli_cert @@ -170,7 +175,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L175 end vflag = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT - start_server(PORT, vflag, true, :ctx_proc => ctx_proc){|server, port| + start_server(PORT, vflag, true, :ctx_proc => ctx_proc, :ignore_listener_error => false){|server, port| ctx = OpenSSL::SSL::SSLContext.new client_ca_from_server = nil ctx.client_cert_cb = Proc.new do |sslconn| @@ -183,7 +188,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L188 def test_read_nonblock_without_session OpenSSL::TestUtils.silent do - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, false){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, false, :ignore_listener_error => false){|server, port| sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true @@ -201,7 +206,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L206 def test_starttls OpenSSL::TestUtils.silent do - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, false){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, false, :ignore_listener_error => false){|server, port| sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true @@ -225,7 +230,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L230 def test_parallel GC.start - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false){|server, port| ssls = [] 10.times{ sock = TCPSocket.new("127.0.0.1", port) @@ -260,7 +265,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L265 end } - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false){|server, port| sock = TCPSocket.new("127.0.0.1", port) ctx = OpenSSL::SSL::SSLContext.new ctx.set_params( @@ -349,7 +354,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L354 def test_post_connection_check sslerr = OpenSSL::SSL::SSLError - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false){|server, port| server_connect(port) { |ssl| assert_raise(sslerr){ssl.post_connection_check("localhost.localdomain")} assert_raise(sslerr){ssl.post_connection_check("127.0.0.1")} @@ -372,7 +377,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L377 ] @svr_cert = issue_cert(@svr, @svr_key, 4, now, now+1800, exts, @ca_cert, @ca_key, OpenSSL::Digest::SHA1.new) - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false){|server, port| server_connect(port) { |ssl| assert(ssl.post_connection_check("localhost.localdomain")) assert(ssl.post_connection_check("127.0.0.1")) @@ -394,7 +399,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L399 ] @svr_cert = issue_cert(@svr, @svr_key, 5, now, now+1800, exts, @ca_cert, @ca_key, OpenSSL::Digest::SHA1.new) - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false){|server, port| server_connect(port) { |ssl| assert(ssl.post_connection_check("localhost.localdomain")) assert_raise(sslerr){ssl.post_connection_check("127.0.0.1")} @@ -460,7 +465,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L465 readwrite_loop(ctx, ssl) end - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc, :server_proc => server_proc) do |server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc, :server_proc => server_proc, :ignore_listener_error => false) do |server, port| 2.times do |i| ctx = OpenSSL::SSL::SSLContext.new if defined?(OpenSSL::SSL::OP_NO_TICKET) @@ -493,7 +498,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L498 assert_equal(num_written, raw_size) ssl.close } - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :server_proc => server_proc){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :server_proc => server_proc, :ignore_listener_error => false){|server, port| server_connect(port) { |ssl| str = auml * i num_written = ssl.write(str) @@ -509,7 +514,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L514 # But it also degrades gracefully, so keep it ctx.options = OpenSSL::SSL::OP_ALL } - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc, :ignore_listener_error => false){|server, port| server_connect(port) { |ssl| ssl.puts('hello') assert_equal("hello\n", ssl.gets) @@ -695,7 +700,7 @@ end https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L700 def test_invalid_shutdown_by_gc assert_nothing_raised { - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false){|server, port| 10.times { sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) @@ -708,7 +713,7 @@ end https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L713 end def test_close_after_socket_close - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false){|server, port| sock = TCPSocket.new("127.0.0.1", port) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true @@ -753,7 +758,11 @@ end https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L758 ssl.connect yield ssl ensure - ssl.close + if ssl + ssl.close + elsif sock + sock.close + end end end Index: test/openssl/test_ssl_session.rb =================================================================== --- test/openssl/test_ssl_session.rb (revision 48231) +++ test/openssl/test_ssl_session.rb (revision 48232) @@ -45,7 +45,7 @@ tddwpBAEDjcwMzA5NTYzMTU1MzAwpQMCARM= https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl_session.rb#L45 def test_session timeout(5) do - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true) do |server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false) do |server, port| sock = TCPSocket.new("127.0.0.1", port) ctx = OpenSSL::SSL::SSLContext.new("TLSv1") ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) @@ -156,7 +156,7 @@ __EOS__ https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl_session.rb#L156 def test_client_session last_session = nil - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true) do |server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false) do |server, port| 2.times do sock = TCPSocket.new("127.0.0.1", port) # Debian's openssl 0.9.8g-13 failed at assert(ssl.session_reused?), @@ -242,7 +242,7 @@ __EOS__ https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl_session.rb#L242 end first_session = nil - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc, :server_proc => server_proc) do |server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc, :server_proc => server_proc, :ignore_listener_error => false) do |server, port| 10.times do |i| sock = TCPSocket.new("127.0.0.1", port) ctx = OpenSSL::SSL::SSLContext.new @@ -292,7 +292,7 @@ __EOS__ https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl_session.rb#L292 # any resulting value is OK (ignored) } - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, ignore_listener_error: false) do |server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ignore_listener_error => false) do |server, port| sock = TCPSocket.new("127.0.0.1", port) begin ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) @@ -350,7 +350,7 @@ __EOS__ https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl_session.rb#L350 c.session_cache_stats readwrite_loop(c, ssl) } - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, ctx_proc: ctx_proc, server_proc: server_proc, ignore_listener_error: false) do |server, port| + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc, :server_proc => server_proc, :ignore_listener_error => false) do |server, port| last_client_session = nil 3.times do sock = TCPSocket.new("127.0.0.1", port) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/