1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/open-uri] fix: added test case that validates that bad TLS version is silently ignored

https://github.com/ruby/open-uri/commit/4b91b11730
This commit is contained in:
Nishant Patel 2022-02-16 16:59:28 +11:00 committed by git
parent cdbaac3f4b
commit 43e925090b

View file

@ -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)