Skip to content

Commit

Permalink
add a few connect_nonblock exception: false asserts
Browse files Browse the repository at this point in the history
kares committed Nov 22, 2015
1 parent d5c61c1 commit 51ce19c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/test/ruby/ssl/test_ssl.rb
Original file line number Diff line number Diff line change
@@ -153,4 +153,36 @@ def test_read_nonblock_would_block
end
end if RUBY_VERSION > '1.9'

def test_connect_nonblock_would_block
start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true) do |server, port|
sock = TCPSocket.new("127.0.0.1", port)
ssl = OpenSSL::SSL::SSLSocket.new(sock)

if defined? OpenSSL::SSL::SSLErrorWaitReadable
begin
ssl.connect_nonblock
fail 'read would block error not raised!'
rescue OpenSSL::SSL::SSLErrorWaitReadable => e
assert_equal 'read would block', e.message
end
else
begin
ssl.connect_nonblock
fail 'read would block error not raised!'
rescue => e
assert_equal 'read would block', e.message
end
end

if RUBY_VERSION > '2.2'
result = eval "ssl.connect_nonblock(exception: false)"
assert_equal :wait_readable, result
end
result = ssl.connect_nonblock(:exception => false)
assert_equal :wait_readable, result

ssl.close
end
end if RUBY_VERSION > '1.9'

end

0 comments on commit 51ce19c

Please sign in to comment.