net-dns2 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- 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/names_test.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/names'
|
3
|
-
|
4
|
-
class NamesTest < Test::Unit::TestCase
|
5
|
-
include Net::DNS::Names
|
6
|
-
|
7
|
-
def test_long_names
|
8
|
-
assert_nothing_raised do
|
9
|
-
pack_name('a' * 63)
|
10
|
-
end
|
11
|
-
assert_raises ArgumentError do
|
12
|
-
pack_name('a' * 64)
|
13
|
-
end
|
14
|
-
assert_nothing_raised do
|
15
|
-
pack_name(['a' * 63, 'b' * 63, 'c' * 63, 'd' * 63].join('.'))
|
16
|
-
end
|
17
|
-
assert_raises ArgumentError do
|
18
|
-
pack_name(['a' * 63, 'b' * 63, 'c' * 63, 'd' * 63, 'e'].join('.'))
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/test/packet_test.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/packet'
|
3
|
-
|
4
|
-
class PacketTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@klass = Net::DNS::Packet
|
8
|
-
@domain = 'example.com'
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_initialize
|
12
|
-
@record = @klass.new(@domain, Net::DNS::MX, Net::DNS::HS)
|
13
|
-
assert_instance_of @klass, @record
|
14
|
-
assert_instance_of Net::DNS::Header, @record.header
|
15
|
-
assert_instance_of Array, @record.question
|
16
|
-
assert_instance_of Net::DNS::Question, @record.question.first
|
17
|
-
assert_instance_of Array, @record.answer
|
18
|
-
assert_instance_of Array, @record.authority
|
19
|
-
assert_instance_of Array, @record.additional
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_initialize_should_set_question
|
23
|
-
@question = @klass.new(@domain).question.first
|
24
|
-
assert_equal @domain, @question.qName
|
25
|
-
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
|
27
|
-
|
28
|
-
@question = @klass.new(@domain, Net::DNS::MX, Net::DNS::HS).question.first
|
29
|
-
assert_equal @domain, @question.qName
|
30
|
-
assert_equal Net::DNS::RR::Types.new(Net::DNS::MX).to_s, @question.qType.to_s
|
31
|
-
assert_equal Net::DNS::RR::Classes.new(Net::DNS::HS).to_s, @question.qClass.to_s
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_self_parse
|
35
|
-
packet = "\337M\201\200\000\001\000\003\000\004\000\004\006google\003com\000\000\001\000\001\300\f\000\001\000\001\000\000\001,\000\004@\351\273c\300\f\000\001\000\001\000\000\001,\000\004H\016\317c\300\f\000\001\000\001\000\000\001,\000\004@\351\247c\300\f\000\002\000\001\000\003\364\200\000\006\003ns1\300\f\300\f\000\002\000\001\000\003\364\200\000\006\003ns2\300\f\300\f\000\002\000\001\000\003\364\200\000\006\003ns3\300\f\300\f\000\002\000\001\000\003\364\200\000\006\003ns4\300\f\300X\000\001\000\001\000\003\307\273\000\004\330\357 \n\300j\000\001\000\001\000\003\307\273\000\004\330\357\"\n\300|\000\001\000\001\000\003\307\273\000\004\330\357$\n\300\216\000\001\000\001\000\003\307\273\000\004\330\357&\n"
|
36
|
-
@record = @klass.parse(packet)
|
37
|
-
assert_instance_of @klass, @record
|
38
|
-
assert_instance_of Net::DNS::Header, @record.header
|
39
|
-
assert_instance_of Array, @record.question
|
40
|
-
assert_instance_of Net::DNS::Question, @record.question.first
|
41
|
-
assert_instance_of Array, @record.answer
|
42
|
-
assert_instance_of Net::DNS::RR::A, @record.answer.first
|
43
|
-
assert_instance_of Array, @record.authority
|
44
|
-
assert_instance_of Net::DNS::RR::NS, @record.authority.first
|
45
|
-
assert_instance_of Array, @record.additional
|
46
|
-
assert_instance_of Net::DNS::RR::A, @record.additional.first
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
data/test/question_test.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/question'
|
3
|
-
|
4
|
-
class QuestionTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@domain = 'example.com.'
|
8
|
-
@type = 'MX'
|
9
|
-
@cls = 'HS'
|
10
|
-
@data = "\006google\003com\000\000\001\000\001"
|
11
|
-
|
12
|
-
@default = Net::DNS::Question.new(@domain)
|
13
|
-
@string = Net::DNS::Question.new(@domain,@type,@cls)
|
14
|
-
@binary = Net::DNS::Question.parse(@data)
|
15
|
-
@binary2 = Net::DNS::Question.parse(@string.data)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_simple
|
19
|
-
assert_equal(@default.qName, @domain)
|
20
|
-
assert_equal(@default.qType.to_s, "A")
|
21
|
-
assert_equal(@default.qClass.to_s, "IN")
|
22
|
-
|
23
|
-
assert_equal(@string.qName, @domain)
|
24
|
-
assert_equal(@string.qType.to_s, "MX")
|
25
|
-
assert_equal(@string.qClass.to_s, "HS")
|
26
|
-
|
27
|
-
assert_equal(@binary.qName, "google.com.")
|
28
|
-
assert_equal(@binary.qType.to_s, "A")
|
29
|
-
assert_equal(@binary.qClass.to_s, "IN")
|
30
|
-
|
31
|
-
assert_equal(@binary2.qName, @domain)
|
32
|
-
assert_equal(@binary2.qType.to_s, "MX")
|
33
|
-
assert_equal(@binary2.qClass.to_s, "HS")
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_raise
|
37
|
-
# assert_raises(Net::DNS::Question::NameInvalid) do
|
38
|
-
# Net::DNS::Question.new(1)
|
39
|
-
# end
|
40
|
-
assert_raises(Net::DNS::Question::NameInvalid) do
|
41
|
-
Net::DNS::Question.new("test{")
|
42
|
-
end
|
43
|
-
assert_raises(ArgumentError) do
|
44
|
-
Net::DNS::Question.parse(Array.new)
|
45
|
-
end
|
46
|
-
assert_raises(ArgumentError) do
|
47
|
-
Net::DNS::Question.parse("test")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_inspect
|
52
|
-
assert_equal "google.com. IN A ",
|
53
|
-
Net::DNS::Question.new("google.com.").inspect
|
54
|
-
assert_equal "google.com. IN A ",
|
55
|
-
Net::DNS::Question.new("google.com.", Net::DNS::A).inspect
|
56
|
-
assert_equal "google.com. IN NS ",
|
57
|
-
Net::DNS::Question.new("google.com.", Net::DNS::NS).inspect
|
58
|
-
assert_equal "google.com. IN NS ",
|
59
|
-
Net::DNS::Question.new("google.com.", Net::DNS::NS).inspect
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_inspect_with_name_longer_than_29_chrs
|
63
|
-
assert_equal "supercalifragilistichespiralidoso.com IN A ",
|
64
|
-
Net::DNS::Question.new("supercalifragilistichespiralidoso.com").inspect
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_to_s
|
68
|
-
assert_equal "google.com. IN A ",
|
69
|
-
Net::DNS::Question.new("google.com.").to_s
|
70
|
-
assert_equal "google.com. IN A ",
|
71
|
-
Net::DNS::Question.new("google.com.", Net::DNS::A).to_s
|
72
|
-
assert_equal "google.com. IN NS ",
|
73
|
-
Net::DNS::Question.new("google.com.", Net::DNS::NS).to_s
|
74
|
-
assert_equal "google.com. IN NS ",
|
75
|
-
Net::DNS::Question.new("google.com.", Net::DNS::NS).to_s
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_to_s_with_name_longer_than_29_chrs
|
79
|
-
assert_equal "supercalifragilistichespiralidoso.com IN A ",
|
80
|
-
Net::DNS::Question.new("supercalifragilistichespiralidoso.com").to_s
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
data/test/resolver_test.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'net/dns/resolver'
|
3
|
-
|
4
|
-
class Net::DNS::Resolver
|
5
|
-
attr_reader :config
|
6
|
-
end
|
7
|
-
|
8
|
-
|
9
|
-
class ResolverTest < Test::Unit::TestCase
|
10
|
-
|
11
|
-
def test_initialize
|
12
|
-
assert_nothing_raised { Net::DNS::Resolver.new }
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_initialize_with_config
|
16
|
-
assert_nothing_raised { Net::DNS::Resolver.new({}) }
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_initialize_with_multi_name_servers
|
20
|
-
resolver = Net::DNS::Resolver.new({ :config_file => File.expand_path('../../spec/fixtures/resolv.conf', __FILE__) })
|
21
|
-
assert_equal ['192.168.1.1', '192.168.1.2', '192.168.1.3', '192.168.1.4'], resolver.nameservers
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_initialize_with_invalid_config_should_raise_argumenterror
|
25
|
-
assert_raises(ArgumentError) { Net::DNS::Resolver.new("") }
|
26
|
-
assert_raises(ArgumentError) { Net::DNS::Resolver.new(0) }
|
27
|
-
assert_raises(ArgumentError) { Net::DNS::Resolver.new(:foo) }
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_query_with_no_nameservers_should_raise_resolvererror
|
31
|
-
assert_raises(Net::DNS::Resolver::Error) { Net::DNS::Resolver.new(:nameservers => []).query("example.com") }
|
32
|
-
end
|
33
|
-
|
34
|
-
# def test_send_to_ipv6_nameserver_should_not_raise_einval
|
35
|
-
# assert_nothing_raised { Net::DNS::Resolver.new(:nameservers => ['2001:4860:4860::8888', '2001:4860:4860::8844']).send('example.com')}
|
36
|
-
# end
|
37
|
-
|
38
|
-
# I know private methods are supposed to not be tested directly
|
39
|
-
# but since this library lacks unit tests, for now let me test them in this way.
|
40
|
-
|
41
|
-
def _make_query_packet(*args)
|
42
|
-
Net::DNS::Resolver.new.send(:make_query_packet, *args)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_make_query_packet_from_ipaddr
|
46
|
-
packet = _make_query_packet(IPAddr.new("192.168.1.1"), Net::DNS::A, cls = Net::DNS::IN)
|
47
|
-
assert_equal "1.1.168.192.in-addr.arpa", packet.question.first.qName
|
48
|
-
assert_equal Net::DNS::PTR.to_i, packet.question.first.qType.to_i
|
49
|
-
assert_equal Net::DNS::IN.to_i, packet.question.first.qClass.to_i
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_make_query_packet_from_string_like_ipv4
|
53
|
-
packet = _make_query_packet("192.168.1.1", Net::DNS::A, cls = Net::DNS::IN)
|
54
|
-
assert_equal "1.1.168.192.in-addr.arpa", packet.question.first.qName
|
55
|
-
assert_equal Net::DNS::PTR.to_i, packet.question.first.qType.to_i
|
56
|
-
assert_equal Net::DNS::IN.to_i, packet.question.first.qClass.to_i
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_make_query_packet_from_string_like_ipv6
|
60
|
-
packet = _make_query_packet("2001:1ac0::200:0:a5d1:6004:2", Net::DNS::A, cls = Net::DNS::IN)
|
61
|
-
assert_equal "2.0.0.0.4.0.0.6.1.d.5.a.0.0.0.0.0.0.2.0.0.0.0.0.0.c.a.1.1.0.0.2.ip6.arpa", packet.question.first.qName
|
62
|
-
assert_equal Net::DNS::PTR.to_i, packet.question.first.qType.to_i
|
63
|
-
assert_equal Net::DNS::IN.to_i, packet.question.first.qClass.to_i
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_make_query_packet_from_string_like_hostname
|
67
|
-
packet = _make_query_packet("ns2.google.com", Net::DNS::A, cls = Net::DNS::IN)
|
68
|
-
assert_equal "ns2.google.com", packet.question.first.qName
|
69
|
-
assert_equal Net::DNS::A.to_i, packet.question.first.qType.to_i
|
70
|
-
assert_equal Net::DNS::IN.to_i, packet.question.first.qClass.to_i
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_make_query_packet_from_string_like_hostname_with_number
|
74
|
-
packet = _make_query_packet("ns.google.com", Net::DNS::A, cls = Net::DNS::IN)
|
75
|
-
assert_equal "ns.google.com", packet.question.first.qName
|
76
|
-
assert_equal Net::DNS::A.to_i, packet.question.first.qType.to_i
|
77
|
-
assert_equal Net::DNS::IN.to_i, packet.question.first.qClass.to_i
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_should_return_state_without_exception
|
81
|
-
res = Net::DNS::Resolver.new
|
82
|
-
assert_nothing_raised {res.state}
|
83
|
-
end
|
84
|
-
|
85
|
-
RubyPlatforms = [
|
86
|
-
["darwin9.0", false], # Mac OS X
|
87
|
-
["darwin", false], # JRuby on Mac OS X
|
88
|
-
["linux-gnu", false],
|
89
|
-
["mingw32", true], # ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mingw32]
|
90
|
-
["mswin32", true], # ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mswin32]
|
91
|
-
["mswin32", true], # ruby 1.8.6 (2008-04-22 rev 6555) [x86-jruby1.1.1]
|
92
|
-
]
|
93
|
-
|
94
|
-
C = Object.const_get(defined?(RbConfig) ? :RbConfig : :Config)::CONFIG
|
95
|
-
|
96
|
-
def test_self_platform_windows_question
|
97
|
-
RubyPlatforms.each do |platform, is_windows|
|
98
|
-
assert_equal is_windows,
|
99
|
-
override_platform(platform) { Net::DNS::Resolver.platform_windows? },
|
100
|
-
"Expected `#{is_windows}' with platform `#{platform}'"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
private
|
106
|
-
|
107
|
-
def override_platform(new_platform, &block)
|
108
|
-
raise LocalJumpError, "no block given" unless block_given?
|
109
|
-
old_platform = C["host_os"]
|
110
|
-
C["host_os"] = new_platform
|
111
|
-
result = yield
|
112
|
-
ensure
|
113
|
-
C["host_os"] = old_platform
|
114
|
-
result
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
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
|