File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -121,4 +121,36 @@ def test_ssl_version_tlsv1_2
121
121
end
122
122
end unless java6? # TLS1_2 is not supported by JDK 6
123
123
124
+ def test_read_nonblock_would_block
125
+ start_server ( PORT , OpenSSL ::SSL ::VERIFY_NONE , true ) do |server , port |
126
+ sock = TCPSocket . new ( "127.0.0.1" , port )
127
+ ssl = OpenSSL ::SSL ::SSLSocket . new ( sock )
128
+ ssl . connect
129
+
130
+ if defined? OpenSSL ::SSL ::SSLErrorWaitReadable
131
+ begin
132
+ ssl . read_nonblock ( 2 )
133
+ fail 'read would block error not raised!'
134
+ rescue OpenSSL ::SSL ::SSLErrorWaitReadable => e
135
+ assert_equal 'read would block' , e . message
136
+ end
137
+ else
138
+ begin
139
+ ssl . read_nonblock ( 2 )
140
+ fail 'read would block error not raised!'
141
+ rescue => e
142
+ assert_equal 'read would block' , e . message
143
+ end
144
+ end
145
+ if RUBY_VERSION > '2.2'
146
+ result = eval "ssl.read_nonblock(5, 'buff', exception: false)"
147
+ assert_equal :wait_readable , result
148
+ end
149
+ result = ssl . sysread_nonblock ( 5 , :exception => false )
150
+ assert_equal :wait_readable , result
151
+
152
+ ssl . close
153
+ end
154
+ end
155
+
124
156
end
You can’t perform that action at this time.
0 commit comments