diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2021-04-15 16:53:47 -0700 |
---|---|---|
committer | Aaron Patterson <tenderlove@ruby-lang.org> | 2021-04-16 09:11:47 -0700 |
commit | ac1490b7c900ee04238f89f0c085fd565e489c00 (patch) | |
tree | ded01936c1ca47cfdf19a478034779ee6b5c94f1 /test | |
parent | d172036b4a3e137107a35f2f7818e01b9b4d630d (diff) | |
download | ruby-openssl-ac1490b7c900ee04238f89f0c085fd565e489c00.tar.gz |
Add SSLSocket#getbyte
Normal sockets respond to `getbyte`, so we should make SSLSocket respond
to `getbyte` as well. This way we can substitute SSLSockets for regular
sockets.
Diffstat (limited to 'test')
-rw-r--r-- | test/openssl/test_ssl.rb | 13 | ||||
-rw-r--r-- | test/openssl/ut_eof.rb | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index f24aabe7..3dda7548 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -185,6 +185,19 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase } end + def test_getbyte + start_server { |port| + server_connect(port) { |ssl| + str = +("x" * 100 + "\n") + ssl.syswrite(str) + newstr = str.bytesize.times.map { |i| + ssl.getbyte + }.pack("C*") + assert_equal(str, newstr) + } + } + end + def test_sync_close start_server do |port| begin diff --git a/test/openssl/ut_eof.rb b/test/openssl/ut_eof.rb index cf1f2d42..7b18f43a 100644 --- a/test/openssl/ut_eof.rb +++ b/test/openssl/ut_eof.rb @@ -4,6 +4,10 @@ require 'test/unit' if defined?(OpenSSL) module OpenSSL::TestEOF + def test_getbyte_eof + open_file("") {|f| assert_nil f.getbyte } + end + def test_eof_0 open_file("") {|f| assert_equal("", f.read(0)) |