whois 5.1.1 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql-analysis.yml +3 -3
  3. data/.github/workflows/release.yml +3 -1
  4. data/.github/workflows/tests.yml +2 -3
  5. data/.rubocop.yml +1 -1
  6. data/.rubocop_todo.yml +11 -87
  7. data/CHANGELOG.md +19 -0
  8. data/LICENSE.txt +1 -1
  9. data/README.md +2 -2
  10. data/SECURITY.md +24 -0
  11. data/bin/whoisrb +3 -3
  12. data/data/tld.json +8 -775
  13. data/lib/whois/client.rb +2 -2
  14. data/lib/whois/errors.rb +1 -1
  15. data/lib/whois/record/part.rb +1 -1
  16. data/lib/whois/record.rb +2 -2
  17. data/lib/whois/server/adapters/afilias.rb +1 -1
  18. data/lib/whois/server/adapters/arin.rb +1 -1
  19. data/lib/whois/server/adapters/arpa.rb +5 -7
  20. data/lib/whois/server/adapters/base.rb +4 -4
  21. data/lib/whois/server/adapters/formatted.rb +1 -1
  22. data/lib/whois/server/adapters/none.rb +2 -2
  23. data/lib/whois/server/adapters/not_implemented.rb +2 -2
  24. data/lib/whois/server/adapters/standard.rb +1 -1
  25. data/lib/whois/server/adapters/verisign.rb +1 -1
  26. data/lib/whois/server/adapters/web.rb +2 -2
  27. data/lib/whois/server/socket_handler.rb +4 -4
  28. data/lib/whois/server.rb +10 -10
  29. data/lib/whois/version.rb +2 -2
  30. data/lib/whois.rb +19 -19
  31. data/spec/integration/whois_spec.rb +2 -2
  32. data/spec/spec_helper.rb +3 -3
  33. data/spec/whois/client_spec.rb +1 -1
  34. data/spec/whois/record/part_spec.rb +1 -1
  35. data/spec/whois/record_spec.rb +26 -18
  36. data/spec/whois/server/adapters/afilias_spec.rb +1 -1
  37. data/spec/whois/server/adapters/arin_spec.rb +1 -1
  38. data/spec/whois/server/adapters/arpa_spec.rb +13 -4
  39. data/spec/whois/server/adapters/base_spec.rb +17 -12
  40. data/spec/whois/server/adapters/formatted_spec.rb +1 -1
  41. data/spec/whois/server/adapters/none_spec.rb +1 -1
  42. data/spec/whois/server/adapters/not_implemented_spec.rb +2 -2
  43. data/spec/whois/server/adapters/standard_spec.rb +1 -1
  44. data/spec/whois/server/adapters/verisign_spec.rb +1 -1
  45. data/spec/whois/server/adapters/web_spec.rb +1 -1
  46. data/spec/whois/server/socket_handler_spec.rb +2 -2
  47. data/spec/whois/server_spec.rb +51 -51
  48. data/spec/whois/web_interface_error_spec.rb +1 -1
  49. data/spec/whois/whois_spec.rb +1 -1
  50. data/utils/deftld.rb +0 -1
  51. data/whois.gemspec +1 -1
  52. metadata +6 -36
data/lib/whois/client.rb CHANGED
@@ -5,11 +5,11 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
12
- require 'timeout'
12
+ require "timeout"
13
13
 
14
14
 
15
15
  module Whois
data/lib/whois/errors.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
data/lib/whois/record.rb CHANGED
@@ -5,11 +5,11 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
12
- require 'whois/record/part'
12
+ require "whois/record/part"
13
13
 
14
14
 
15
15
  module Whois
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
@@ -30,16 +30,14 @@ module Whois
30
30
  # "192.in-addr.arpa" => "192.0.0.0"
31
31
  # "in-addr.arpa" => "0.0.0.0"
32
32
  def inaddr_to_ip(string)
33
- raise ServerError, "Invalid .in-addr.arpa address" unless string.match?(/^([0-9]{1,3}\.?){0,4}in-addr\.arpa$/)
33
+ raise ServerError, "Invalid .in-addr.arpa address" unless string.match?(/\A([0-9]{1,3}\.?){0,4}in-addr\.arpa\z/)
34
34
 
35
35
  a, b, c, d = string.scan(/[0-9]{1,3}\./).reverse
36
36
  [a, b, c, d].map do |token|
37
37
  token = (token || 0).to_i
38
- if token <= 255 && token >= 0
39
- token
40
- else
41
- raise ServerError, "Invalid .in-addr.arpa token `#{token}'"
42
- end
38
+ raise ServerError, "Invalid .in-addr.arpa token `#{token}'" unless token <= 255 && token >= 0
39
+
40
+ token
43
41
  end.join(".")
44
42
  end
45
43
 
