From 86048989b2460d1dd762037449f8c9a9f6d35d3a Mon Sep 17 00:00:00 2001 From: rhe Date: Mon, 29 Aug 2016 05:47:09 +0000 Subject: import Ruby/OpenSSL 2.0.0.beta.1 * NEWS, {ext,test,sample}/openssl: Import Ruby/OpenSSL 2.0.0.beta.1. ext/openssl is now converted into a default gem. The full commit history since r55538 can be found at: https://github.com/ruby/openssl/compare/08e1881f5663...v2.0.0.beta.1 [Feature #9612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/openssl/test_pair.rb | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'test/openssl/test_pair.rb') diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb index d611d0f965..9250222979 100644 --- a/test/openssl/test_pair.rb +++ b/test/openssl/test_pair.rb @@ -4,7 +4,7 @@ require_relative 'utils' if defined?(OpenSSL::TestUtils) require 'socket' -require_relative '../ruby/ut_eof' +require_relative 'ut_eof' module OpenSSL::SSLPairM def server @@ -322,6 +322,16 @@ module OpenSSL::TestPairM } end + def test_partial_tls_record_read_nonblock + ssl_pair { |s1, s2| + # the beginning of a TLS record + s1.io.write("\x17") + # should raise a IO::WaitReadable since a full TLS record is not available + # for reading + assert_raise(IO::WaitReadable) { s2.read_nonblock(1) } + } + end + def tcp_pair host = "127.0.0.1" serv = TCPServer.new(host, 0) @@ -341,7 +351,7 @@ module OpenSSL::TestPairM ctx2.tmp_dh_callback = nil sock1, sock2 = tcp_pair s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) - accepted = s2.accept_nonblock(exception: false) + s2.accept_nonblock(exception: false) ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ciphers = "DH" @@ -350,16 +360,16 @@ module OpenSSL::TestPairM s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) t = Thread.new { s1.connect } - accept = s2.accept + EnvUtil.suppress_warning { # uses default callback + assert_nothing_raised { s2.accept } + } assert_equal s1, t.value - assert accept ensure t.join if t s1.close if s1 s2.close if s2 sock1.close if sock1 sock2.close if sock2 - accepted.close if accepted.respond_to?(:close) end def test_connect_without_setting_dh_callback @@ -368,7 +378,7 @@ module OpenSSL::TestPairM ctx2.security_level = 0 sock1, sock2 = tcp_pair s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) - accepted = s2.accept_nonblock(exception: false) + s2.accept_nonblock(exception: false) ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ciphers = "DH" @@ -376,16 +386,16 @@ module OpenSSL::TestPairM s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) t = Thread.new { s1.connect } - accept = s2.accept + EnvUtil.suppress_warning { # default DH + assert_nothing_raised { s2.accept } + } assert_equal s1, t.value - assert accept ensure t.join if t s1.close if s1 s2.close if s2 sock1.close if sock1 sock2.close if sock2 - accepted.close if accepted.respond_to?(:close) end def test_ecdh_callback @@ -422,11 +432,11 @@ module OpenSSL::TestPairM end until rv == s1 end - accepted = s2.accept + s2.accept assert called, 'ecdh callback should be called' rescue OpenSSL::SSL::SSLError => e if e.message =~ /no cipher match/ - skip "ECDH cipher not supported." + pend "ECDH cipher not supported." else raise e end @@ -447,7 +457,7 @@ module OpenSSL::TestPairM begin ctx1.ciphers = "ECDH" rescue OpenSSL::SSL::SSLError - skip "ECDH is not enabled in this OpenSSL" if $!.message =~ /no cipher match/ + pend "ECDH is not enabled in this OpenSSL" if $!.message =~ /no cipher match/ raise end ctx1.ecdh_curves = "P-384:P-521" -- cgit v1.2.3