diff options
author | SHIBATA Hiroshi <hsbt@ruby-lang.org> | 2014-10-27 11:12:18 +0900 |
---|---|---|
committer | SHIBATA Hiroshi <hsbt@ruby-lang.org> | 2014-10-27 11:12:18 +0900 |
commit | ad6b55f73a85ab960d2e5f1876f31081bb59c643 (patch) | |
tree | 6001aed0d9c0f6a77d04cc550320bce73fe56130 /test/test_partial_record_read.rb | |
parent | 1134fb9ad0fd60563006defc558f57f8523dd6e8 (diff) | |
download | ruby-openssl-ad6b55f73a85ab960d2e5f1876f31081bb59c643.tar.gz |
import ruby trunk
Diffstat (limited to 'test/test_partial_record_read.rb')
-rw-r--r-- | test/test_partial_record_read.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/test_partial_record_read.rb b/test/test_partial_record_read.rb new file mode 100644 index 00000000..f3d83c69 --- /dev/null +++ b/test/test_partial_record_read.rb @@ -0,0 +1,36 @@ +require_relative "utils" + +if defined?(OpenSSL) + + class OpenSSL::TestPartialRecordRead < OpenSSL::SSLTestCase + def test_partial_tls_record_read_nonblock + port = 12345 + + start_server(port, OpenSSL::SSL::VERIFY_NONE, true, :server_proc => + Proc.new do |server_ctx, server_ssl| + begin + server_ssl.io.write("\x01") # the beginning of a TLS record + sleep 6 # do not finish prematurely before the read by the client is attempted + ensure + server_ssl.close + end + end + ) do |server, port| + sock = TCPSocket.new("127.0.0.1", port) + ssl = OpenSSL::SSL::SSLSocket.new(sock) + ssl.sync_close = true + begin + ssl.connect + sleep 3 # wait is required for the (incomplete) TLS record to arrive at the client socket + + # Should raise a IO::WaitReadable since a full TLS record is not available for reading. + assert_raise(IO::WaitReadable) { ssl.read_nonblock(1) } + ensure + ssl.close + end + end + end + + end + +end |