net-dns2 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +13 -5
- data/.travis.yml +2 -10
- data/CHANGELOG.md +22 -0
- data/README.md +19 -16
- data/Rakefile +8 -63
- data/lib/net/dns.rb +1 -0
- data/lib/net/dns/header.rb +7 -3
- data/lib/net/dns/names.rb +16 -8
- data/lib/net/dns/packet.rb +15 -7
- data/lib/net/dns/resolver.rb +49 -50
- data/lib/net/dns/rr.rb +1 -1
- data/lib/net/dns/rr/a.rb +1 -3
- data/lib/net/dns/rr/soa.rb +25 -18
- data/lib/net/dns/rr/txt.rb +12 -2
- data/lib/net/dns/rr/types.rb +1 -0
- data/net-dns.gemspec +25 -6
- metadata +26 -44
- 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_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/ns_test.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/rr'
|
3
|
-
|
4
|
-
class RRNSTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@rr_name = "google.com."
|
8
|
-
@rr_type = "NS"
|
9
|
-
@rr_cls = "IN"
|
10
|
-
@rr_ttl = 10800
|
11
|
-
@rr_nsdname = "ns1.google.com."
|
12
|
-
|
13
|
-
@rr_output = "google.com. 10800 IN NS ns1.google.com."
|
14
|
-
|
15
|
-
@rr = Net::DNS::RR::NS.new(:name => "google.com.", :nsdname => "ns1.google.com.", :ttl => @rr_ttl)
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
def test_initialize_from_hash
|
20
|
-
@record = Net::DNS::RR::NS.new(:name => "google.com.", :nsdname => "ns1.google.com.")
|
21
|
-
assert_equal @rr_output, @record.inspect
|
22
|
-
assert_equal @rr_name, @record.name
|
23
|
-
assert_equal @rr_type, @record.type
|
24
|
-
assert_equal @rr_cls, @record.cls
|
25
|
-
assert_equal @rr_ttl, @record.ttl
|
26
|
-
assert_equal @rr_nsdname, @record.nsdname
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_initialize_from_string
|
30
|
-
@record = Net::DNS::RR::NS.new("google.com. 10800 IN NS ns1.google.com.")
|
31
|
-
assert_equal @rr_output, @record.inspect
|
32
|
-
assert_equal @rr_name, @record.name
|
33
|
-
assert_equal @rr_type, @record.type
|
34
|
-
assert_equal @rr_cls, @record.cls
|
35
|
-
assert_equal @rr_ttl, @record.ttl
|
36
|
-
assert_equal @rr_nsdname, @record.nsdname
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_parse
|
40
|
-
data = "\006google\003com\000\000\002\000\001\000\000*0\000\020\003ns1\006google\003com\000"
|
41
|
-
@record = Net::DNS::RR.parse(data)
|
42
|
-
assert_equal @rr_output, @record.inspect
|
43
|
-
assert_equal @rr_name, @record.name
|
44
|
-
assert_equal @rr_type, @record.type
|
45
|
-
assert_equal @rr_cls, @record.cls
|
46
|
-
assert_equal @rr_ttl, @record.ttl
|
47
|
-
assert_equal @rr_nsdname, @record.nsdname
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
InvalidArguments = [
|
52
|
-
{ :name => "google.com", :nsdname => "255.256" },
|
53
|
-
{ :name => "google.com" },
|
54
|
-
Object.new,
|
55
|
-
Array.new(7),
|
56
|
-
"10800 IN A",
|
57
|
-
]
|
58
|
-
|
59
|
-
InvalidArguments.each_with_index do |arguments, index|
|
60
|
-
define_method "test_initialize_should_raise_with_invalid_arguments_#{index}" do
|
61
|
-
assert_raises(ArgumentError) { Net::DNS::RR::NS.new(arguments) }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
def test_value
|
67
|
-
assert_equal "ns1.google.com.", @rr.value
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def test_inspect
|
72
|
-
assert_equal "google.com. 10800 IN NS ns1.google.com.",
|
73
|
-
@rr.inspect
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_to_s
|
77
|
-
assert_equal "google.com. 10800 IN NS ns1.google.com.",
|
78
|
-
@rr.to_s
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_to_a
|
82
|
-
assert_equal ["google.com.", 10800, "IN", "NS", "ns1.google.com."],
|
83
|
-
@rr.to_a
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
data/test/rr/types_test.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/rr'
|
3
|
-
|
4
|
-
class RRTypesTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_default
|
10
|
-
# Default type should be ANY => 255
|
11
|
-
instance = Net::DNS::RR::Types.new(nil)
|
12
|
-
assert_equal("1", instance.to_str)
|
13
|
-
assert_equal("A", instance.to_s)
|
14
|
-
|
15
|
-
# Let's change default behaviour
|
16
|
-
Net::DNS::RR::Types.default = "A"
|
17
|
-
instance = Net::DNS::RR::Types.new(nil)
|
18
|
-
assert_equal("1", instance.to_str)
|
19
|
-
assert_equal("A", instance.to_s)
|
20
|
-
|
21
|
-
Net::DNS::RR::Types.default = "ANY"
|
22
|
-
instance = Net::DNS::RR::Types.new(nil)
|
23
|
-
assert_equal("255", instance.to_str)
|
24
|
-
assert_equal("ANY", instance.to_s)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_types
|
28
|
-
Net::DNS::RR::Types::TYPES.each do |key, num|
|
29
|
-
instance_from_string = Net::DNS::RR::Types.new(key)
|
30
|
-
instance_from_num = Net::DNS::RR::Types.new(num)
|
31
|
-
assert_equal(key, instance_from_string.to_s)
|
32
|
-
assert_equal(num.to_s, instance_from_string.to_str)
|
33
|
-
assert_equal(key, instance_from_num.to_s)
|
34
|
-
assert_equal(num.to_s, instance_from_num.to_str)
|
35
|
-
end
|
36
|
-
assert_raises(ArgumentError) do
|
37
|
-
Net::DNS::RR::Types.new(Hash.new)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_regexp
|
42
|
-
pattern = Net::DNS::RR::Types.regexp
|
43
|
-
assert_instance_of String, pattern
|
44
|
-
Net::DNS::RR::Types::TYPES.each do |key, num|
|
45
|
-
assert_match /\|?#{key}\|?/, pattern
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_valid?
|
50
|
-
assert_equal(true, Net::DNS::RR::Types.valid?("A"))
|
51
|
-
assert_equal(true, Net::DNS::RR::Types.valid?(1))
|
52
|
-
assert_equal(false, Net::DNS::RR::Types.valid?("Q"))
|
53
|
-
assert_equal(false, Net::DNS::RR::Types.valid?(256))
|
54
|
-
assert_raises(ArgumentError) do
|
55
|
-
Net::DNS::RR::Types.valid? Hash.new
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_to_str
|
60
|
-
assert_equal("A", Net::DNS::RR::Types.to_str(1))
|
61
|
-
assert_raises(ArgumentError) do
|
62
|
-
Net::DNS::RR::Types.to_str(256)
|
63
|
-
end
|
64
|
-
assert_raises(ArgumentError) do
|
65
|
-
Net::DNS::RR::Types.to_str("string")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
data/test/rr_test.rb
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/rr'
|
3
|
-
|
4
|
-
class RRTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@rr_name = "example.com."
|
8
|
-
@type = "A"
|
9
|
-
@cls = "IN"
|
10
|
-
@ttl = 10800
|
11
|
-
@rdata = "64.233.187.99"
|
12
|
-
|
13
|
-
@defaults = Net::DNS::RR.new(:name => @rr_name,
|
14
|
-
:rdata => @rdata)
|
15
|
-
|
16
|
-
|
17
|
-
@a_hash = Net::DNS::RR.new(:name => @rr_name,
|
18
|
-
:ttl => @ttl,
|
19
|
-
:cls => @cls,
|
20
|
-
:type => @type,
|
21
|
-
:address => @rdata)
|
22
|
-
|
23
|
-
@a_string = Net::DNS::RR::A.new("example.com. 10800 IN A 64.233.187.99")
|
24
|
-
|
25
|
-
@str = "example.com. 10800 IN A 64.233.187.99"
|
26
|
-
|
27
|
-
@a = Net::DNS::RR.new("foo.example.com. 86400 A 10.1.2.3")
|
28
|
-
@mx = Net::DNS::RR.new("example.com. 7200 MX 10 mailhost.example.com.")
|
29
|
-
@cname = Net::DNS::RR.new("www.example.com IN CNAME www1.example.com")
|
30
|
-
@txt = Net::DNS::RR.new('baz.example.com 3600 HS TXT "text record"')
|
31
|
-
|
32
|
-
@a_data = @a.data
|
33
|
-
@a_binary = Net::DNS::RR.parse(@a_data)
|
34
|
-
@mx_data = @mx.data
|
35
|
-
@mx_binary = Net::DNS::RR.parse(@mx_data)
|
36
|
-
|
37
|
-
@array = [@rr_name,@ttl,@cls,@type,@rdata]
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_classes
|
41
|
-
assert_instance_of Net::DNS::RR::A, @a
|
42
|
-
assert_instance_of Net::DNS::RR::MX, @mx
|
43
|
-
assert_instance_of Net::DNS::RR::CNAME, @cname
|
44
|
-
assert_instance_of Net::DNS::RR::TXT, @txt
|
45
|
-
assert_instance_of Net::DNS::RR::A, @a_binary
|
46
|
-
assert_instance_of Net::DNS::RR::MX, @mx_binary
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_ttl
|
50
|
-
assert_equal @a.ttl, 86400
|
51
|
-
assert_equal @mx.ttl, 7200
|
52
|
-
assert_equal @cname.ttl, 10800
|
53
|
-
assert_equal @txt.ttl, 3600
|
54
|
-
assert_equal @a_binary.ttl, 86400
|
55
|
-
assert_equal @mx_binary.ttl, 7200
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_types
|
59
|
-
assert_equal @a.type, "A"
|
60
|
-
assert_equal @mx.type, "MX"
|
61
|
-
assert_equal @cname.type, "CNAME"
|
62
|
-
assert_equal @txt.type, "TXT"
|
63
|
-
assert_equal @a_binary.type, "A"
|
64
|
-
assert_equal @mx_binary.type, "MX"
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_cls
|
68
|
-
assert_equal @a.cls, "IN"
|
69
|
-
assert_equal @mx.cls, "IN"
|
70
|
-
assert_equal @cname.cls, "IN"
|
71
|
-
assert_equal @txt.cls, "HS"
|
72
|
-
assert_equal @a_binary.cls, "IN"
|
73
|
-
assert_equal @mx_binary.cls, "IN"
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_name
|
77
|
-
assert_equal @a.name, "foo.example.com."
|
78
|
-
assert_equal @mx.name, "example.com."
|
79
|
-
assert_equal @cname.name, "www.example.com"
|
80
|
-
assert_equal @txt.name, "baz.example.com"
|
81
|
-
assert_equal @a_binary.name, "foo.example.com."
|
82
|
-
assert_equal @mx_binary.name, "example.com."
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_rdata
|
86
|
-
assert_equal @a.address.to_s, "10.1.2.3"
|
87
|
-
assert_equal @mx.preference, 10
|
88
|
-
assert_equal @mx.exchange, "mailhost.example.com."
|
89
|
-
assert_equal @cname.cname, "www1.example.com"
|
90
|
-
assert_equal @txt.txt, '"text record"'
|
91
|
-
assert_equal @a_binary.address.to_s, "10.1.2.3"
|
92
|
-
assert_equal @mx_binary.preference, 10
|
93
|
-
assert_equal @mx_binary.exchange, "mailhost.example.com."
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_simple
|
97
|
-
assert_equal @rr_name, @defaults.name
|
98
|
-
assert_equal @type, @defaults.type
|
99
|
-
assert_equal @cls, @defaults.cls
|
100
|
-
assert_equal @ttl, @defaults.ttl
|
101
|
-
assert_equal @rdata, @defaults.rdata.to_s
|
102
|
-
|
103
|
-
assert_equal(@str,@a_hash.inspect)
|
104
|
-
assert_equal(@rr_name, @a_hash.name)
|
105
|
-
assert_equal(@type, @a_hash.type)
|
106
|
-
assert_equal(@cls, @a_hash.cls)
|
107
|
-
assert_equal(@ttl, @a_hash.ttl)
|
108
|
-
assert_equal(@rdata, @a_hash.address.to_s)
|
109
|
-
|
110
|
-
assert_equal(@str, @a_string.inspect)
|
111
|
-
assert_equal(@rr_name, @a_string.name)
|
112
|
-
assert_equal(@type, @a_string.type)
|
113
|
-
assert_equal(@cls, @a_string.cls)
|
114
|
-
assert_equal(@ttl, @a_string.ttl)
|
115
|
-
assert_equal(@rdata, @a_string.address.to_s)
|
116
|
-
|
117
|
-
assert_equal(@a_data, @a_binary.data)
|
118
|
-
assert_equal(@mx_data, @mx_binary.data)
|
119
|
-
|
120
|
-
assert_equal(@str, @a_hash.to_s)
|
121
|
-
assert_equal(@array, @a_hash.to_a)
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_range
|
125
|
-
assert_raises(ArgumentError) do
|
126
|
-
Net::DNS::RR.new("google.com. 10800 IM A")
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
|
data/test/test_helper.rb
DELETED