@@ -5,13 +5,13 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
12
- require 'whois/record/part'
13
- require 'whois/record'
14
- require 'whois/server/socket_handler'
12
+ require "whois/record/part"
13
+ require "whois/record"
14
+ require "whois/server/socket_handler"
15
15
 
16
16
 
17
17
  module Whois
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
@@ -36,7 +36,7 @@ module Whois
36
36
  #
37
37
  # @raise [Whois::NoInterfaceError] For every request.
38
38
  #
39
- def request(string)
39
+ def request(_string)
40
40
  raise NoInterfaceError, "This `#{type}' has no whois server"
41
41
  end
42
42
 
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
@@ -22,7 +22,7 @@ module Whois
22
22
  #
23
23
  # @raise [Whois::ServerNotImplemented] For every request.
24
24
  #
25
- def request(string)
25
+ def request(_string)
26
26
  raise ServerNotImplemented, "The `#{host}' feature has not been implemented yet."
27
27
  end
28
28
 
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
@@ -32,7 +32,7 @@ module Whois
32
32
  #
33
33
  # @raise [Whois::WebInterfaceError] For every request.
34
34
  #
35
- def request(string)
35
+ def request(_string)
36
36
  raise WebInterfaceError, options[:url]
37
37
  end
38
38
 
@@ -5,12 +5,12 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
12
- require 'socket'
13
- require 'whois/errors'
12
+ require "socket"
13
+ require "whois/errors"
14
14
 
15
15
 
16
16
  module Whois
@@ -58,7 +58,7 @@ module Whois
58
58
  client.write("#{query}\r\n") # I could use put(foo) and forget the \n
59
59
  client.read # but write/read is more symmetric than puts/read
60
60
  ensure # and I really want to use read instead of gets.
61
- client.close if client # If != client something went wrong.
61
+ client&.close # If != client something went wrong.
62
62
  end
63
63
  end
64
64
 
data/lib/whois/server.rb CHANGED
@@ -5,12 +5,12 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
12
- require 'ipaddr'
13
- require 'json'
12
+ require "ipaddr"
13
+ require "json"
14
14
  require "whois/server/adapters/base"
15
15
  require "whois/server/adapters/arin"
16
16
  require "whois/server/adapters/arpa"
@@ -67,7 +67,7 @@ module Whois
67
67
  # @return [void]
68
68
  def load_definitions
69
69
  clear_definitions
70
- Dir[File.expand_path('../../data/*.json', __dir__)].each { |f| load_json(f) }
70
+ Dir[File.expand_path("../../data/*.json", __dir__)].each { |f| load_json(f) }
71
71
  end
72
72
 
73
73
  # Loads the definitions from a JSON file.
@@ -86,7 +86,7 @@ module Whois
86
86
  options = if settings.empty?
87
87
  EMPTY_HASH
88
88
  else
89
- settings.map { |k, v| [k.to_sym, v.is_a?(String) ? intern_string(v) : v] }.to_h.freeze
89
+ settings.to_h { |k, v| [k.to_sym, v.is_a?(String) ? intern_string(v) : v] }.freeze
90
90
  end
91
91
  define(type, allocation, host, options)
92
92
  end
@@ -268,7 +268,7 @@ module Whois
268
268
  begin
269
269
  ip = IPAddr.new(string)
270
270
  type = ip.ipv4? ? TYPE_IPV4 : TYPE_IPV6
271
- _definitions(type).each do |_, definition|
271
+ _definitions(type).each_value do |definition|
272
272
  return factory(type, *definition) if IPAddr.new(definition.first).include?(ip)
273
273
  end
274
274
  rescue ArgumentError
@@ -283,7 +283,7 @@ module Whois
283
283
  # @param string [String]
284
284
  # @raise [Whois::ServerNotSupported]
285
285
  # emails are not supported.
286
- def find_for_email(string)
286
+ def find_for_email(_string)
287
287
  raise ServerNotSupported, "No WHOIS server is known for email objects"
288
288
  end
289
289
 
@@ -303,7 +303,7 @@ module Whois
303
303
  index = token.index(".")
304
304
  break if index.nil?
305
305
 
306
- token = token[(index + 1)..-1]
306
+ token = token[(index + 1)..]
307
307
  end
308
308
  end
309
309
 
@@ -321,7 +321,7 @@ module Whois
321
321
  def find_for_asn(string)
322
322
  asn = string[/\d+/].to_i
323
323
  asn_type = asn <= 65_535 ? TYPE_ASN16 : TYPE_ASN32
324
- _definitions(asn_type).each do |_, definition|
324
+ _definitions(asn_type).each_value do |definition|
325
325
  if (range = definition.first.split.map(&:to_i)) && asn >= range.first && asn <= range.last
326
326
  return factory(asn_type, *definition)
327
327
  end
