Commit graph

481 commits

Author SHA1 Message Date
Jeremy Evans
20eb9e98b6 [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.

0e8dc91120
2020-08-03 18:55:44 +09:00
Takashi Kokubun
574a4f0217
Skip test_read_body_block_mod for --jit-wait 2020-06-22 10:45:39 -07:00
Takashi Kokubun
7658a0f8fe
Try increasing read_timeout a little more
It failed again
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3018488
2020-06-21 23:21:48 -07:00
Takashi Kokubun
eed4aaa0bf
Increase read_timeout for --jit-wait
This tries to fix a random failure like
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3017837
2020-06-21 16:16:24 -07:00
Takashi Kokubun
ec07e2de1a
Increase read timeout of FTP tests with --jit-wait
Trying to eliminate some newer random failures
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3016543
2020-06-21 02:14:34 -07:00
Takashi Kokubun
80bd3aa32b
Try using longer read_timeout for --jit-wait
failure on TestFTP.

When we skip a test, the place to hang (long wait for compilation)
just moves to another test and it doesn't seem to finish.
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3003055
2020-06-14 15:01:15 -07:00
Takashi Kokubun
1583c743d5
Skip test_getbinaryfile_command_injection on --jit-wait
Timeout-based test often fails with --jit-wait as a false positive.
Like other tests in the TestFTP, let me skip this as well.

http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3001181
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3000134
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2999923
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2998857
2020-06-13 16:33:46 -07:00
Kazuhiro NISHIYAMA
efa8df2886
local_address may raise IOError in debug print
20200605T020004Z.fail.html.gz
```
[  984/20282] IMAPTest#test_connection_closed_without_greeting#<Thread:0x000055b6e9589d28 /home/mame/chkbuild/tmp/build/20200605T020004Z/ruby/test/net/imap/test_imap.rb:133 run> terminated with exception (report_on_exception is true):
/home/mame/chkbuild/tmp/build/20200605T020004Z/ruby/.ext/common/socket.rb:252:in `local_address': closed stream (IOError)
	from /home/mame/chkbuild/tmp/build/20200605T020004Z/ruby/.ext/common/socket.rb:252:in `connect_address'
	from /home/mame/chkbuild/tmp/build/20200605T020004Z/ruby/test/net/imap/test_imap.rb:514:in `block (2 levels) in test_connection_closed_without_greeting'
	from /home/mame/chkbuild/tmp/build/20200605T020004Z/ruby/test/net/imap/test_imap.rb:514:in `each_object'
	from /home/mame/chkbuild/tmp/build/20200605T020004Z/ruby/test/net/imap/test_imap.rb:514:in `each'
	from /home/mame/chkbuild/tmp/build/20200605T020004Z/ruby/test/net/imap/test_imap.rb:514:in `map'
	from /home/mame/chkbuild/tmp/build/20200605T020004Z/ruby/test/net/imap/test_imap.rb:514:in `block in test_connection_closed_without_greeting'
	from /home/mame/chkbuild/tmp/build/20200605T020004Z/ruby/test/net/imap/test_imap.rb:134:in `block in start_server'
```
2020-06-05 11:45:30 +09:00
Kazuhiro NISHIYAMA
e17028e48b
Add sockets to debug print
debug print does not include `in_tcp_socket_2`,
so I think other socket connected to server socket.
Add sockets to debug print, and check other socket is in same process or not.

20200604T160009Z.fail.html.gz
```
  1) Failure:
IMAPTest#test_connection_closed_without_greeting [/export/home/chkbuild/chkbuild-gcc/tmp/build/20200604T160009Z/ruby/test/net/imap/test_imap.rb:523]:
[Net::IMAP::Error] exception expected, not #<RuntimeError: {:server=>#<TCPServer:(closed)>,
 :port=>35490,
 :server_created=>
  {:server=>"#<TCPServer:fd 10, AF_INET6, ::1, 35490>", :t=>45917010.30510591},
 :in_start_server_before_accept=>{:t=>45917010.305154555},
 :in_tcp_socket=>
  {:host=>"::1",
   :port=>35490,
   :server=>"#<TCPServer:fd 10, AF_INET6, ::1, 35490>",
   :t=>45917010.40560127},
 :in_start_server=>
  {:sock_addr=>["AF_INET6", 35490, "::1", "::1"],
   :sock_peeraddr=>["AF_INET6", 51584, "::1", "::1"],
   :t=>45917010.40767231},
 :in_start_server_sock_closed=>{:t=>45917010.40770047},
 :in_rescue=>
  {:e=>#<Errno::EINVAL: Invalid argument - connect(2) for [::1]:35490>,
   :server_addr=>"::1",
   :t=>45917010.40867455}}
>.
```
2020-06-05 10:48:47 +09:00
Hiroshi SHIBATA
3e8e4c0505 [ruby/net-ftp] Added guard condition for the old ruby versions
a56ba121ee
2020-04-08 15:51:18 +09:00
Hiroshi SHIBATA
0c131fb7ff [ruby/net-ftp] Guard with under the Ruby 2.6
bed4bc31db
2020-04-08 15:50:48 +09:00
Takashi Kokubun
ba04678c98
Ignore test_getbinaryfile for --jit-wait
To fix this properly, we'd need to configure timeout for the server and
the client because waiting for compilation takes time.

Until we figure out how to do it, let me skip this.
2020-03-25 22:54:23 -07:00
Yusuke Endoh
5908914ea2 test/net/http/test_http.rb: relax open_timeout limit
The test fails randomly on the CI of OpenCSW SPARC Solaris 10:

20200321T091909Z.fail.html.gz
```
  1) Failure:
TestNetHTTP_v1_2_chunked#test_timeout_during_HTTP_session [/export/home/rubyci/unstable10s/tmp/build/20200321T091909Z/ruby/test/net/http/test_http.rb:575]:
[Net::ReadTimeout] exception expected, not #<Net::OpenTimeout: execution expired>.
```

The environment uses RUBY_TEST_SUBPROCESS_TIMEOUT_SCALE=20, so the open
timeout 0.1 sec. means 2.0 sec. for the environment, but it seems too
strict because the environment is painfully slow.
2020-03-21 23:09:17 +09:00
Takashi Kokubun
a90117c8c9
Skip test_abort_tls with --jit-wait for now
Perhaps the server blocks for an unexpectedly long time by waiting for
JIT. As it's usually passing, I don't think it's detecting a bug.
2020-03-12 18:43:03 -07:00
Takashi Kokubun
e0512b29aa
Let Net::HTTP.get take request headers (#2957)
* Let Net::HTTP.get take request headers

* Add more test cases for no header usages

* Add examples with request headers

* Add a NEWS entry [ci skip]

[Feature #16686]
2020-03-10 22:26:22 -07:00
Nobuyoshi Nakada
f08cd708b1
Fixed FD leak 2020-03-04 23:26:57 +09:00
Hiroshi SHIBATA
9cb1ffaa5c
Promote net-http to the default gems.
test/net/http/test_https.rb: rename fixture methods to read_fixture
  because it conflicts with test-unit gem.
2020-02-21 21:21:14 +09:00
Kazuhiro NISHIYAMA
d142b37bdc
Add more debug print
20200129T022510Z.fail.html.gz
2020-01-29 15:00:03 +09:00
Kazuhiro NISHIYAMA
838fa941f1
Add more debug print
20200125T032406Z.fail.html.gz
```
IMAPTest#test_connection_closed_without_greeting [/export/home/rubyci/chkbuild-tmp/tmp/build/20200125T032406Z/ruby/test/net/imap/test_imap.rb:485]:
[Net::IMAP::Error] exception expected, not #<RuntimeError: {:"server before close"=>"#<TCPServer:fd 10, AF_INET6, ::1, 48515>", :sock_addr=>["AF_INET6", 48515, "::1", "::1"], :sock_peeraddr=>["AF_INET6", 35223, "::1", "::1"], :e=>#<Errno::EINVAL: Invalid argument - connect(2) for [::1]:48515>, :server=>#<TCPServer:(closed)>, :port=>48515, :server_addr=>"::1"}>.
```
2020-01-26 20:03:27 +09:00
Yuta Iwama
be6931f7f7 Add #verify_hostname= and #verify_hostname to skip hostname verification (#2858)
According to https://github.com/ruby/openssl/pull/60,

> Currently an user who wants to do the hostname verification needs to
call SSLSocket#post_connection_check explicitly after the TLS connection
is established.

if an user who wants to skip the hostname verification,
SSLSocket#post_connection_check doesn't need to be called

https://bugs.ruby-lang.org/issues/16555
2020-01-23 17:23:17 +09:00
Yusuke Endoh
251f5d8226 Revert "lib/net/http/response.rb: support raw deflate correctly"
This reverts commit 5105240b1e.

In RFC 2616:

```
   deflate
        The "zlib" format defined in RFC 1950 [31] in combination with
        the "deflate" compression mechanism described in RFC 1951 [29].
```

So "Content-Encoding: deflate" means zlib format, not raw deflate.

[Bug #11268]
2019-12-16 23:39:10 +09:00
Yusuke Endoh
5105240b1e lib/net/http/response.rb: support raw deflate correctly
Net::HTTP had used `Zlib::Inflate.new(32 + Zlib::MAX_WBITS)` for all
content encoding (deflate, zlib, and gzip).
But the argument `32 + Zlib::MAX_WBITS` means zlib and gzip decoding
with automatic header detection, so (raw) deflate compression had not
been supported.

This change makes it support raw deflate correctly by passing an
argument `-Zlib::MAX_WBITS` (which means raw deflate) to
`Zlib::Inflate.new`.  All deflate-mode tests are fixed too.

[Bug #11268]
2019-12-16 23:20:42 +09:00
Kazuhiro NISHIYAMA
a83c46e3fd
Add more debug info
closed server doesn't have useful info.
So call inspect before close.
And add local debug code in comment.

20191215T092405Z.fail.html.gz
```
  1) Failure:
IMAPTest#test_connection_closed_without_greeting [/export/home/rubyci/chkbuild-tmp/tmp/build/20191215T092405Z/ruby/test/net/imap/test_imap.rb:483]:
[Net::IMAP::Error] exception expected, not #<RuntimeError: {:e=>#<Errno::EINVAL: Invalid argument - connect(2) for [::1]:41748>, :server=>#<TCPServer:(closed)>, :port=>41748, :server_addr=>"::1"}>.
```
2019-12-15 20:09:24 +09:00
Kazuhiro NISHIYAMA
68321dd1fa
Move rescue for debug into block of assert_raise 2019-12-12 22:05:14 +09:00
Kazuhiro NISHIYAMA
c20dd2f754
Add more debug info when Errno::EINVAL
20191212T072406Z.fail.html.gz
2019-12-12 17:38:27 +09:00
NARUSE, Yui
af11efd377 fix ipaddr parameter of Net::HTTP.start to support proxy
54072e329c
2019-12-10 19:12:21 +09:00
Yusuke Endoh
660388f6c5 test/net/http/test_https.rb (test_get_SNI_failure): stop proxy settings
Because the test fails under HTTP proxy settings.

20191210T000004Z.fail.html.gz
```
  1) Failure:
TestNetHTTPS#test_get_SNI_failure [/export/home/users/chkbuild/cb-gcc/tmp/build/20191210T000004Z/ruby/test/net/http/test_https.rb:81]:
[OpenSSL::SSL::SSLError] exception expected, not #<Net::HTTPServerException: 403 "Forbidden">.
```

The new SNI feature introduced at 54072e329c may need to be improved for
HTTP proxy environment.
2019-12-10 09:41:33 +09:00
NARUSE, Yui
54072e329c Add ipaddr optional parameter to Net::HTTP#start
to replace the address for TCP/IP connection [Feature #5180]

There're 3 layers of hostname:
* host address for TCP/IP
* TLS server name
* HTTP Host header value
To test DNS round robin or check server certificate from server local,
people sometimes want to connect server with given IP address but keep
TLS server name and HTTP Host header value.

closes [Feature #15215]
closes https://github.com/ruby/ruby/pull/1893
closes https://github.com/ruby/ruby/pull/1977
2019-12-09 20:21:49 +09:00
Jeremy Evans
ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind
version guards.  This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
Jeremy Evans
c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
This removes the security features added by $SAFE = 1, and warns for access
or modification of $SAFE from Ruby-level, as well as warning when calling
all public C functions related to $SAFE.

This modifies some internal functions that took a safe level argument
to no longer take the argument.

rb_require_safe now warns, rb_require_string has been added as a
version that takes a VALUE and does not warn.

One public C function that still takes a safe level argument and that
this doesn't warn for is rb_eval_cmd.  We may want to consider
adding an alternative method that does not take a safe level argument,
and warn for rb_eval_cmd.
2019-11-18 01:00:25 +02:00
Jeremy Evans
2b6a9f3a1f Ignore Errno::EPIPE when sending requests in net/http
An EPIPE when sending the request should be ignored.  Even if you
cannot write more data, you may still be able to read the server's
response.

Fixes [Bug #14466]
2019-09-27 07:43:32 -07:00
Shugo Maeda
633ae3278e
Add Net::FTP#features and Net::FTP#option
Patch by darkphnx (Dan Wentworth) .  Thanks!
[Feature #15964]
2019-09-02 14:43:51 +09:00
Espartaco Palma
2665e5858f Adding missing test for Net::HTTPGenericRequest initializer (#1835)
A new exception is raised if an URI::HTTP is received and that object doesn't
have a hostname property.
Complementary to #1278
2019-08-16 01:38:46 +09:00
Nobuyoshi Nakada
11662c70b0
Test missing Content-Type warnings 2019-07-24 01:42:45 +09:00
Nobuyoshi Nakada
c9826c20d2
Show the caller's location
* lib/net/http/header.rb: show the caller's location instead of
  the current lines.
2019-07-24 00:26:28 +09:00
Nobuyoshi Nakada
409b0ec4c3
Suppress unused variable warnings 2019-06-30 11:45:37 +09:00
Nobuyoshi Nakada
45ba027d08
Removed unused variables 2019-06-30 08:45:01 +09:00
Nobuyoshi Nakada
7ba14b029c
Add max option to TestProtocol#create_mockio
* test/net/protocol/test_protocol.rb (TestProtocol#create_mockio):
  max option to limit maximum writable size at once, and unify
  mock method in test_write0_multibyte.
2019-06-29 17:52:57 +09:00
Yusuke Endoh
1cbc4f9876 test/net/imap/test_imap.rb: use Thread#stop? to wait for server thread
Still timeout occurs.  Retry for 5dd8fdd3f3.
20190625T032405Z.fail.html.gz
2019-06-25 17:22:02 +09:00
Yusuke Endoh
5dd8fdd3f3 test/net/imap/test_imap.rb: wait for the server thread to start
In some slow CI environments, the invocation of a thread seems very
slow.  This causes a test failure to attempt to connect a server that
does not start yet.

20190615T002420Z.fail.html.gz
20190611T022407Z.fail.html.gz
2019-06-15 11:06:39 +09:00
Yusuke Endoh
6096baea5d test/net/http/test_http.rb: Extend the timeout
20190610T071910Z.log.html.gz
2019-06-11 06:45:49 +09:00
Yusuke Endoh
60924636e5 test/net/http/test_http.rb: extend the timeout for Solaris CI
20190605T231909Z.fail.html.gz
2019-06-06 21:50:21 +09:00
mrkn
888ddda157 test/net/fixtures/Makefile: moved from test/net/imap
This Makefile can be used to update test certificates.  It should have been
moved at which the certificates was moved at r56836.

[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-02 04:18:34 +00:00
kazu
1e0b49a293 Try to update cert (2nd try)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-02 03:29:01 +00:00
kazu
f234e6c3d3 Try to update cert
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-02 03:08:20 +00:00
nobu
1680a13a92 Fix Net::Protocol::BufferedIO#write when sending large multi-byte string
This commit should fix Net::Protocol::BufferedIO#write when sending
large multi-byte string like following example.

```
$ ruby -rnet/http -rjson -v -e "Net::HTTP.post(URI('http://httpbin.org/post'), { text: 'あ'*100_000 }.to_json, 'Content-Type' => 'application/json')"
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
Traceback (most recent call last):
        19: from -e:1:in `<main>'
        18: from lib/ruby/2.6.0/net/http.rb:500:in `post'
        17: from lib/ruby/2.6.0/net/http.rb:605:in `start'
        16: from lib/ruby/2.6.0/net/http.rb:920:in `start'
        15: from lib/ruby/2.6.0/net/http.rb:502:in `block in post'
        14: from lib/ruby/2.6.0/net/http.rb:1281:in `post'
        13: from lib/ruby/2.6.0/net/http.rb:1493:in `send_entity'
        12: from lib/ruby/2.6.0/net/http.rb:1479:in `request'
        11: from lib/ruby/2.6.0/net/http.rb:1506:in `transport_request'
        10: from lib/ruby/2.6.0/net/http.rb:1506:in `catch'
         9: from lib/ruby/2.6.0/net/http.rb:1507:in `block in transport_request'
         8: from lib/ruby/2.6.0/net/http/generic_request.rb:123:in `exec'
         7: from lib/ruby/2.6.0/net/http/generic_request.rb:189:in `send_request_with_body'
         6: from lib/ruby/2.6.0/net/protocol.rb:247:in `write'
         5: from lib/ruby/2.6.0/net/protocol.rb:265:in `writing'
         4: from lib/ruby/2.6.0/net/protocol.rb:248:in `block in write'
         3: from lib/ruby/2.6.0/net/protocol.rb:275:in `write0'
         2: from lib/ruby/2.6.0/net/protocol.rb:275:in `each_with_index'
         1: from lib/ruby/2.6.0/net/protocol.rb:275:in `each'
lib/ruby/2.6.0/net/protocol.rb:280:in `block in write0': undefined method `bytesize' for nil:NilClass (NoMethodError)
```

[Fix GH-2058]

From: Eito Katagiri <eitoball@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-27 04:49:12 +00:00
naruse
1bf066dcfa Preserve HTTP header key as string [Bug #15394]
to prevent send Host header twice accidentally.

From: Sangyong Sim <sangyong-sim@cookpad.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-10 23:54:14 +00:00
k0kubun
ed42b0102d test_ftp.rb: loosen another timeout requirement
for Travis osx.
454864155

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-14 08:21:05 +00:00
k0kubun
2a477e0e44 test_ftp.rb: loosen timeout for Travis osx
454798071

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-14 07:44:30 +00:00
k0kubun
3f1524f0d2 test_ftp.rb: extend timeout for --jit-wait testing
to avoid random failures like
5be394b818

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08 04:06:15 +00:00