[rubygems/rubygems] test_bundled_ca.rb: Add Net::OpenTimeout as a offline case.

It seems that when DNS connection is enabled, but the TCP connection is
disabled in a way, the `Net::HTTP.connect` raises `Net::OpenTimeout`.
And I want to skip the tests in this case.

042faf74e7/lib/net/http.rb (L1601-L1608)

```
  1) Error:
TestBundledCA#test_accessing_new_index:
Net::OpenTimeout: execution expired
    /builddir/build/BUILD/ruby-3.0.4/lib/net/http.rb:987:in `initialize'
    /builddir/build/BUILD/ruby-3.0.4/lib/net/http.rb:987:in `open'
    /builddir/build/BUILD/ruby-3.0.4/lib/net/http.rb:987:in `block in connect'
    /builddir/build/BUILD/ruby-3.0.4/lib/timeout.rb:107:in `timeout'
    /builddir/build/BUILD/ruby-3.0.4/lib/net/http.rb:985:in `connect'
    /builddir/build/BUILD/ruby-3.0.4/lib/net/http.rb:970:in `do_start'
    /builddir/build/BUILD/ruby-3.0.4/lib/net/http.rb:959:in `start'
    /builddir/build/BUILD/ruby-3.0.4/lib/net/http.rb:1512:in `request'
    /builddir/build/BUILD/ruby-3.0.4/lib/net/http.rb:1270:in `get'
    /builddir/build/BUILD/ruby-3.0.4/test/rubygems/test_bundled_ca.rb:34:in `assert_https'
    /builddir/build/BUILD/ruby-3.0.4/test/rubygems/test_bundled_ca.rb:58:in `test_accessing_new_index'
...
```

https://github.com/rubygems/rubygems/commit/5defe0a2f6
This commit is contained in:
Jun Aruga 2023-12-05 14:07:29 +09:00 committed by git
parent d9a1bb4b09
commit 538ff35133

View File

@ -33,7 +33,7 @@ class TestGemBundledCA < Gem::TestCase
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.cert_store = bundled_certificate_store
http.get("/")
rescue Errno::ENOENT, Errno::ETIMEDOUT, SocketError
rescue Errno::ENOENT, Errno::ETIMEDOUT, SocketError, Net::OpenTimeout
pend "#{host} seems offline, I can't tell whether ssl would work."
rescue OpenSSL::SSL::SSLError => e
# Only fail for certificate verification errors