Skip to content

Commit

Permalink
[ruby/net-http] Switch invalid server name format
Browse files Browse the repository at this point in the history
invalid_servername is not a valid name in an SSL request due to
the use of the underscore, and LibreSSL 3.2.0 will raise an
exception for this.  These tests are not testing the allowed
characters in the server name, but how net/http handles cases where
the server name provided does not match the IP address you are
trying to connect to, so I think it's better to just modify the
tests to use a correct format.

While here, fix a typo in a test name, and use better code in the
ensure block so the same test doesn't issue both a failure and an
error.

ruby/net-http@0e8dc91120
  • Loading branch information
jeremyevans authored and hsbt committed Aug 3, 2020
1 parent e732d37 commit 20eb9e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/net/http/test_https.rb
Expand Up @@ -108,7 +108,7 @@ def test_get_SNI_proxy

def test_get_SNI_failure
TestNetHTTPUtils.clean_http_proxy_env do
http = Net::HTTP.new("invalid_servername", config("port"))
http = Net::HTTP.new("invalidservername", config("port"))
http.ipaddr = config('host')
http.use_ssl = true
http.cert_store = TEST_STORE
Expand Down Expand Up @@ -204,22 +204,22 @@ def test_verify_none
skip $!
end

def test_skip_hostname_verfiction
def test_skip_hostname_verification
TestNetHTTPUtils.clean_http_proxy_env do
http = Net::HTTP.new('invalid_servername', config('port'))
http = Net::HTTP.new('invalidservername', config('port'))
http.ipaddr = config('host')
http.use_ssl = true
http.cert_store = TEST_STORE
http.verify_hostname = false
assert_nothing_raised { http.start }
ensure
http&.finish
http.finish if http&.started?
end
end

def test_fail_if_verify_hostname_is_true
TestNetHTTPUtils.clean_http_proxy_env do
http = Net::HTTP.new('invalid_servername', config('port'))
http = Net::HTTP.new('invalidservername', config('port'))
http.ipaddr = config('host')
http.use_ssl = true
http.cert_store = TEST_STORE
Expand Down

0 comments on commit 20eb9e9

Please sign in to comment.