Skip to content

Commit 51ce19c

Browse files
committed
add a few connect_nonblock exception: false asserts
1 parent d5c61c1 commit 51ce19c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/test/ruby/ssl/test_ssl.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,36 @@ def test_read_nonblock_would_block
153153
end
154154
end if RUBY_VERSION > '1.9'
155155

156+
def test_connect_nonblock_would_block
157+
start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true) do |server, port|
158+
sock = TCPSocket.new("127.0.0.1", port)
159+
ssl = OpenSSL::SSL::SSLSocket.new(sock)
160+
161+
if defined? OpenSSL::SSL::SSLErrorWaitReadable
162+
begin
163+
ssl.connect_nonblock
164+
fail 'read would block error not raised!'
165+
rescue OpenSSL::SSL::SSLErrorWaitReadable => e
166+
assert_equal 'read would block', e.message
167+
end
168+
else
169+
begin
170+
ssl.connect_nonblock
171+
fail 'read would block error not raised!'
172+
rescue => e
173+
assert_equal 'read would block', e.message
174+
end
175+
end
176+
177+
if RUBY_VERSION > '2.2'
178+
result = eval "ssl.connect_nonblock(exception: false)"
179+
assert_equal :wait_readable, result
180+
end
181+
result = ssl.connect_nonblock(:exception => false)
182+
assert_equal :wait_readable, result
183+
184+
ssl.close
185+
end
186+
end if RUBY_VERSION > '1.9'
187+
156188
end

0 commit comments

Comments
 (0)