diff options
author | Nishant Patel <91441876+nishantactivepipe@users.noreply.github.com> | 2022-02-16 16:59:28 +1100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-10-06 18:00:58 +0900 |
commit | 43e925090b6cf33b889904f8b795f4583b20a59b (patch) | |
tree | 2610ad22f99a05696ec044473fb3801e23b4268b | |
parent | cdbaac3f4b6349907fe744f5eafab982b45e53e2 (diff) |
[ruby/open-uri] fix: added test case that validates that bad TLS version is silently ignored
https://github.com/ruby/open-uri/commit/4b91b11730
-rw-r--r-- | test/open-uri/test_ssl.rb | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/test/open-uri/test_ssl.rb b/test/open-uri/test_ssl.rb index a4e20b553f..2d6149e654 100644 --- a/test/open-uri/test_ssl.rb +++ b/test/open-uri/test_ssl.rb @@ -92,6 +92,26 @@ class TestOpenURISSL } end + def test_validation_ssl_version + with_https {|srv, dr, url| + setup_validation(srv, dr) + URI.open("#{url}/data", :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE, :ssl_version => :TLSv1_2) {|f| + assert_equal("200", f.status[0]) + assert_equal("ddd", f.read) + } + } + end + + def test_validate_bad_ssl_version_silently + with_https {|srv, dr, url| + setup_validation(srv, dr) + URI.open("#{url}/data", :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE, :ssl_version => :TLS_no_such_version) {|f| + assert_equal("200", f.status[0]) + assert_equal("ddd", f.read) + } + } + end + def test_validation_failure unless /mswin|mingw/ =~ RUBY_PLATFORM # on Windows, Errno::ECONNRESET will be raised, and it'll be eaten by @@ -107,16 +127,6 @@ class TestOpenURISSL } end - def test_validation_ssl_version - with_https {|srv, dr, url| - setup_validation(srv, dr) - URI.open("#{url}/data", :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE, :ssl_version => :TLSv1_2) {|f| - assert_equal("200", f.status[0]) - assert_equal("ddd", f.read) - } - } - end - def with_https_proxy(proxy_log_tester=lambda {|proxy_log, proxy_access_log| assert_equal([], proxy_log) }) proxy_log = [] proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN) |