From 593164c2bea634e33682a0095825ef17021a7433 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 15 Apr 2021 16:53:47 -0700 Subject: [ruby/openssl] 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. https://github.com/ruby/openssl/commit/ac1490b7c9 --- test/openssl/test_ssl.rb | 13 +++++++++++++ test/openssl/ut_eof.rb | 4 ++++ 2 files changed, 17 insertions(+) (limited to 'test/openssl') diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index f24aabe748..3dda754870 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 cf1f2d423e..7b18f43a79 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)) -- cgit v1.2.3