@@ -363,7 +363,7 @@ module Whois
363
363
  end
364
364
 
365
365
  def matches_email?(string)
366
- string.include?('@')
366
+ string.include?("@")
367
367
  end
368
368
 
369
369
  def matches_asn?(string)
data/lib/whois/version.rb CHANGED
@@ -5,11 +5,11 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
12
12
  module Whois
13
13
  # The current library version.
14
- VERSION = "5.1.1"
14
+ VERSION = "6.0.1"
15
15
  end
data/lib/whois.rb CHANGED
@@ -5,15 +5,15 @@
5
5
  #
6
6
  # An intelligent pure Ruby WHOIS client and parser.
7
7
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
8
+ # Copyright (c) 2009-2024 Simone Carletti <weppos@weppos.net>
9
9
  #++
10
10
 
11
11
 
12
- require 'whois/version'
13
- require 'whois/errors'
14
- require 'whois/client'
15
- require 'whois/server'
16
- require 'whois/record'
12
+ require "whois/version"
13
+ require "whois/errors"
14
+ require "whois/client"
15
+ require "whois/server"
16
+ require "whois/record"
17
17
 
18
18
 
19
19
  module Whois
@@ -74,7 +74,7 @@ module Whois
74
74
  result
75
75
  end
76
76
 
77
- def deprecate(message = nil, callstack = caller)
77
+ def deprecate(message = nil, _callstack = caller)
78
78
  # warn("DEPRECATION WARNING: #{message} #{deprecation_caller_message(callstack)}")
79
79
  warn("DEPRECATION WARNING: #{message}")
80
80
  end
@@ -99,24 +99,24 @@ module Whois
99
99
 
100
100
  def deprecation_caller_message(callstack)
101
101
  file, line, method = extract_callstack(callstack)
102
- if file
103
- if line && method
104
- "(called from #{method} at #{file}:#{line})"
105
- else
106
- "(called from #{file}:#{line})"
107
- end
102
+ return unless file
103
+
104
+ if line && method
105
+ "(called from #{method} at #{file}:#{line})"
106
+ else
107
+ "(called from #{file}:#{line})"
108
108
  end
109
109
  end
110
110
 
111
111
  def extract_callstack(callstack)
112
112
  gem_root = "#{File.expand_path('../..', __dir__)}/"
113
113
  offending_line = callstack.find { |line| !line.start_with?(gem_root) } || callstack.first
114
- if offending_line
115
- if (md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/))
116
- md.captures
117
- else
118
- offending_line
119
- end
114
+ return unless offending_line
115
+
116
+ if (md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/))
117
+ md.captures
118
+ else
119
+ offending_line
120
120
  end
121
121
  end
122
122
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois do
6
6
  let(:response) { "Domain: example.it\nStatus: AVAILABLE\n" }
@@ -13,7 +13,7 @@ describe Whois do
13
13
  .with("example.it", "whois.nic.it", 43)
14
14
  .and_return(response)
15
15
 
16
- record = Whois.lookup("example.it")
16
+ record = described_class.lookup("example.it")
17
17
 
18
18
  expect(record).to be_a(Whois::Record)
19
19
  # expect(record.available?).to be_truthy
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rspec'
4
- require 'whois'
3
+ require "rspec"
4
+ require "whois"
5
5
 
6
6
  SPEC_ROOT = File.expand_path(__dir__) unless defined?(SPEC_ROOT)
7
7
 
@@ -12,7 +12,7 @@ Encoding.default_internal = Encoding::UTF_8
12
12
 
13
13
  # Requires supporting ruby files with custom matchers and macros, etc,
14
14
  # in spec/support/ and its subdirectories.
15
- Dir[File.join(SPEC_ROOT, "support/**/*.rb")].sort.each { |f| require f }
15
+ Dir[File.join(SPEC_ROOT, "support/**/*.rb")].each { |f| require f }
16
16
 
17
17
  RSpec.configure do |config|
18
18
  config.mock_with :rspec
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Client do
6
6
  describe "#initialize" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Record::Part do
6
6
  describe "#initialize" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Record do
6
6
  subject { described_class.new(server, parts) }
@@ -65,64 +65,72 @@ describe Whois::Record do
65
65
  one = two = described_class.new(server, parts)
66
66
 
67
67
  expect(one == two).to be_truthy
68
- expect(one.eql?(two)).to be_truthy
68
+ expect(one).to eql(two)
69
69
  end
70
70
 
71
71
  it "returns true when other has same class and has the same parts" do
72
- one, two = described_class.new(server, parts), described_class.new(server, parts)
72
+ one = described_class.new(server, parts)
73
+ two = described_class.new(server, parts)
73
74
 
74
75
  expect(one == two).to be_truthy
75
- expect(one.eql?(two)).to be_truthy
76
+ expect(one).to eql(two)
76
77
  end
