net-dns 0.8.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.rspec +1 -0
- data/.travis.yml +9 -16
- data/CHANGELOG.md +37 -13
- data/LICENSE.txt +56 -0
- data/README.md +94 -77
- data/demo/check_soa.rb +27 -38
- data/demo/threads.rb +3 -7
- data/lib/net/dns/header.rb +86 -110
- data/lib/net/dns/names.rb +31 -31
- data/lib/net/dns/packet.rb +148 -158
- data/lib/net/dns/question.rb +41 -42
- data/lib/net/dns/resolver/socks.rb +47 -55
- data/lib/net/dns/resolver/timeouts.rb +19 -30
- data/lib/net/dns/resolver.rb +151 -176
- data/lib/net/dns/rr/a.rb +45 -55
- data/lib/net/dns/rr/aaaa.rb +39 -50
- data/lib/net/dns/rr/classes.rb +32 -37
- data/lib/net/dns/rr/cname.rb +31 -41
- data/lib/net/dns/rr/hinfo.rb +40 -56
- data/lib/net/dns/rr/mr.rb +31 -42
- data/lib/net/dns/rr/mx.rb +35 -47
- data/lib/net/dns/rr/ns.rb +31 -41
- data/lib/net/dns/rr/null.rb +10 -15
- data/lib/net/dns/rr/ptr.rb +16 -24
- data/lib/net/dns/rr/soa.rb +36 -35
- data/lib/net/dns/rr/srv.rb +18 -19
- data/lib/net/dns/rr/txt.rb +11 -16
- data/lib/net/dns/rr/types.rb +118 -109
- data/lib/net/dns/rr.rb +107 -117
- data/lib/net/dns/version.rb +5 -13
- data/lib/net/dns.rb +6 -11
- metadata +18 -83
- data/.gitignore +0 -8
- data/Gemfile +0 -4
- data/Rakefile +0 -71
- data/fixtures/resolv.conf +0 -4
- data/lib/net/dns/core_ext.rb +0 -52
- data/net-dns.gemspec +0 -35
- data/test/header_test.rb +0 -167
- data/test/names_test.rb +0 -21
- data/test/packet_test.rb +0 -49
- data/test/question_test.rb +0 -83
- data/test/resolver/timeouts_test.rb +0 -109
- data/test/resolver_test.rb +0 -117
- data/test/rr/a_test.rb +0 -113
- data/test/rr/aaaa_test.rb +0 -109
- data/test/rr/classes_test.rb +0 -85
- data/test/rr/cname_test.rb +0 -97
- data/test/rr/hinfo_test.rb +0 -117
- data/test/rr/mr_test.rb +0 -105
- data/test/rr/mx_test.rb +0 -112
- data/test/rr/ns_test.rb +0 -86
- data/test/rr/types_test.rb +0 -69
- data/test/rr_test.rb +0 -131
- data/test/test_helper.rb +0 -4
data/test/rr/a_test.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/rr'
|
3
|
-
|
4
|
-
class RRATest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@rr_name = "google.com."
|
8
|
-
@rr_type = "A"
|
9
|
-
@rr_cls = "IN"
|
10
|
-
@rr_ttl = 10000
|
11
|
-
@rr_value = "64.233.187.99"
|
12
|
-
@rr_address = IPAddr.new(@rr_value)
|
13
|
-
|
14
|
-
@rr_output = "google.com. 10000 IN A 64.233.187.99"
|
15
|
-
|
16
|
-
@rr = Net::DNS::RR::A.new(:name => @rr_name, :address => @rr_address, :ttl => @rr_ttl)
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def test_initialize_from_hash
|
21
|
-
@record = Net::DNS::RR::A.new(:name => @rr_name, :address => @rr_value, :ttl => @rr_ttl)
|
22
|
-
assert_equal @rr_output, @record.to_s
|
23
|
-
assert_equal @rr_name, @record.name
|
24
|
-
assert_equal @rr_type, @record.type
|
25
|
-
assert_equal @rr_cls, @record.cls
|
26
|
-
assert_equal @rr_ttl, @record.ttl
|
27
|
-
assert_equal @rr_address, @record.address
|
28
|
-
assert_equal @rr_value, @record.value
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_initialize_from_string
|
32
|
-
@record = Net::DNS::RR::A.new("#{@rr_name} #{@rr_ttl} #{@rr_cls} #{@rr_type} #{@rr_value}")
|
33
|
-
assert_equal @rr_output, @record.to_s
|
34
|
-
assert_equal @rr_name, @record.name
|
35
|
-
assert_equal @rr_type, @record.type
|
36
|
-
assert_equal @rr_cls, @record.cls
|
37
|
-
assert_equal @rr_ttl, @record.ttl
|
38
|
-
assert_equal @rr_address, @record.address
|
39
|
-
assert_equal @rr_value, @record.value
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_parse
|
43
|
-
data = "\006google\003com\000\000\001\000\001\000\000'\020\000\004@\351\273c"
|
44
|
-
@record = Net::DNS::RR.parse(data)
|
45
|
-
assert_equal @rr_output, @record.to_s
|
46
|
-
assert_equal @rr_name, @record.name
|
47
|
-
assert_equal @rr_type, @record.type
|
48
|
-
assert_equal @rr_cls, @record.cls
|
49
|
-
assert_equal @rr_ttl, @record.ttl
|
50
|
-
assert_equal @rr_address, @record.address
|
51
|
-
assert_equal @rr_value, @record.value
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
InvalidArguments = [
|
56
|
-
{ :name => "google.com", :address => "255.256" },
|
57
|
-
{ :name => "google.com" },
|
58
|
-
Object.new,
|
59
|
-
Array.new(7),
|
60
|
-
"10800 IN A",
|
61
|
-
"google.com. 10800 IN B",
|
62
|
-
"google.com. 10800 IM A",
|
63
|
-
]
|
64
|
-
|
65
|
-
InvalidArguments.each_with_index do |arguments, index|
|
66
|
-
define_method "test_initialize_should_raise_with_invalid_arguments_#{index}" do
|
67
|
-
assert_raises(ArgumentError) { Net::DNS::RR::A.new(arguments) }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
def test_address_getter
|
73
|
-
assert_equal @rr_address, @rr.address
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_address_setter
|
77
|
-
assert_raises(ArgumentError) { @rr.address = nil }
|
78
|
-
|
79
|
-
expected = IPAddr.new("64.233.187.99")
|
80
|
-
assert_equal expected, @rr.address = "64.233.187.99"
|
81
|
-
assert_equal expected, @rr.address
|
82
|
-
|
83
|
-
expected = IPAddr.new("64.233.187.90")
|
84
|
-
assert_equal expected, @rr.address = 1089059674
|
85
|
-
assert_equal expected, @rr.address
|
86
|
-
|
87
|
-
expected = IPAddr.new("64.233.187.80")
|
88
|
-
assert_equal expected, @rr.address = IPAddr.new("64.233.187.80")
|
89
|
-
assert_equal expected, @rr.address
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
def test_value
|
94
|
-
assert_equal @rr_value, @rr.value
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
def test_inspect
|
99
|
-
assert_equal "google.com. 10000 IN A 64.233.187.99",
|
100
|
-
@rr.inspect
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_to_s
|
104
|
-
assert_equal "google.com. 10000 IN A 64.233.187.99",
|
105
|
-
@rr.to_s
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_to_a
|
109
|
-
assert_equal ["google.com.", 10000, "IN", "A", "64.233.187.99"],
|
110
|
-
@rr.to_a
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
data/test/rr/aaaa_test.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/rr'
|
3
|
-
|
4
|
-
class RRAAAATest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@rr_name = "www.nic.it."
|
8
|
-
@rr_type = "AAAA"
|
9
|
-
@rr_cls = "IN"
|
10
|
-
@rr_ttl = 60
|
11
|
-
@rr_value = "2a00:d40:1:1::239"
|
12
|
-
@rr_address = IPAddr.new(@rr_value)
|
13
|
-
|
14
|
-
@rr_output = "www.nic.it. 60 IN AAAA 2a00:d40:1:1::239"
|
15
|
-
|
16
|
-
@rr = Net::DNS::RR::AAAA.new(:name => @rr_name, :address => @rr_address, :ttl => @rr_ttl)
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def test_initialize_from_hash
|
21
|
-
@record = Net::DNS::RR::AAAA.new(:name => @rr_name, :address => @rr_value, :ttl => @rr_ttl)
|
22
|
-
assert_equal @rr_output, @record.to_s
|
23
|
-
assert_equal @rr_name, @record.name
|
24
|
-
assert_equal @rr_type, @record.type
|
25
|
-
assert_equal @rr_cls, @record.cls
|
26
|
-
assert_equal @rr_ttl, @record.ttl
|
27
|
-
assert_equal @rr_address, @record.address
|
28
|
-
assert_equal @rr_value, @record.value
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_initialize_from_string
|
32
|
-
@record = Net::DNS::RR::AAAA.new("#{@rr_name} #{@rr_ttl} #{@rr_cls} #{@rr_type} #{@rr_value}")
|
33
|
-
assert_equal @rr_output, @record.to_s
|
34
|
-
assert_equal @rr_name, @record.name
|
35
|
-
assert_equal @rr_type, @record.type
|
36
|
-
assert_equal @rr_cls, @record.cls
|
37
|
-
assert_equal @rr_ttl, @record.ttl
|
38
|
-
assert_equal @rr_address, @record.address
|
39
|
-
assert_equal @rr_value, @record.value
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_parse
|
43
|
-
data = "\003www\003nic\002it\000\000\034\000\001\000\000\000<\000\020*\000\r@\000\001\000\001\000\000\000\000\000\000\0029"
|
44
|
-
@record = Net::DNS::RR.parse(data)
|
45
|
-
assert_equal @rr_output, @record.to_s
|
46
|
-
assert_equal @rr_name, @record.name
|
47
|
-
assert_equal @rr_type, @record.type
|
48
|
-
assert_equal @rr_cls, @record.cls
|
49
|
-
assert_equal @rr_ttl, @record.ttl
|
50
|
-
assert_equal @rr_address, @record.address
|
51
|
-
assert_equal @rr_value, @record.value
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
InvalidArguments = [
|
56
|
-
{ :name => "google.com", :address => "2a00" },
|
57
|
-
{ :name => "google.com" },
|
58
|
-
Object.new,
|
59
|
-
Array.new(7),
|
60
|
-
"10800 IN AAAA",
|
61
|
-
# FIXME: "google.com. 10800 IN B",
|
62
|
-
# FIXME: "google.com. 10800 IM AAAA",
|
63
|
-
]
|
64
|
-
|
65
|
-
InvalidArguments.each_with_index do |arguments, index|
|
66
|
-
define_method "test_initialize_should_raise_with_invalid_arguments_#{index}" do
|
67
|
-
assert_raises(ArgumentError) { Net::DNS::RR::AAAA.new(arguments) }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
def test_address_getter
|
73
|
-
assert_equal @rr_address, @rr.address
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_address_setter
|
77
|
-
assert_raises(ArgumentError) { @rr.address = nil }
|
78
|
-
|
79
|
-
expected = IPAddr.new("2a00:d40:1:1::239")
|
80
|
-
assert_equal expected, @rr.address = "2a00:d40:1:1::239"
|
81
|
-
assert_equal expected, @rr.address
|
82
|
-
|
83
|
-
expected = IPAddr.new("2a00:d40:1:1::240")
|
84
|
-
assert_equal expected, @rr.address = IPAddr.new("2a00:d40:1:1::240")
|
85
|
-
assert_equal expected, @rr.address
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
def test_value
|
90
|
-
assert_equal @rr_value, @rr.value
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
def test_inspect
|
95
|
-
assert_equal "www.nic.it. 60 IN AAAA 2a00:d40:1:1::239",
|
96
|
-
@rr.inspect
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_to_s
|
100
|
-
assert_equal "www.nic.it. 60 IN AAAA 2a00:d40:1:1::239",
|
101
|
-
@rr.to_s
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_to_a
|
105
|
-
assert_equal ["www.nic.it.", 60, "IN", "AAAA", "2a00:d40:1:1::239"],
|
106
|
-
@rr.to_a
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
data/test/rr/classes_test.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/rr'
|
3
|
-
|
4
|
-
class RRClassesTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@classes = {
|
8
|
-
}
|
9
|
-
@regexp_string = "ANY|CH|HS|IN|NONE"
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
StrAndNum = [
|
14
|
-
['IN' , 1],
|
15
|
-
['CH' , 3],
|
16
|
-
['HS' , 4],
|
17
|
-
['NONE' , 254],
|
18
|
-
['ANY' , 255],
|
19
|
-
]
|
20
|
-
|
21
|
-
StrAndNum.each do |str, num|
|
22
|
-
define_method "test_initialize_from_str_#{str}" do
|
23
|
-
instance = Net::DNS::RR::Classes.new(str)
|
24
|
-
assert_equal str, instance.to_s
|
25
|
-
assert_equal num, instance.to_i
|
26
|
-
end
|
27
|
-
define_method "test_initialize_from_num_#{num}" do
|
28
|
-
instance = Net::DNS::RR::Classes.new(num)
|
29
|
-
assert_equal str, instance.to_s
|
30
|
-
assert_equal num, instance.to_i
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_initialize_should_raise_with_invalid_class
|
35
|
-
assert_raises(ArgumentError) { Net::DNS::RR::Classes.new(Hash.new) }
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def test_inspect
|
40
|
-
assert_equal 1, Net::DNS::RR::Classes.new(1).inspect
|
41
|
-
assert_equal 1, Net::DNS::RR::Classes.new("IN").inspect
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_to_s
|
45
|
-
assert_equal "IN", Net::DNS::RR::Classes.new(1).to_s
|
46
|
-
assert_equal "IN", Net::DNS::RR::Classes.new("IN").to_s
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_to_i
|
50
|
-
assert_equal 1, Net::DNS::RR::Classes.new(1).to_i
|
51
|
-
assert_equal 1, Net::DNS::RR::Classes.new("IN").to_i
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
def test_self_default
|
56
|
-
# Default type should be ANY => 255
|
57
|
-
instance = Net::DNS::RR::Classes.new(nil)
|
58
|
-
assert_equal 1, instance.to_i
|
59
|
-
assert_equal "IN", instance.to_s
|
60
|
-
|
61
|
-
# Let's change default behaviour
|
62
|
-
Net::DNS::RR::Classes.default = "CH"
|
63
|
-
instance = Net::DNS::RR::Classes.new(nil)
|
64
|
-
assert_equal 3, instance.to_i
|
65
|
-
assert_equal "CH", instance.to_s
|
66
|
-
|
67
|
-
Net::DNS::RR::Classes.default = "IN"
|
68
|
-
instance = Net::DNS::RR::Classes.new(nil)
|
69
|
-
assert_equal 1, instance.to_i
|
70
|
-
assert_equal "IN", instance.to_s
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_self_valid?
|
74
|
-
assert Net::DNS::RR::Classes.valid?("IN")
|
75
|
-
assert Net::DNS::RR::Classes.valid?(1)
|
76
|
-
assert !Net::DNS::RR::Classes.valid?("Q")
|
77
|
-
assert !Net::DNS::RR::Classes.valid?(256)
|
78
|
-
assert_raises(ArgumentError) { Net::DNS::RR::Classes.valid?(Hash.new) }
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_self_regexp
|
82
|
-
assert_equal @regexp_string, Net::DNS::RR::Classes.regexp
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
data/test/rr/cname_test.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/rr'
|
3
|
-
|
4
|
-
class RRCNAMETest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@rr_name = "www.google.com."
|
8
|
-
@rr_type = "CNAME"
|
9
|
-
@rr_cls = "IN"
|
10
|
-
@rr_ttl = 550317
|
11
|
-
@rr_value = "www.l.google.com."
|
12
|
-
@rr_cname = @rr_value
|
13
|
-
|
14
|
-
@rr_output = "www.google.com. 550317 IN CNAME www.l.google.com."
|
15
|
-
|
16
|
-
@rr = Net::DNS::RR::CNAME.new(:name => @rr_name, :cname => @rr_cname, :ttl => @rr_ttl)
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def test_initialize_from_hash
|
21
|
-
@record = Net::DNS::RR::CNAME.new(:name => @rr_name, :cname => @rr_value, :ttl => @rr_ttl)
|
22
|
-
assert_equal @rr_output, @record.to_s
|
23
|
-
assert_equal @rr_name, @record.name
|
24
|
-
assert_equal @rr_type, @record.type
|
25
|
-
assert_equal @rr_cls, @record.cls
|
26
|
-
assert_equal @rr_ttl, @record.ttl
|
27
|
-
assert_equal @rr_cname, @record.cname
|
28
|
-
assert_equal @rr_value, @record.value
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_initialize_from_string
|
32
|
-
@record = Net::DNS::RR::CNAME.new("#{@rr_name} #{@rr_ttl} #{@rr_cls} #{@rr_type} #{@rr_value}")
|
33
|
-
assert_equal @rr_output, @record.to_s
|
34
|
-
assert_equal @rr_name, @record.name
|
35
|
-
assert_equal @rr_type, @record.type
|
36
|
-
assert_equal @rr_cls, @record.cls
|
37
|
-
assert_equal @rr_ttl, @record.ttl
|
38
|
-
assert_equal @rr_cname, @record.cname
|
39
|
-
assert_equal @rr_value, @record.value
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_parse
|
43
|
-
data = "\003www\006google\003com\000\000\005\000\001\000\be\255\000\022\003www\001l\006google\003com\000"
|
44
|
-
@record = Net::DNS::RR.parse(data)
|
45
|
-
assert_equal @rr_output, @record.to_s
|
46
|
-
assert_equal @rr_name, @record.name
|
47
|
-
assert_equal @rr_type, @record.type
|
48
|
-
assert_equal @rr_cls, @record.cls
|
49
|
-
assert_equal @rr_ttl, @record.ttl
|
50
|
-
assert_equal @rr_cname, @record.cname
|
51
|
-
assert_equal @rr_value, @record.value
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
InvalidArguments = [
|
56
|
-
# FIXME: { :name => "google.com", :cname => "foo___bar" },
|
57
|
-
# FIXME: { :name => "google.com", :cname => "foo$bar" },
|
58
|
-
{ :name => "google.com" },
|
59
|
-
Object.new,
|
60
|
-
Array.new(7),
|
61
|
-
"10800 IN CNAME",
|
62
|
-
"google.com. 10800 IN CNAME",
|
63
|
-
]
|
64
|
-
|
65
|
-
InvalidArguments.each_with_index do |arguments, index|
|
66
|
-
define_method "test_initialize_should_raise_with_invalid_arguments_#{index}" do
|
67
|
-
assert_raises(ArgumentError) { p Net::DNS::RR::CNAME.new(arguments) }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
def test_cname_getter
|
73
|
-
assert_equal @rr_cname, @rr.cname
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
def test_value
|
78
|
-
assert_equal @rr_value, @rr.value
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
def test_inspect
|
83
|
-
assert_equal "www.google.com. 550317 IN CNAME www.l.google.com.",
|
84
|
-
@rr.inspect
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_to_s
|
88
|
-
assert_equal "www.google.com. 550317 IN CNAME www.l.google.com.",
|
89
|
-
@rr.to_s
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_to_a
|
93
|
-
assert_equal ["www.google.com.", 550317, "IN", "CNAME", "www.l.google.com."],
|
94
|
-
@rr.to_a
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
data/test/rr/hinfo_test.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/rr'
|
3
|
-
require 'net/dns/rr/hinfo'
|
4
|
-
|
5
|
-
class RRHINFOTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@rr_name = ""
|
9
|
-
@rr_type = "HINFO"
|
10
|
-
@rr_cls = "IN"
|
11
|
-
@rr_ttl = nil
|
12
|
-
@rr_value = %Q{"PC-Intel-700mhz" "Redhat Linux 7.1"}
|
13
|
-
@rr_output = %Q{ IN HINFO "PC-Intel-700mhz" "Redhat Linux 7.1"}
|
14
|
-
|
15
|
-
@rr_cpu = "PC-Intel-700mhz"
|
16
|
-
@rr_os = "Redhat Linux 7.1"
|
17
|
-
|
18
|
-
@rr = Net::DNS::RR::HINFO.new(:name => @rr_name, :cpu => @rr_cpu, :os => @rr_os)
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def test_initialize_from_hash
|
23
|
-
@record = Net::DNS::RR::HINFO.new(:name => @rr_name, :cpu => @rr_cpu, :os => @rr_os)
|
24
|
-
assert_equal @rr_output, @record.to_s
|
25
|
-
assert_equal @rr_name, @record.name
|
26
|
-
assert_equal @rr_type, @record.type
|
27
|
-
assert_equal @rr_cls, @record.cls
|
28
|
-
assert_equal 10800, @record.ttl
|
29
|
-
assert_equal @rr_value, @record.value
|
30
|
-
|
31
|
-
assert_equal @rr_cpu, @record.cpu
|
32
|
-
assert_equal @rr_os, @record.os
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_initialize_from_string
|
36
|
-
@record = Net::DNS::RR::HINFO.new(%Q{#{@rr_name} #{@rr_ttl} #{@rr_cls} #{@rr_type} PC-Intel-700mhz "Redhat Linux 7.1"})
|
37
|
-
assert_equal @rr_output, @record.to_s
|
38
|
-
assert_equal @rr_value, @record.value
|
39
|
-
|
40
|
-
assert_equal @rr_cpu, @record.cpu
|
41
|
-
assert_equal @rr_os, @record.os
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_initialize_from_string_without_quotes
|
45
|
-
@record = Net::DNS::RR::HINFO.new("#{@rr_name} #{@rr_ttl} #{@rr_cls} #{@rr_type} #{@rr_value}")
|
46
|
-
assert_equal @rr_output, @record.to_s
|
47
|
-
# FIXME: assert_equal @rr_name, @record.name
|
48
|
-
assert_equal @rr_type, @record.type
|
49
|
-
assert_equal @rr_cls, @record.cls
|
50
|
-
assert_equal 10800, @record.ttl
|
51
|
-
assert_equal @rr_value, @record.value
|
52
|
-
|
53
|
-
assert_equal @rr_cpu, @record.cpu
|
54
|
-
assert_equal @rr_os, @record.os
|
55
|
-
end
|
56
|
-
|
57
|
-
# FIXME: Can't get valid data
|
58
|
-
# def test_parse
|
59
|
-
# data = "\002in\000\000\r\000\001\000\000*0\000!\017PC-Intel-700mhz\020Redhat Linux 7.1"
|
60
|
-
# @record = Net::DNS::RR.parse(data)
|
61
|
-
# assert_equal @rr_output, @record.to_s
|
62
|
-
# assert_equal @rr_name, @record.name
|
63
|
-
# assert_equal @rr_type, @record.type
|
64
|
-
# assert_equal @rr_cls, @record.cls
|
65
|
-
# assert_equal @rr_ttl, @record.ttl
|
66
|
-
# assert_equal @rr_value, @record.value
|
67
|
-
#
|
68
|
-
# assert_equal @rr_cpu, @record.cpu
|
69
|
-
# assert_equal @rr_os, @record.os
|
70
|
-
# end
|
71
|
-
|
72
|
-
|
73
|
-
InvalidArguments = [
|
74
|
-
{ :name => "google.com" },
|
75
|
-
Object.new,
|
76
|
-
Array.new(7),
|
77
|
-
"10800 IN HINFO",
|
78
|
-
"IN HINFO",
|
79
|
-
]
|
80
|
-
|
81
|
-
InvalidArguments.each_with_index do |arguments, index|
|
82
|
-
define_method "test_initialize_should_raise_with_invalid_arguments_#{index}" do
|
83
|
-
assert_raises(ArgumentError) { p Net::DNS::RR::HINFO.new(arguments) }
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
def test_cpu
|
89
|
-
assert_equal @rr_cpu, @rr.cpu
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_os
|
93
|
-
assert_equal @rr_os, @rr.os
|
94
|
-
end
|
95
|
-
|
96
|
-
|
97
|
-
def test_value
|
98
|
-
assert_equal %Q{"PC-Intel-700mhz" "Redhat Linux 7.1"}, @rr.value
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
def test_inspect
|
103
|
-
assert_equal %Q{ IN HINFO "PC-Intel-700mhz" "Redhat Linux 7.1"},
|
104
|
-
@rr.inspect
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_to_s
|
108
|
-
assert_equal %Q{ IN HINFO "PC-Intel-700mhz" "Redhat Linux 7.1"},
|
109
|
-
@rr.to_s
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_to_a
|
113
|
-
assert_equal [nil, nil, "IN", "HINFO", %Q{"PC-Intel-700mhz" "Redhat Linux 7.1"}],
|
114
|
-
@rr.to_a
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
data/test/rr/mr_test.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/rr'
|
3
|
-
|
4
|
-
class RRMRTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@klass = Net::DNS::RR::MR
|
8
|
-
@rr = @klass.new(:name => "eddie.movie.edu.", :newname => "eddie.bornagain.edu.", :ttl => 9000)
|
9
|
-
|
10
|
-
@rr_name = "eddie.movie.edu."
|
11
|
-
@rr_type = "MR"
|
12
|
-
@rr_cls = "IN"
|
13
|
-
@rr_ttl = 9000
|
14
|
-
@rr_newname = "eddie.bornagain.edu."
|
15
|
-
@rr_value = "eddie.bornagain.edu."
|
16
|
-
@rr_output = "eddie.movie.edu. 9000 IN MR eddie.bornagain.edu."
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def test_initialize_from_hash
|
21
|
-
@record = @klass.new(:name => "eddie.movie.edu.", :newname => "eddie.bornagain.edu.", :ttl => 9000)
|
22
|
-
assert_equal @rr_output, @record.inspect
|
23
|
-
assert_equal @rr_name, @record.name
|
24
|
-
assert_equal @rr_type, @record.type
|
25
|
-
assert_equal @rr_cls, @record.cls
|
26
|
-
assert_equal @rr_ttl, @record.ttl
|
27
|
-
assert_equal @rr_newname, @record.newname
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_initialize_from_string
|
31
|
-
@record = @klass.new("eddie.movie.edu. 9000 IN MR eddie.bornagain.edu.")
|
32
|
-
assert_equal @rr_output, @record.inspect
|
33
|
-
assert_equal @rr_name, @record.name
|
34
|
-
assert_equal @rr_type, @record.type
|
35
|
-
assert_equal @rr_cls, @record.cls
|
36
|
-
assert_equal @rr_ttl, @record.ttl
|
37
|
-
assert_equal @rr_newname, @record.newname
|
38
|
-
end
|
39
|
-
|
40
|
-
# def test_parse
|
41
|
-
# data = "\005eddie\005movie\003edu\000\000\t\000\001\000\000#(\000\025\005eddie\tbornagain\003edu\000"
|
42
|
-
# @record = Net::DNS::RR.parse(data)
|
43
|
-
# assert_equal @rr_output, @record.inspect
|
44
|
-
# assert_equal @rr_name, @record.name
|
45
|
-
# assert_equal @rr_type, @record.type
|
46
|
-
# assert_equal @rr_cls, @record.cls
|
47
|
-
# assert_equal @rr_ttl, @record.ttl
|
48
|
-
# assert_equal @rr_newname, @record.newname
|
49
|
-
# end
|
50
|
-
|
51
|
-
|
52
|
-
InvalidArguments = [
|
53
|
-
# FIXME: { :name => "eddie.movie.edu.", :newname => "foo___bar" },
|
54
|
-
# FIXME: { :name => "eddie.movie.edu.", :newname => "foo$bar" },
|
55
|
-
# FIXME: { :name => "eddie.movie.edu", :newname => "eddie.newname.edu." },
|
56
|
-
Object.new,
|
57
|
-
Array.new(7),
|
58
|
-
"9000 IN MR",
|
59
|
-
]
|
60
|
-
|
61
|
-
InvalidArguments.each_with_index do |arguments, index|
|
62
|
-
define_method "test_initialize_should_raise_with_invalid_arguments_#{index}" do
|
63
|
-
assert_raises(ArgumentError) { @klass.new(arguments) }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_initialize_should_raise_with_missing_newname
|
68
|
-
error = assert_raises(ArgumentError) { @klass.new(:name => "eddie.movie.edu.") }
|
69
|
-
assert_match /:newname/, error.message
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
def test_value
|
74
|
-
@rr = @klass.new(:name => "eddie.movie.edu.", :newname => "eddie.newname.edu.")
|
75
|
-
assert_equal "eddie.newname.edu.", @rr.value
|
76
|
-
|
77
|
-
@rr = @klass.new(:name => "eddie.movie.edu.", :newname => "eddie.othername.edu.")
|
78
|
-
assert_equal "eddie.othername.edu.", @rr.value
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_newname
|
82
|
-
@rr = @klass.new(:name => "eddie.movie.edu.", :newname => "eddie.newname.edu.")
|
83
|
-
assert_equal "eddie.newname.edu.", @rr.newname
|
84
|
-
|
85
|
-
@rr = @klass.new(:name => "eddie.movie.edu.", :newname => "eddie.othername.edu.")
|
86
|
-
assert_equal "eddie.othername.edu.", @rr.newname
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
def test_inspect
|
91
|
-
assert_equal "eddie.movie.edu. 9000 IN MR eddie.bornagain.edu.",
|
92
|
-
@rr.inspect
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_to_s
|
96
|
-
assert_equal "eddie.movie.edu. 9000 IN MR eddie.bornagain.edu.",
|
97
|
-
@rr.to_s
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_to_a
|
101
|
-
assert_equal ["eddie.movie.edu.", 9000, "IN", "MR", "eddie.bornagain.edu."],
|
102
|
-
@rr.to_a
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|