[前][次][番号順一覧][スレッド一覧]

ruby-changes:62518

From: Jeremy <ko1@a...>
Date: Mon, 3 Aug 2020 19:01:22 +0900 (JST)
Subject: [ruby-changes:62518] 20eb9e98b6 (master): [ruby/net-http] Switch invalid server name format

https://git.ruby-lang.org/ruby.git/commit/?id=20eb9e98b6

From 20eb9e98b65352422fbb1197eb8699bfcb12d5ef Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Wed, 29 Jul 2020 12:34:07 -0700
Subject: [ruby/net-http] Switch invalid server name format

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.

https://github.com/ruby/net-http/commit/0e8dc91120

diff --git a/test/net/http/test_https.rb b/test/net/http/test_https.rb
index 660104d..7660ef6 100644
--- a/test/net/http/test_https.rb
+++ b/test/net/http/test_https.rb
@@ -108,7 +108,7 @@ class TestNetHTTPS < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/net/http/test_https.rb#L108
 
   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
@@ -204,22 +204,22 @@ class TestNetHTTPS < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/net/http/test_https.rb#L204
     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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]