77
78
 
78
79
  it "returns true when other has descendant class and has the same parts" do
79
80
  subklass = Class.new(described_class)
80
- one, two = described_class.new(server, parts), subklass.new(server, parts)
81
+ one = described_class.new(server, parts)
82
+ two = subklass.new(server, parts)
81
83
 
82
84
  expect(one == two).to be_truthy
83
- expect(one.eql?(two)).to be_truthy
85
+ expect(one).to eql(two)
84
86
  end
85
87
 
86
88
  it "returns true when other has same class and has equal parts" do
87
- one, two = described_class.new(server, parts), described_class.new(server, parts.dup)
89
+ one = described_class.new(server, parts)
90
+ two = described_class.new(server, parts.dup)
88
91
 
89
92
  expect(one == two).to be_truthy
90
- expect(one.eql?(two)).to be_truthy
93
+ expect(one).to eql(two)
91
94
  end
92
95
 
93
96
  it "returns true when other has same class, different server and the same parts" do
94
- one, two = described_class.new(server, parts), described_class.new(nil, parts)
97
+ one = described_class.new(server, parts)
98
+ two = described_class.new(nil, parts)
95
99
 
96
100
  expect(one == two).to be_truthy
97
- expect(one.eql?(two)).to be_truthy
101
+ expect(one).to eql(two)
98
102
  end
99
103
 
100
104
  it "returns false when other has different class and has the same parts" do
101
- one, two = described_class.new(server, parts), Struct.new(:server, :parts).new(server, parts)
105
+ one = described_class.new(server, parts)
106
+ two = Struct.new(:server, :parts).new(server, parts)
102
107
 
103
108
  expect(one == two).to be_falsey
104
- expect(one.eql?(two)).to be_falsey
109
+ expect(one).not_to eql(two)
105
110
  end
106
111
 
107
112
  it "returns false when other has different parts" do
108
- one, two = described_class.new(server, parts), described_class.new(server, [])
113
+ one = described_class.new(server, parts)
114
+ two = described_class.new(server, [])
109
115
 
110
116
  expect(one == two).to be_falsey
111
- expect(one.eql?(two)).to be_falsey
117
+ expect(one).not_to eql(two)
112
118
  end
113
119
 
114
120
  it "returns false when other is string and has the same content" do
115
- one, two = described_class.new(server, parts), described_class.new(server, parts).to_s
121
+ one = described_class.new(server, parts)
122
+ two = described_class.new(server, parts).to_s
116
123
 
117
124
  expect(one == two).to be_falsey
118
- expect(one.eql?(two)).to be_falsey
125
+ expect(one).not_to eql(two)
119
126
  end
120
127
 
121
128
  it "returns false when other is string and has different content" do
122
- one, two = described_class.new(server, parts), "different"
129
+ one = described_class.new(server, parts)
130
+ two = "different"
123
131
 
124
132
  expect(one == two).to be_falsey
125
- expect(one.eql?(two)).to be_falsey
133
+ expect(one).not_to eql(two)
126
134
  end
127
135
  end
128
136
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::Afilias do
6
6
  let(:definition) { [:tld, ".test", "whois.afilias-grs.info", {}] }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Whois::Server::Adapters::Arin do
6
6
  let(:definition) { [:ipv4, "0.0.0.0/1", "whois.arin.net"] }
@@ -1,20 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
4
- require 'whois/server/adapters/arin'
3
+ require "spec_helper"
4
+ require "whois/server/adapters/arin"
5
5
 
6
6
  describe Whois::Server::Adapters::Arpa do
7
7
  let(:definition) { [:tld, ".in-addr.arpa", nil, {}] }
8
8
 
9
9
  describe "#lookup" do
10
10
  it "returns the WHOIS record" do
11
- response = "Whois Response"
12
11
  server = described_class.new(*definition)
13
- expect(Whois::Server::Adapters::Arin.query_handler).to receive(:call).with("n + 229.128.in-addr.arpa", "whois.arin.net", 43).and_return(response)
12
+ expect(Whois::Server::Adapters::Arin.query_handler).to receive(:call)
13
+ .with("n + 229.128.in-addr.arpa", "whois.arin.net", 43)
14
+ .and_return(response = "Whois Response")
14
15
 
15
16
  record = server.lookup("229.128.in-addr.arpa")
16
17
  expect(record.to_s).to eq(response)
17
18
  expect(record.parts).to eq([Whois::Record::Part.new(body: response, host: "whois.arin.net")])
18
19
  end
20
+
21
+ it "discards newlines" do
22
+ server = described_class.new(*definition)
23
+
24
+ expect do
25
+ server.lookup("229.128.in-addr.arpa\nextra")
26
+ end.to raise_error(Whois::ServerError, "Invalid .in-addr.arpa address")
27
+ end
19
28
  end
20
29
  end