diff options
author | Samuel Williams <[email protected]> | 2024-01-18 06:08:59 +1300 |
---|---|---|
committer | git <[email protected]> | 2024-01-17 17:09:03 +0000 |
commit | 4f634d3c85ca45b5995c1f37619784c99f2be62c (patch) | |
tree | a7fd8b8cbcd3e647dc68ad8268ff4955d82c78a7 /test/openssl | |
parent | 6213ab1a51387fd9cdcb5e87908722f3bbdf78cb (diff) |
[ruby/openssl] Add support for IO#timeout.
(https://github.com/ruby/openssl/pull/714)
* Add support for IO#timeout.
https://github.com/ruby/openssl/commit/3bbf5178a9
Diffstat (limited to 'test/openssl')
-rw-r--r-- | test/openssl/test_ssl.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index 07dc9a343c..dcb7757add 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -193,6 +193,24 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase } end + def test_read_with_timeout + omit "does not support timeout" unless IO.method_defined?(:timeout) + + start_server do |port| + server_connect(port) do |ssl| + str = +("x" * 100 + "\n") + ssl.syswrite(str) + assert_equal(str, ssl.sysread(str.bytesize)) + + ssl.timeout = 1 + assert_raise(IO::TimeoutError) {ssl.read(1)} + + ssl.syswrite(str) + assert_equal(str, ssl.sysread(str.bytesize)) + end + end + end + def test_getbyte start_server { |port| server_connect(port) { |ssl| |