Skip to content

Commit

Permalink
[ruby/open-uri] fix: added test case that validates that bad TLS vers…
Browse files Browse the repository at this point in the history
…ion is silently ignored

ruby/open-uri@4b91b11730
  • Loading branch information
nishantactive authored and matzbot committed Oct 6, 2022
1 parent cdbaac3 commit 43e9250
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions test/open-uri/test_ssl.rb
Expand Up @@ -92,6 +92,26 @@ def test_validation_noverify
}
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
Expand All @@ -107,16 +127,6 @@ def test_validation_failure
}
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)
Expand Down

0 comments on commit 43e9250

Please sign in to comment.