net-dns 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +1 -1
- data/.rspec +1 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_defaults.yml +364 -0
- data/.rubocop_todo.yml +207 -0
- data/.travis.yml +9 -16
- data/CHANGELOG.md +12 -1
- data/Gemfile +6 -2
- data/LICENSE.txt +56 -0
- data/README.md +94 -77
- data/Rakefile +23 -56
- data/bin/console +14 -0
- data/demo/check_soa.rb +27 -38
- data/demo/threads.rb +3 -7
- data/lib/net/dns.rb +4 -11
- data/lib/net/dns/core_ext.rb +8 -15
- data/lib/net/dns/header.rb +58 -66
- data/lib/net/dns/names.rb +25 -23
- data/lib/net/dns/packet.rb +136 -139
- data/lib/net/dns/question.rb +36 -39
- data/lib/net/dns/resolver.rb +103 -113
- data/lib/net/dns/resolver/socks.rb +45 -51
- data/lib/net/dns/resolver/timeouts.rb +17 -26
- data/lib/net/dns/rr.rb +107 -117
- data/lib/net/dns/rr/a.rb +46 -55
- data/lib/net/dns/rr/aaaa.rb +40 -49
- data/lib/net/dns/rr/classes.rb +26 -29
- data/lib/net/dns/rr/cname.rb +33 -41
- data/lib/net/dns/rr/hinfo.rb +44 -56
- data/lib/net/dns/rr/mr.rb +33 -42
- data/lib/net/dns/rr/mx.rb +37 -47
- data/lib/net/dns/rr/ns.rb +33 -41
- data/lib/net/dns/rr/null.rb +8 -11
- data/lib/net/dns/rr/ptr.rb +14 -20
- data/lib/net/dns/rr/soa.rb +27 -30
- data/lib/net/dns/rr/srv.rb +13 -17
- data/lib/net/dns/rr/txt.rb +8 -11
- data/lib/net/dns/rr/types.rb +97 -99
- data/lib/net/dns/version.rb +5 -13
- data/net-dns.gemspec +17 -29
- data/{fixtures → spec/fixtures}/resolv.conf +0 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/unit/resolver/dns_timeout_spec.rb +36 -0
- data/spec/unit/resolver/tcp_timeout_spec.rb +46 -0
- data/spec/unit/resolver/udp_timeout_spec.rb +46 -0
- data/test/test_helper.rb +12 -3
- data/test/{header_test.rb → unit/header_test.rb} +43 -46
- data/test/{names_test.rb → unit/names_test.rb} +1 -1
- data/test/{packet_test.rb → unit/packet_test.rb} +3 -5
- data/test/{question_test.rb → unit/question_test.rb} +3 -5
- data/test/{resolver_test.rb → unit/resolver_test.rb} +10 -13
- data/test/{rr → unit/rr}/a_test.rb +10 -17
- data/test/{rr → unit/rr}/aaaa_test.rb +7 -14
- data/test/{rr → unit/rr}/classes_test.rb +14 -16
- data/test/{rr → unit/rr}/cname_test.rb +7 -14
- data/test/{rr → unit/rr}/hinfo_test.rb +16 -22
- data/test/{rr → unit/rr}/mr_test.rb +12 -18
- data/test/{rr → unit/rr}/mx_test.rb +18 -24
- data/test/{rr → unit/rr}/ns_test.rb +10 -16
- data/test/{rr → unit/rr}/types_test.rb +10 -8
- data/test/{rr_test.rb → unit/rr_test.rb} +33 -37
- metadata +77 -49
- data/test/resolver/timeouts_test.rb +0 -109
data/lib/net/dns/version.rb
CHANGED
@@ -1,16 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Net
|
2
4
|
module DNS
|
3
|
-
|
4
|
-
|
5
|
-
MAJOR = 0
|
6
|
-
MINOR = 8
|
7
|
-
PATCH = 0
|
8
|
-
BUILD = nil
|
9
|
-
|
10
|
-
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join(".")
|
11
|
-
end
|
12
|
-
|
13
|
-
VERSION = Version::STRING
|
14
|
-
|
5
|
+
# The current library version.
|
6
|
+
VERSION = "0.9.0".freeze
|
15
7
|
end
|
16
|
-
end
|
8
|
+
end
|
data/net-dns.gemspec
CHANGED
@@ -1,35 +1,23 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
2
|
+
require "net/dns/version"
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
4
|
-
s.name
|
5
|
-
s.version
|
6
|
-
|
7
|
-
s.
|
8
|
-
s.
|
9
|
-
s.
|
5
|
+
s.name = "net-dns"
|
6
|
+
s.version = Net::DNS::VERSION
|
7
|
+
s.authors = ["Marco Ceresa", "Simone Carletti"]
|
8
|
+
s.email = ["ceresa@gmail.com", "weppos@weppos.net"]
|
9
|
+
s.homepage = "http://github.com/bluemonk/net-dns"
|
10
|
+
s.summary = "Pure Ruby DNS library."
|
10
11
|
s.description = "Net::DNS is a pure Ruby DNS library, with a clean OO interface and an extensible API."
|
11
|
-
s.email = ["ceresa@gmail.com", "weppos@weppos.net"]
|
12
|
-
s.files = [".gitignore", ".travis.yml", "CHANGELOG.md", "Gemfile", "README.md", "Rakefile", "THANKS.rdoc", "demo/check_soa.rb", "demo/threads.rb", "fixtures/resolv.conf", "lib/net/dns.rb", "lib/net/dns/core_ext.rb", "lib/net/dns/header.rb", "lib/net/dns/names.rb", "lib/net/dns/packet.rb", "lib/net/dns/question.rb", "lib/net/dns/resolver.rb", "lib/net/dns/resolver/socks.rb", "lib/net/dns/resolver/timeouts.rb", "lib/net/dns/rr.rb", "lib/net/dns/rr/a.rb", "lib/net/dns/rr/aaaa.rb", "lib/net/dns/rr/classes.rb", "lib/net/dns/rr/cname.rb", "lib/net/dns/rr/hinfo.rb", "lib/net/dns/rr/mr.rb", "lib/net/dns/rr/mx.rb", "lib/net/dns/rr/ns.rb", "lib/net/dns/rr/null.rb", "lib/net/dns/rr/ptr.rb", "lib/net/dns/rr/soa.rb", "lib/net/dns/rr/srv.rb", "lib/net/dns/rr/txt.rb", "lib/net/dns/rr/types.rb", "lib/net/dns/version.rb", "net-dns.gemspec", "test/header_test.rb", "test/names_test.rb", "test/packet_test.rb", "test/question_test.rb", "test/resolver/timeouts_test.rb", "test/resolver_test.rb", "test/rr/a_test.rb", "test/rr/aaaa_test.rb", "test/rr/classes_test.rb", "test/rr/cname_test.rb", "test/rr/hinfo_test.rb", "test/rr/mr_test.rb", "test/rr/mx_test.rb", "test/rr/ns_test.rb", "test/rr/types_test.rb", "test/rr_test.rb", "test/test_helper.rb"]
|
13
|
-
s.homepage = "http://github.com/bluemonk/net-dns"
|
14
|
-
s.require_paths = ["lib"]
|
15
|
-
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
16
|
-
s.rubyforge_project = "net-dns"
|
17
|
-
s.rubygems_version = "2.0.3"
|
18
|
-
s.summary = "Pure Ruby DNS library."
|
19
|
-
s.test_files = ["test/header_test.rb", "test/names_test.rb", "test/packet_test.rb", "test/question_test.rb", "test/resolver/timeouts_test.rb", "test/resolver_test.rb", "test/rr/a_test.rb", "test/rr/aaaa_test.rb", "test/rr/classes_test.rb", "test/rr/cname_test.rb", "test/rr/hinfo_test.rb", "test/rr/mr_test.rb", "test/rr/mx_test.rb", "test/rr/ns_test.rb", "test/rr/types_test.rb", "test/rr_test.rb", "test/test_helper.rb"]
|
20
12
|
|
21
|
-
|
22
|
-
|
13
|
+
s.required_ruby_version = ">= 2.1"
|
14
|
+
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.extra_rdoc_files = %w[LICENSE.txt]
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
s.add_dependency(%q<rake>, ["~> 10.0"])
|
29
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
30
|
-
end
|
31
|
-
else
|
32
|
-
s.add_dependency(%q<rake>, ["~> 10.0"])
|
33
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
34
|
-
end
|
20
|
+
s.add_development_dependency "mocha"
|
21
|
+
s.add_development_dependency "rake"
|
22
|
+
s.add_development_dependency "yard"
|
35
23
|
end
|
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'net/dns'
|
3
|
+
|
4
|
+
unless defined?(SPEC_ROOT)
|
5
|
+
SPEC_ROOT = File.expand_path(__dir__)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
|
+
# in spec/support/ and its subdirectories.
|
10
|
+
Dir[File.join(SPEC_ROOT, "support/**/*.rb")].each { |f| require f }
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.mock_with :rspec
|
14
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/dns/resolver/timeouts'
|
3
|
+
|
4
|
+
describe Net::DNS::Resolver::DnsTimeout do
|
5
|
+
subject { described_class.new(10) }
|
6
|
+
|
7
|
+
describe "#initialize" do
|
8
|
+
it "returns an instance of DnsTimeout" do
|
9
|
+
expect(subject.class).to be(described_class)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "sets timeout" do
|
13
|
+
expect(described_class.new(0).seconds).to eq(0)
|
14
|
+
expect(described_class.new(10).seconds).to eq(10)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "raises ArgumentError when timeout is invalid" do
|
18
|
+
expect { described_class.new(nil) }.to raise_error(ArgumentError)
|
19
|
+
expect { described_class.new("") }.to raise_error(ArgumentError)
|
20
|
+
expect { described_class.new("foo") }.to raise_error(ArgumentError)
|
21
|
+
expect { described_class.new(-1) }.to raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#to_s" do
|
26
|
+
it "returns the seconds" do
|
27
|
+
expect(subject.to_s).to eq("10")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#timeout" do
|
32
|
+
it "requires a block" do
|
33
|
+
expect { subject.timeout }.to raise_error(LocalJumpError)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/dns/resolver/timeouts'
|
3
|
+
|
4
|
+
describe Net::DNS::Resolver::TcpTimeout do
|
5
|
+
subject { described_class.new(10) }
|
6
|
+
|
7
|
+
it "inherits from DnsTimeout" do
|
8
|
+
expect(described_class.ancestors).to include(Net::DNS::Resolver::DnsTimeout)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#initialize" do
|
12
|
+
it "returns an instance of TcpTimeout" do
|
13
|
+
expect(subject.class).to be(described_class)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "sets timeout" do
|
17
|
+
expect(described_class.new(0).seconds).to eq(0)
|
18
|
+
expect(described_class.new(10).seconds).to eq(10)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "raises ArgumentError when timeout is invalid" do
|
22
|
+
expect { described_class.new(nil) }.to raise_error(ArgumentError)
|
23
|
+
expect { described_class.new("") }.to raise_error(ArgumentError)
|
24
|
+
expect { described_class.new("foo") }.to raise_error(ArgumentError)
|
25
|
+
expect { described_class.new(-1) }.to raise_error(ArgumentError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#to_s" do
|
30
|
+
it "returns infinite when seconds is 0" do
|
31
|
+
expect(described_class.new(0).to_s).to eq("infinite")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns the seconds" do
|
35
|
+
expect(subject.to_s).to eq("10")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#pretty_to_s" do
|
40
|
+
it "returns a more verbose version" do
|
41
|
+
expect(described_class.new(30).pretty_to_s).to eq("30 seconds")
|
42
|
+
expect(described_class.new(90).pretty_to_s).to eq("1 minutes and 30 seconds")
|
43
|
+
expect(described_class.new(3690).pretty_to_s).to eq("1 hours, 1 minutes and 30 seconds")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'net/dns/resolver/timeouts'
|
3
|
+
|
4
|
+
describe Net::DNS::Resolver::UdpTimeout do
|
5
|
+
subject { described_class.new(10) }
|
6
|
+
|
7
|
+
it "inherits from DnsTimeout" do
|
8
|
+
expect(described_class.ancestors).to include(Net::DNS::Resolver::DnsTimeout)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#initialize" do
|
12
|
+
it "returns an instance of TcpTimeout" do
|
13
|
+
expect(subject.class).to be(described_class)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "sets timeout" do
|
17
|
+
expect(described_class.new(0).seconds).to eq(0)
|
18
|
+
expect(described_class.new(10).seconds).to eq(10)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "raises ArgumentError when timeout is invalid" do
|
22
|
+
expect { described_class.new(nil) }.to raise_error(ArgumentError)
|
23
|
+
expect { described_class.new("") }.to raise_error(ArgumentError)
|
24
|
+
expect { described_class.new("foo") }.to raise_error(ArgumentError)
|
25
|
+
expect { described_class.new(-1) }.to raise_error(ArgumentError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#to_s" do
|
30
|
+
it "returns infinite when seconds is 0" do
|
31
|
+
expect(described_class.new(0).to_s).to eq("not defined")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns the seconds" do
|
35
|
+
expect(subject.to_s).to eq("10")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#pretty_to_s" do
|
40
|
+
it "returns a more verbose version" do
|
41
|
+
expect(described_class.new(30).pretty_to_s).to eq("30 seconds")
|
42
|
+
expect(described_class.new(90).pretty_to_s).to eq("1 minutes and 30 seconds")
|
43
|
+
expect(described_class.new(3690).pretty_to_s).to eq("1 hours, 1 minutes and 30 seconds")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/reporters"
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true)
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
7
|
+
require "net/dns"
|
8
|
+
|
9
|
+
module Minitest::Assertions
|
10
|
+
def assert_nothing_raised(*)
|
11
|
+
yield
|
12
|
+
end
|
13
|
+
end
|
@@ -1,27 +1,26 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'net/dns/header'
|
3
3
|
|
4
|
-
class HeaderTest < Test
|
4
|
+
class HeaderTest < Minitest::Test
|
5
5
|
include Net::DNS
|
6
|
-
|
7
|
-
def setup
|
8
6
|
|
7
|
+
def setup
|
9
8
|
@default = Header.new
|
10
|
-
@hash = Header.new(:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
|
9
|
+
@hash = Header.new(id: 441,
|
10
|
+
qr: 1,
|
11
|
+
opCode: Header::IQUERY,
|
12
|
+
aa: 1,
|
13
|
+
tc: 1,
|
14
|
+
rd: 0,
|
15
|
+
cd: 0,
|
16
|
+
ad: 0,
|
17
|
+
ra: 1,
|
18
|
+
rCode: Header::RCode::FORMAT,
|
19
|
+
qdCount: 1,
|
20
|
+
anCount: 2,
|
21
|
+
nsCount: 3,
|
22
|
+
arCount: 3)
|
23
|
+
|
25
24
|
@modified = Header.new
|
26
25
|
@modified.id = 442
|
27
26
|
@modified.qr = true
|
@@ -38,10 +37,10 @@ class HeaderTest < Test::Unit::TestCase
|
|
38
37
|
@modified.arCount = 3
|
39
38
|
|
40
39
|
@data = @modified.data
|
41
|
-
num = [(@data.unpack("n")[0]+1)].pack("n")
|
42
|
-
@data[0]
|
40
|
+
num = [(@data.unpack("n")[0] + 1)].pack("n")
|
41
|
+
@data[0] = num[0]
|
42
|
+
@data[1] = num[1]
|
43
43
|
@binary = Header.parse(@data)
|
44
|
-
|
45
44
|
end
|
46
45
|
|
47
46
|
def test_simple
|
@@ -60,7 +59,7 @@ class HeaderTest < Test::Unit::TestCase
|
|
60
59
|
assert_equal(@default.nsCount, 0)
|
61
60
|
assert_equal(@default.arCount, 0)
|
62
61
|
|
63
|
-
assert_equal(@hash.id, 441)
|
62
|
+
assert_equal(@hash.id, 441)
|
64
63
|
assert_equal(@hash.query?, false)
|
65
64
|
assert_equal(@hash.response?, true)
|
66
65
|
assert_equal(@hash.opCode, Header::IQUERY)
|
@@ -75,8 +74,8 @@ class HeaderTest < Test::Unit::TestCase
|
|
75
74
|
assert_equal(@hash.anCount, 2)
|
76
75
|
assert_equal(@hash.nsCount, 3)
|
77
76
|
assert_equal(@hash.arCount, 3)
|
78
|
-
|
79
|
-
assert_equal(@modified.id, 442)
|
77
|
+
|
78
|
+
assert_equal(@modified.id, 442)
|
80
79
|
assert_equal(@modified.query?, false)
|
81
80
|
assert_equal(@modified.response?, true)
|
82
81
|
assert_equal(@modified.opCode, Header::IQUERY)
|
@@ -91,10 +90,10 @@ class HeaderTest < Test::Unit::TestCase
|
|
91
90
|
assert_equal(@modified.anCount, 2)
|
92
91
|
assert_equal(@modified.nsCount, 3)
|
93
92
|
assert_equal(@modified.arCount, 3)
|
94
|
-
|
93
|
+
|
95
94
|
assert_equal(@binary.data, @data)
|
96
95
|
|
97
|
-
assert_equal(@binary.id, 443)
|
96
|
+
assert_equal(@binary.id, 443)
|
98
97
|
assert_equal(@binary.query?, false)
|
99
98
|
assert_equal(@binary.response?, true)
|
100
99
|
assert_equal(@binary.opCode, Header::IQUERY)
|
@@ -109,59 +108,57 @@ class HeaderTest < Test::Unit::TestCase
|
|
109
108
|
assert_equal(@binary.anCount, 2)
|
110
109
|
assert_equal(@binary.nsCount, 3)
|
111
110
|
assert_equal(@binary.arCount, 3)
|
112
|
-
|
111
|
+
|
113
112
|
assert_raises(ArgumentError) do
|
114
|
-
Header.new(
|
113
|
+
Header.new([])
|
115
114
|
end
|
116
115
|
assert_raises(ArgumentError) do
|
117
|
-
Header.parse(
|
116
|
+
Header.parse([])
|
118
117
|
end
|
119
118
|
assert_raises(ArgumentError) do
|
120
119
|
Header.parse("aa")
|
121
120
|
end
|
122
121
|
assert_raises(ArgumentError) do
|
123
|
-
@default.id =
|
122
|
+
@default.id = 1_000_000
|
124
123
|
end
|
125
124
|
assert_raises(ArgumentError) do
|
126
|
-
@default.qr=2
|
125
|
+
@default.qr = 2
|
127
126
|
end
|
128
127
|
assert_raises(Header::WrongOpcodeError) do
|
129
|
-
@default.opCode=4
|
128
|
+
@default.opCode = 4
|
130
129
|
end
|
131
130
|
assert_raises(ArgumentError) do
|
132
|
-
@default.aa=2
|
131
|
+
@default.aa = 2
|
133
132
|
end
|
134
133
|
assert_raises(ArgumentError) do
|
135
|
-
@default.tc=2
|
134
|
+
@default.tc = 2
|
136
135
|
end
|
137
136
|
assert_raises(Header::WrongRecursiveError) do
|
138
|
-
@default.recursive=2
|
137
|
+
@default.recursive = 2
|
139
138
|
end
|
140
139
|
assert_raises(ArgumentError) do
|
141
|
-
@default.ra=2
|
140
|
+
@default.ra = 2
|
142
141
|
end
|
143
142
|
assert_raises(ArgumentError) do
|
144
|
-
@default.cd=2
|
143
|
+
@default.cd = 2
|
145
144
|
end
|
146
145
|
assert_raises(ArgumentError) do
|
147
|
-
@default.ad=2
|
146
|
+
@default.ad = 2
|
148
147
|
end
|
149
148
|
assert_raises(ArgumentError) do
|
150
|
-
@default.rCode=46
|
149
|
+
@default.rCode = 46
|
151
150
|
end
|
152
151
|
assert_raises(Header::WrongCountError) do
|
153
|
-
@default.qdCount=
|
152
|
+
@default.qdCount = 100_000
|
154
153
|
end
|
155
154
|
assert_raises(Header::WrongCountError) do
|
156
|
-
@default.anCount=
|
155
|
+
@default.anCount = 100_000
|
157
156
|
end
|
158
157
|
assert_raises(Header::WrongCountError) do
|
159
|
-
@default.nsCount=
|
158
|
+
@default.nsCount = 100_000
|
160
159
|
end
|
161
160
|
assert_raises(Header::WrongCountError) do
|
162
|
-
@default.arCount=
|
161
|
+
@default.arCount = 100_000
|
163
162
|
end
|
164
|
-
end
|
165
|
-
|
163
|
+
end
|
166
164
|
end
|
167
|
-
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'net/dns/packet'
|
3
3
|
|
4
|
-
class PacketTest < Test
|
5
|
-
|
4
|
+
class PacketTest < Minitest::Test
|
6
5
|
def setup
|
7
6
|
@klass = Net::DNS::Packet
|
8
7
|
@domain = 'example.com'
|
@@ -23,7 +22,7 @@ class PacketTest < Test::Unit::TestCase
|
|
23
22
|
@question = @klass.new(@domain).question.first
|
24
23
|
assert_equal @domain, @question.qName
|
25
24
|
assert_equal Net::DNS::RR::Types.new(Net::DNS::A).to_s, @question.qType.to_s
|
26
|
-
assert_equal Net::DNS::RR::Classes.new(Net::DNS::IN).to_s, @question.qClass.to_s
|
25
|
+
assert_equal Net::DNS::RR::Classes.new(Net::DNS::IN).to_s, @question.qClass.to_s
|
27
26
|
|
28
27
|
@question = @klass.new(@domain, Net::DNS::MX, Net::DNS::HS).question.first
|
29
28
|
assert_equal @domain, @question.qName
|
@@ -45,5 +44,4 @@ class PacketTest < Test::Unit::TestCase
|
|
45
44
|
assert_instance_of Array, @record.additional
|
46
45
|
assert_instance_of Net::DNS::RR::A, @record.additional.first
|
47
46
|
end
|
48
|
-
|
49
|
-
end
|
47
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'net/dns/question'
|
3
3
|
|
4
|
-
class QuestionTest < Test
|
5
|
-
|
4
|
+
class QuestionTest < Minitest::Test
|
6
5
|
def setup
|
7
6
|
@domain = 'example.com.'
|
8
7
|
@type = 'MX'
|
@@ -10,7 +9,7 @@ class QuestionTest < Test::Unit::TestCase
|
|
10
9
|
@data = "\006google\003com\000\000\001\000\001"
|
11
10
|
|
12
11
|
@default = Net::DNS::Question.new(@domain)
|
13
|
-
@string = Net::DNS::Question.new(@domain
|
12
|
+
@string = Net::DNS::Question.new(@domain, @type, @cls)
|
14
13
|
@binary = Net::DNS::Question.parse(@data)
|
15
14
|
@binary2 = Net::DNS::Question.parse(@string.data)
|
16
15
|
end
|
@@ -41,7 +40,7 @@ class QuestionTest < Test::Unit::TestCase
|
|
41
40
|
Net::DNS::Question.new("test{")
|
42
41
|
end
|
43
42
|
assert_raises(ArgumentError) do
|
44
|
-
Net::DNS::Question.parse(
|
43
|
+
Net::DNS::Question.parse([])
|
45
44
|
end
|
46
45
|
assert_raises(ArgumentError) do
|
47
46
|
Net::DNS::Question.parse("test")
|
@@ -79,5 +78,4 @@ class QuestionTest < Test::Unit::TestCase
|
|
79
78
|
assert_equal "supercalifragilistichespiralidoso.com IN A ",
|
80
79
|
Net::DNS::Question.new("supercalifragilistichespiralidoso.com").to_s
|
81
80
|
end
|
82
|
-
|
83
81
|
end
|