summaryrefslogtreecommitdiff
path: root/test/resolv
AgeCommit message (Collapse)Author
2024-11-26[ruby/resolv] Omit Windows and MinGW platforms with with_udp_and_tcpHiroshi SHIBATA
https://github.com/ruby/resolv/actions/runs/12021339854/job/33511655994?pr=64 ``` => 705: with_udp_and_tcp('127.0.0.1', 0) do |u1, t1| 706: with_udp_and_tcp('127.0.0.1', 0) do |u2,t2| 707: u2.close # XXX: u2 UDP socket is not used, but using #with_udp_and_tcp to enable Windows EACCES workaround 708: _, server1_port, _, server1_address = u1.addr Error: Errno::EACCES: Permission denied - bind(2) for "127.0.0.1" port 55685 ``` https://github.com/ruby/ruby/actions/runs/12005069051/job/33461068529?pr=12161 ``` 1) Error: TestResolvDNS#test_multiple_servers_with_timeout_and_truncated_tcp_fallback: Errno::EACCES: Permission denied - bind(2) for "127.0.0.1" port 50676 D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TCPServer#initialize' D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TCPServer.new' D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TestResolvDNS#with_udp_and_tcp' D:/a/ruby/ruby/src/test/resolv/test_dns.rb:705:in 'TestResolvDNS#test_multiple_servers_with_timeout_and_truncated_tcp_fallback' ``` https://github.com/ruby/resolv/commit/05765df178
2024-11-26[ruby/resolv] _1 is not provided in Ruby 2.5Hiroshi SHIBATA
https://github.com/ruby/resolv/commit/83f18e2a49
2024-10-10test/resolv/test_dns.rb: Keep `UDPSocket`s until a free port is foundYusuke Endoh
Follow up to 589f1978d8c368b8eccf34453463ad46a58d36da I suspect `UDPSocket.new` grabs the same port number because they are closed at each trial. Notes: Merged: https://github.com/ruby/ruby/pull/11863
2024-10-09mingw environment can't bind free port with 10 times. We should omit it ↵Hiroshi SHIBATA
instead of test failure. ``` 1) Error: TestResolvDNS#test_multiple_servers_with_timeout_and_truncated_tcp_fallback: Errno::EACCES: Permission denied - bind(2) for "127.0.0.1" port 59677 D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TCPServer#initialize' D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TCPServer.new' D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TestResolvDNS#with_udp_and_tcp' D:/a/ruby/ruby/src/test/resolv/test_dns.rb:711:in 'TestResolvDNS#test_multiple_servers_with_timeout_and_truncated_tcp_fallback' 2) Error: TestResolvDNS#test_query_ipv4_address_truncated_tcp_fallback: Errno::EACCES: Permission denied - bind(2) for "127.0.0.1" port 59689 D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TCPServer#initialize' D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TCPServer.new' D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TestResolvDNS#with_udp_and_tcp' D:/a/ruby/ruby/src/test/resolv/test_dns.rb:223:in 'TestResolvDNS#test_query_ipv4_address_truncated_tcp_fallback' ``` Notes: Merged: https://github.com/ruby/ruby/pull/11842
2024-10-08Specify use_ipv6 option for ipv4 testHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/11828
2024-09-10[ruby/resolv] test_dns: Fix FD leakKasumi Hanazuki
The listening TCP socket is closed by `with_udp_and_tcp` helper, but the connected socket is leaking. ``` Leaked file descriptor: TestResolvDNS#test_multiple_servers_with_timeout_and_truncated_tcp_fallback: 12 : #<TCPSocket:fd 12, AF_INET, 127.0.0.1, 50888> COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ruby 3248055 chkbuild 12u IPv4 112546322 0t0 TCP localhost:50888->localhost:40112 (CLOSE_WAIT) ``` For the purpose of the test case to simulate a timeout over TCP transport, we have to delay closing this socket until the end the test case. Fixup: https://github.com/ruby/resolv/pull/50 https://github.com/ruby/resolv/commit/236c38bdb1
2024-08-22Suppress warning for fd leakHiroshi SHIBATA
``` Leaked file descriptor: TestResolvDNS#test_multiple_servers_with_timeout_and_truncated_tcp_fallback: 15 : #<TCPSocket:fd 15, AF_INET, 127.0.0.1, 61633> ``` Notes: Merged: https://github.com/ruby/ruby/pull/11428
2024-08-13[ruby/resolv] test_dns: Fix failure on WindowsSorah Fukumori
(https://github.com/ruby/resolv/pull/58) test_dns: Fix failure on Windows 1. Switch to #with_udp_and_tcp helper method for EACCES retries on Windows; the given UDP socket is unnecessary though. 2. Using 127.0.0.1 should be fine, as it must give different host:port pair. 3. On Windows, 5 retries of bind(2) appears still flaky, doubling it for sure. follow-up: https://github.com/ruby/resolv/pull/50 follow-up: https://github.com/ruby/resolv/commit/6252914e95dfdf8995d8074df6cafe6f0a76c1ca https://github.com/ruby/resolv/commit/0a0d57e369
2024-08-13[ruby/resolv] Fix TCP fallback with multiple nameserversIgor Pstyga
Under the following conditions the exception `Resolv::DNS::Requester::RequestError: host/port don't match` is raised: - Multiple nameservers are configured for Resolv::DNS - A nameserver falls back from UDP to TCP - TCP request hits Resolv::DNS timeout - Resolv::DNS retries the next nameserver More details here https://bugs.ruby-lang.org/issues/8285 https://github.com/ruby/resolv/commit/7d524df80e Co-authored-by: Julian Mehnle <[email protected]>
2024-03-31[ruby/resolv] Add an explicit with_udp_and_tcp helper to test_dns.rbKJ Tsanaktsidis
This helper tries to bind UDP and TCP sockets to the same port, by retrying the bind if the randomly-assinged UDP port is already taken in TCP. This fixes a flaky test. [Bug #20403] https://github.com/ruby/resolv/commit/3d135f99d9
2024-02-29[ruby/resolv] Implement CAA resource recordKasumi Hanazuki
This patch implements handling of CAA resource records defined by [RFC8659]. - There are no known deployment of CAA records outside of IN (Internet), but the RFC does not state that CAA records are class-specific. Thus `CAA` class is defined as a class-independent RRType. - `CAA` class stores `flags` field (a 1-octet bitset) as an Integer. In this way it's easier to ensure the encoded RR is in the valid wire format. [RFC8659]: https://datatracker.ietf.org/doc/html/rfc8659 https://github.com/ruby/resolv/commit/cfc4de75e3 Co-authored-by: aeris <[email protected]>
2023-11-26[ruby/resolv] Close leaked FDNobuyoshi Nakada
https://github.com/ruby/resolv/commit/49aefa3bba
2023-11-25[ruby/resolv] Support a :raise_timeout_errors option to raise timeouts as ↵Jeremy Evans
Resolv::ResolvError This allows to differentiate a timeout from an NXDOMAIN response. Fixes [Bug #18151] https://github.com/ruby/resolv/commit/c0e5abab76
2023-11-24[ruby/resolv] Fix the fallback from UDP to TCP due to message truncationJeremy Evans
If truncation is detected, return immediately from decode so that the UDP connection can be retried with TCP, instead of failing to decode due to trying to decode a truncated response. Fixes [Bug #13513] https://github.com/ruby/resolv/commit/0de996dbca
2023-11-24[ruby/resolv] Implement dohpath SvcParamKasumi Hanazuki
(https://github.com/ruby/resolv/pull/33) * Implement dohpath SvcParam [RFC 9461] This patch implements "dohpath" SvcParam proposed in [draft-ietf-add-svcb-dns-08]. This parameter specifies a URI template for the :path used in DNS-over-HTTPS requests. "dohpath" is employed by [DDR], also a to-be-published Proposed Standard that specifies how to upgrade DNS transport to a more secure one, i.d., DNS-over-TLS or DNS-over-HTTPS. DDR is deployed in the public DNS resolvers including Cloudflare DNS, Google Public DNS, and Quad9. [RFC 9461]: https://datatracker.ietf.org/doc/rfc9461/ [DDR]: https://datatracker.ietf.org/doc/draft-ietf-add-ddr/ https://github.com/ruby/resolv/commit/da9c023539 Co-authored-by: Sorah Fukumori <[email protected]>
2023-11-24[ruby/resolv] Implement SVCB and HTTPS RRsKasumi Hanazuki
(https://github.com/ruby/resolv/pull/32) * Add MessageDecoder#get_list This method repeats yielding until all the data upto the current limit is consumed, and then returns an Array containig the block results. * Implement SVCB and HTTPS RRs [RFC 9460] > This patch implements SVCB and HTTPS resource record types defined in > [RFC 9460]. > > The RR types are now supported by many server implementations including > BIND, unbound, PowerDNS, and Knot DNS. Major browsers such as Chrome, > Edge, and Safari have started to query HTTPS records, with the records > gradually adopted by websites. Also, SVCB is actually deployed in the > public DNS resolvers such as Cloudflare DNS and Google Public DNS for > [DDR]. > > With such wide adoption, we have plenty of real-world use cases, and > it is unlikely the wire format will change further in an incompatible > way. It is time to implement them in the client libraries! > > # Rationale for proposed API > > ## `Resolv::DNS::Resource::IN::ServiceBinding` > > This is an abstract class for SVCB-compatible RR types. > SVCB-compatible RR types, as defined in the Draft, shares the wire > format and the semantics of their RDATA fields with SVCB to allow > implementations to share the processing of these RR types. So we do > so. > > The interface of this class is straightforward: It has three > attributes `priority`, `target`, and `params`, which correspond the > RDATA fields SvcPriority, TargetName, and SvcParams, resp. > > SVCB RR type is defined specifically within IN class. Thus, this > class is placed in the `Resolv::DNS::Resource::IN` namespace. > > ## `Resolv::DNS::Resource::IN::SVCB`, `Resolv::DNS::Resource::IN::HTTPS` > > Just inherits ServiceBinding class. > > ## `Resolv::DNS::SvcParam` > > This class represents a pair of a SvcParamKey and a SvcParamValue. > Aligned with the design of `Resolv::DNS::Resource`, each SvcParamKey > has its own subclass of `Resolv::DNS::SvcParam`. > > ## `Resolv::DNS::SvcParam::Generic` > > This is an abstract class representing a SvcParamKey that is unknown > to this library. `Generic.create(key)` dynamically defines its > subclass for specific `key`. E.g., `Generic.create(667)` will define > `Generic::Key667`. > > This class holds SvcParamValue in its wire format. > > SvcParam with an unknown SvcParamKey will be decoded as a subclass of > this class. Also, users of this library can generate a non-supported > SvcParam if they know its wire format. > > ## `Resolv::DNS::SvcParams` > > This is conceptually a set of `SvcParam`s, whose elements have the > unique SvcParamKeys. It behaves like a set, and for convenience > provides indexing by SvcParamKey. > > - `#initialize(params)` takes an Enumerable of `SvcParam`s as the > initial content. If it contains `SvcParam`s with the duplicate key, > the one that appears last takes precedence. > - `#[](key)` fetches the `SvcParam` with the given key. The key can be > specified by its name (e.g., `:alpn`) or number (e.g., `1`). > - `#add(param)` adds a `SvcParam` to the set. If the set already has a > `SvcParam` with the same key, it will be replaced. > - `#delete(key)` deletes a `SvcParam` by its key and returns it. The key > can be specified by its name or number. * Update comments referring to draft-ietf-dnsop-svcb-https-12 Published as RFC 9460. https://datatracker.ietf.org/doc/rfc9460/ [draft-ietf-dnsop-svcb-https-12]: https://datatracker.ietf.org/doc/draft-ietf-dnsop-svcb-https/12/ [RFC 9460]: https://datatracker.ietf.org/doc/rfc9460/ [DDR]: https://datatracker.ietf.org/doc/draft-ietf-add-ddr/ https://github.com/ruby/resolv/commit/b3ced7f039
2023-11-22[ruby/resolv] IPv6: update to_s method to be RFC5952 compliantJohn Bond
(https://github.com/ruby/resolv/pull/25) * IPv6: update to_s method to be RFC5952 compliant I noticed that the resolv library does not honour RFC 5952 Section 4.2.2. in relation to textural representation of ipv6 addresses: The symbol "::" MUST NOT be used to shorten just one 16-bit 0 field. For example, the representation 2001:db8:0:1:1:1:1:1 is correct, but 2001:db8::1:1:1:1:1 is not correct. Fixes https://github.com/ruby/resolv/pull/24 https://github.com/ruby/resolv/commit/5efcd6ed70 Co-authored-by: Sorah Fukumori <[email protected]>
2023-04-08[ruby/resolv] Do not compress domain name in SRV RDATAKasumi Hanazuki
[RFC2782] prohibits use of name compression for the target host name in the RDATA of a SRV record. [RFC2782]: https://datatracker.ietf.org/doc/rfc2782/ Closes: https://github.com/ruby/resolv/issues/29 https://github.com/ruby/resolv/commit/ac85724e17
2022-01-12[ruby/resolv] Use omit instead of skip for test-unitHiroshi SHIBATA
https://github.com/ruby/resolv/commit/55e42221d4
2022-01-12[ruby/resolv] Support more characters in link local addressesJeremy Evans
Implements [Feature #17524] https://github.com/ruby/resolv/commit/993a1a374f
2021-05-19Removed minitest/mockHiroshi SHIBATA
2021-05-11Run nmake check on Actions (#4487)Takashi Kokubun
* Run nmake check on Actions * Skip tests not working in mswin GitHub Actions * Override TEMP * Revert "Skip tests not working in mswin GitHub Actions" This reverts commit 544d2575fcdf23ae63cd25aa03fce10c28b259f2. * Revert "Revert "Skip tests not working in mswin GitHub Actions"" This reverts commit e1f8ad7862c9c4be52dc6e1031a004621eb07e6e. * Fix timeouts * Skip some more broken tests * Update windows.yml * Add a guard for rbasic_spec * Revert "Update windows.yml" This reverts commit bc9694b6b3b9594d406378d15ca11723fb052bc8. * Skip the ensure clause * Simplify the ensure Notes: Merged-By: k0kubun <[email protected]>
2020-11-09`fe80` should be case insensitive tooKazuhiro NISHIYAMA
2020-11-08test/resolv/test_dns.rb: suppress "assigned but unused variable"Yusuke Endoh
2020-11-07Add support for IPv6 link local addresses to resolvJeremy Evans
Now that it should work correctly, test that every address returned by Socket.ip_address_list is resolvable. Socket works with IPv6 link local addresses, and ipaddr now does as well, so I think resolv should support them. Fixes [Bug #17112] Notes: Merged: https://github.com/ruby/ruby/pull/3452
2020-11-07Remove sender/message_id pair after response received in resolvJeremy Evans
Once a response for a given DNS request has been received (which requires a matching message id), the [sender, message_id] pair should be removed from the list of valid senders. This makes it so duplicate responses from the same sender are ignored. Fixes [Bug #12838] Notes: Merged: https://github.com/ruby/ruby/pull/3536
2019-12-30MinGW on Actions (#2791)MSP-Greg
* MinGW - skip spec in spec/ruby/optional/capi/thread_spec.rb C-API Thread function rb_thread_call_without_gvl -- runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO stops/freezes spec tests See https://bugs.ruby-lang.org/issues/16265 * MinGW - skip test test/resolv/test_dns.rb Test times out in CI (both AppVeyor & Actions), cannot repo locally * MinGW - skip test test/ruby/test_thread_queue.rb * Add Actions mingw.yml
2019-07-30Use lowercase letters for IPv6 addresses.Tanaka Akira
Reported by chucke (Tiago Cardoso). Patch by jeremyevans0 (Jeremy Evans). [Bug #14612]
2019-06-08Make Resolv::DNS#each_name accept Resolv::IPv{4,6} argumentsJeremy Evans
These arguments were previously documented as supported, but not actually supported. Patch from Toru Iwase Fixes [Bug #15900]
2018-11-11Fix a typo [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-06use the reference as failure messagesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-06resolv.rb: close socketnobu
* lib/resolv.rb (UnconnectedUDP#lazy_initialize): store new sockets before binding, so the sockets get closed when the requester is closing. * lib/resolv.rb (ConnectedUDP#lazy_initialize): ditto. * lib/resolv.rb (UnconnectedUDP#close): synchronize to get rid of race condition. * lib/resolv.rb (ConnectedUDP#close): ditto. [ruby-core:85901] [Bug #14571] From: quixoten (Devin Christensen) <[email protected]> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11fix for IPv6 envnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11Mock fetching data from real DNS [Feature #14340]naruse
This test just tests MDNS#each_address method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20fix test errors on Windowsusa
* test/resolv/test_addr.rb (test_hosts_by_command): on Windows, `|` is invalid charactor for path and raises `Errno::EINVAL` if trying to open. * test/resolv/test_dns.rb (test_resolv_conf_by_command): ditto. cf. [Bug #14205] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20Fixed command Injectionnobu
* lib/resolv.rb (Resolv::Config.parse_resolv_conf): fixed potential command injection by use of Kernel#open. [ruby-core:84347] [Bug #14205] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Handle Errno::EADDRNOTAVAIL with Raspberry Pi environment.hsbt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Fixed unexpected behavior of `Resolv::MDNS#each_address` when given ".local" ↵hsbt
address. https://github.com/ruby/ruby/pull/1425 Patch by @elct9620 [fix GH-1484] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-14Made #decode_rdata client to catch errorsnobu
* lib/resolv.rb (Resolv::DNS::Message::MessageDecoder#get_rr): re-raise an exception from decode_rdata as DecodeError, so it can report them to the top in more informative way. It was not reflecting on errors of data and thus breaking. Client code expects `DecodeError` and knows how to handle broken messages. [Fix GH-1511] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05fix Resolv::LOC::Coord.create.akr
* lib/resolv.rb (Resolv::LOC::Coord.create): fixed. [ruby-core:72567] [Bug #11912] fixed by Eric Wong and Kazuhiro NISHIYAMA. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-28Resolv::IPv6.create: avoid modifying frozen string literalnormal
* lib/resolv.rb (Resolv::IPv6.create): avoid modifying frozen * test/resolv/test_dns.rb (test_ipv6_create): test for above [Bug #11910] [ruby-core:72559] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-09* lib/resolv.rb (Resolv::DNS::Message::MessageEncoder#put_labels):akr
Prevent overflow of pointer to labels. Patch by Hannes Georg. [ruby-core:71248] [Bug #11632] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-13use Timeout.timeoutnobu
* time: Object#timeout has been deprecated a long time ago, use Timeout.timeout. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-17resolv.rb: fix equalitynobu
* lib/resolv.rb (Resolv::DNS::Resource#==, #hash): elements returned by Kernel#instance_variables are Symbols now. [ruby-core:68128] [Bug #10857] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-02* lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.akr
(Resolv::DNS::Name#initialize): Normalize labels as Resolv::DNS::Label::Str objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-30resolv.rb: case-insensitive comparisonnobu
* lib/resolv.rb (Resolv::DNS::Name#==): DNS is case-insensitive, so the comparison should be case-insensitive as well. [ruby-core:66498] [Bug #10550] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-30test_dns.rb: test namenobu
* test/resolv/test_dns.rb (TestResolvDNS#test_dots_diffences): fix test name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-30resolv.rb: dots differencesnobu
* lib/resolv.rb (Resolv::DNS::Name): names with different dots should be different. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-25test_dns.rb: fix scopenobu
* test/resolv/test_dns.rb (test_query_ipv4_address): fix local variables scope. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e