pNet-DNS 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +68 -0
- data/lib/Net/DNS.rb +879 -0
- data/lib/Net/DNS/Header.rb +303 -0
- data/lib/Net/DNS/Nameserver.rb +601 -0
- data/lib/Net/DNS/Packet.rb +851 -0
- data/lib/Net/DNS/Question.rb +117 -0
- data/lib/Net/DNS/RR.rb +630 -0
- data/lib/Net/DNS/RR/A.rb +103 -0
- data/lib/Net/DNS/RR/AAAA.rb +147 -0
- data/lib/Net/DNS/RR/AFSDB.rb +114 -0
- data/lib/Net/DNS/RR/CERT.rb +191 -0
- data/lib/Net/DNS/RR/CNAME.rb +89 -0
- data/lib/Net/DNS/RR/DNAME.rb +84 -0
- data/lib/Net/DNS/RR/EID.rb +70 -0
- data/lib/Net/DNS/RR/HINFO.rb +108 -0
- data/lib/Net/DNS/RR/ISDN.rb +118 -0
- data/lib/Net/DNS/RR/LOC.rb +341 -0
- data/lib/Net/DNS/RR/MB.rb +92 -0
- data/lib/Net/DNS/RR/MG.rb +96 -0
- data/lib/Net/DNS/RR/MINFO.rb +109 -0
- data/lib/Net/DNS/RR/MR.rb +92 -0
- data/lib/Net/DNS/RR/MX.rb +124 -0
- data/lib/Net/DNS/RR/NAPTR.rb +182 -0
- data/lib/Net/DNS/RR/NIMLOC.rb +70 -0
- data/lib/Net/DNS/RR/NS.rb +100 -0
- data/lib/Net/DNS/RR/NSAP.rb +273 -0
- data/lib/Net/DNS/RR/NULL.rb +68 -0
- data/lib/Net/DNS/RR/OPT.rb +251 -0
- data/lib/Net/DNS/RR/PTR.rb +93 -0
- data/lib/Net/DNS/RR/PX.rb +131 -0
- data/lib/Net/DNS/RR/RP.rb +108 -0
- data/lib/Net/DNS/RR/RT.rb +115 -0
- data/lib/Net/DNS/RR/SOA.rb +195 -0
- data/lib/Net/DNS/RR/SPF.rb +46 -0
- data/lib/Net/DNS/RR/SRV.rb +153 -0
- data/lib/Net/DNS/RR/SSHFP.rb +190 -0
- data/lib/Net/DNS/RR/TKEY.rb +219 -0
- data/lib/Net/DNS/RR/TSIG.rb +358 -0
- data/lib/Net/DNS/RR/TXT.rb +162 -0
- data/lib/Net/DNS/RR/UNKNOWN.rb +76 -0
- data/lib/Net/DNS/RR/X25.rb +90 -0
- data/lib/Net/DNS/Resolver.rb +2090 -0
- data/lib/Net/DNS/Resolver/Recurse.rb +478 -0
- data/lib/Net/DNS/Update.rb +189 -0
- data/test/custom.txt +4 -0
- data/test/resolv.conf +4 -0
- data/test/tc_escapedchars.rb +498 -0
- data/test/tc_header.rb +91 -0
- data/test/tc_inet6.rb +169 -0
- data/test/tc_misc.rb +137 -0
- data/test/tc_online.rb +236 -0
- data/test/tc_packet.rb +174 -0
- data/test/tc_packet_unique_push.rb +126 -0
- data/test/tc_question.rb +49 -0
- data/test/tc_recurse.rb +69 -0
- data/test/tc_res_env.rb +59 -0
- data/test/tc_res_file.rb +55 -0
- data/test/tc_res_opt.rb +135 -0
- data/test/tc_resolver.rb +102 -0
- data/test/tc_rr-opt.rb +40 -0
- data/test/tc_rr-rrsort.rb +116 -0
- data/test/tc_rr-txt.rb +138 -0
- data/test/tc_rr-unknown.rb +95 -0
- data/test/tc_rr.rb +246 -0
- data/test/tc_tcp.rb +34 -0
- data/test/tc_tkey.rb +115 -0
- data/test/tc_update.rb +226 -0
- data/test/ts_netdns.rb +17 -0
- data/test/ts_offline.rb +32 -0
- data/test/ts_online.rb +33 -0
- metadata +119 -0
data/test/tc_tcp.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# The contents of this file are subject to the Mozilla
|
2
|
+
# Public Licence Version 1.1 (the "Licence"); you may
|
3
|
+
# not use this file except in compliance with the
|
4
|
+
# Licence. You may obtain a copy of the Licence at
|
5
|
+
# http://www.mozilla.org/MPL
|
6
|
+
# Software distributed under the Licence is distributed
|
7
|
+
# on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
8
|
+
# either express or implied. See the Licence of the
|
9
|
+
# specific language governing rights and limitations
|
10
|
+
# under the Licence.
|
11
|
+
# The Original Code is pNet::DNS.
|
12
|
+
# The Initial Developer of the Original Code is
|
13
|
+
# Nominet UK (www.nominet.org.uk). Portions created by
|
14
|
+
# Nominet UK are Copyright (c) Nominet UK 2006.
|
15
|
+
# All rights reserved.
|
16
|
+
require 'test/unit'
|
17
|
+
require 'Net/DNS'
|
18
|
+
class TestTcp < Test::Unit::TestCase
|
19
|
+
def test_TCP
|
20
|
+
res = Net::DNS::Resolver.new(:config_file=>"/etc/resolv.conf")
|
21
|
+
res.debug=true
|
22
|
+
res.usevc = true
|
23
|
+
ret=res.query("example.com")
|
24
|
+
assert(ret.is_a?(Net::DNS::Packet))
|
25
|
+
end
|
26
|
+
def test_TCP_port
|
27
|
+
res = Net::DNS::Resolver.new(:config_file=>"/etc/resolv.conf")
|
28
|
+
res.debug=true
|
29
|
+
res.usevc = true
|
30
|
+
res.srcport=rand(60000) + 1025
|
31
|
+
ret=res.query("example.com")
|
32
|
+
assert(ret.is_a?(Net::DNS::Packet))
|
33
|
+
end
|
34
|
+
end
|
data/test/tc_tkey.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
# The contents of this file are subject to the Mozilla
|
2
|
+
# Public Licence Version 1.1 (the "Licence"); you may
|
3
|
+
# not use this file except in compliance with the
|
4
|
+
# Licence. You may obtain a copy of the Licence at
|
5
|
+
# http://www.mozilla.org/MPL
|
6
|
+
# Software distributed under the Licence is distributed
|
7
|
+
# on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
8
|
+
# either express or implied. See the Licence of the
|
9
|
+
# specific language governing rights and limitations
|
10
|
+
# under the Licence.
|
11
|
+
# The Original Code is pNet::DNS.
|
12
|
+
# The Initial Developer of the Original Code is
|
13
|
+
# Nominet UK (www.nominet.org.uk). Portions created by
|
14
|
+
# Nominet UK are Copyright (c) Nominet UK 2006.
|
15
|
+
# All rights reserved.
|
16
|
+
require 'test/unit'
|
17
|
+
require 'Net/DNS'
|
18
|
+
require "digest/md5"
|
19
|
+
class TestTKey < Test::Unit::TestCase
|
20
|
+
def is_empty(string)
|
21
|
+
return (string == "; no data" || string == "; rdlength = 0")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_tkey
|
25
|
+
|
26
|
+
|
27
|
+
#------------------------------------------------------------------------------
|
28
|
+
# Canned data.
|
29
|
+
#------------------------------------------------------------------------------
|
30
|
+
|
31
|
+
zone = "example.com"
|
32
|
+
name = "123456789-test"
|
33
|
+
klass = "IN"
|
34
|
+
type = "TKEY"
|
35
|
+
algorithm = "fake.algorithm.example.com"
|
36
|
+
key = "fake key"
|
37
|
+
inception = 100000 # use a strange fixed inception time to give a fixed
|
38
|
+
# checksum
|
39
|
+
expiration = inception + 24*60*60
|
40
|
+
|
41
|
+
rr = nil
|
42
|
+
|
43
|
+
#------------------------------------------------------------------------------
|
44
|
+
# Packet creation.
|
45
|
+
#------------------------------------------------------------------------------
|
46
|
+
|
47
|
+
rr = Net::DNS::RR.create(
|
48
|
+
:name => name,
|
49
|
+
:type => "TKEY",
|
50
|
+
:ttl => 0,
|
51
|
+
:rrclass => "ANY",
|
52
|
+
:algorithm => algorithm,
|
53
|
+
:inception => inception,
|
54
|
+
:expiration => expiration,
|
55
|
+
:mode => 3, # GSSAPI
|
56
|
+
:key => "fake key",
|
57
|
+
:other_data => ""
|
58
|
+
)
|
59
|
+
|
60
|
+
packet = Net::DNS::Packet.new_from_values(name, "TKEY", "IN")
|
61
|
+
packet.push("answer", rr)
|
62
|
+
|
63
|
+
z = (packet.zone)[0]
|
64
|
+
|
65
|
+
assert(packet, 'new() returned packet') #2
|
66
|
+
assert_equal('QUERY', packet.header.opcode, 'header opcode correct') #3
|
67
|
+
assert_equal(name, z.zname, 'zname correct') #4
|
68
|
+
assert_equal("IN", z.zclass, 'zclass correct') #5
|
69
|
+
assert_equal('TKEY', z.ztype, 'ztype correct') #6
|
70
|
+
|
71
|
+
|
72
|
+
#------------------------------------------------------------------------------
|
73
|
+
# create a signed TKEY query packet using an external signing function
|
74
|
+
# and compare it to a known good result. This effectively tests the
|
75
|
+
# sign_func and sig_data methods of TSIG as well.
|
76
|
+
#------------------------------------------------------------------------------
|
77
|
+
|
78
|
+
|
79
|
+
tsig = Net::DNS::RR.create({
|
80
|
+
:name => name,
|
81
|
+
:type => "TSIG",
|
82
|
+
:ttl => 0,
|
83
|
+
:rrclass => "ANY",
|
84
|
+
:algorithm => algorithm,
|
85
|
+
:time_signed => inception + 1,
|
86
|
+
:fudge => 36000,
|
87
|
+
:mac_size => 0,
|
88
|
+
:mac => "",
|
89
|
+
:key => key,
|
90
|
+
:sign_func => Proc.new { |key,data|
|
91
|
+
# OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new("md5"), key, data)
|
92
|
+
hmac = Digest::MD5.new(key)
|
93
|
+
hmac.update(data)
|
94
|
+
return hmac.hexdigest
|
95
|
+
},
|
96
|
+
:other_len => 0,
|
97
|
+
:other_data => nil,
|
98
|
+
:error => 0
|
99
|
+
})
|
100
|
+
|
101
|
+
packet.push(:additional, tsig)
|
102
|
+
|
103
|
+
# use a fixed packet id so we get a known checksum
|
104
|
+
packet.header.id=(1234)
|
105
|
+
|
106
|
+
# create the packet - this will fill in the 'mac' field
|
107
|
+
raw_packet = packet.data
|
108
|
+
|
109
|
+
assert_equal(
|
110
|
+
"6365643161343964663364643264656131306638303633626465366236643465",
|
111
|
+
(packet.additional)[0].mac,
|
112
|
+
'MAC correct')
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
data/test/tc_update.rb
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
# The contents of this file are subject to the Mozilla
|
2
|
+
# Public Licence Version 1.1 (the "Licence"); you may
|
3
|
+
# not use this file except in compliance with the
|
4
|
+
# Licence. You may obtain a copy of the Licence at
|
5
|
+
# http://www.mozilla.org/MPL
|
6
|
+
# Software distributed under the Licence is distributed
|
7
|
+
# on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
8
|
+
# either express or implied. See the Licence of the
|
9
|
+
# specific language governing rights and limitations
|
10
|
+
# under the Licence.
|
11
|
+
# The Original Code is pNet::DNS.
|
12
|
+
# The Initial Developer of the Original Code is
|
13
|
+
# Nominet UK (www.nominet.org.uk). Portions created by
|
14
|
+
# Nominet UK are Copyright (c) Nominet UK 2006.
|
15
|
+
# All rights reserved.
|
16
|
+
require 'test/unit'
|
17
|
+
require 'Net/DNS'
|
18
|
+
class TestUpdate < Test::Unit::TestCase
|
19
|
+
def is_empty(string)
|
20
|
+
return true if string == nil || string.length == 0
|
21
|
+
|
22
|
+
return (string == "; no data" || string == "; rdlength = 0");
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_update
|
26
|
+
#------------------------------------------------------------------------------
|
27
|
+
# Canned data.
|
28
|
+
#------------------------------------------------------------------------------
|
29
|
+
|
30
|
+
zone = "example.com";
|
31
|
+
name = "foo.example.com";
|
32
|
+
klass = "HS";
|
33
|
+
klass2 = "CH";
|
34
|
+
type = "A";
|
35
|
+
ttl = 43200;
|
36
|
+
rdata = "10.1.2.3";
|
37
|
+
rr = nil;
|
38
|
+
|
39
|
+
#------------------------------------------------------------------------------
|
40
|
+
# Packet creation.
|
41
|
+
#------------------------------------------------------------------------------
|
42
|
+
|
43
|
+
packet = Net::DNS::Update.new_from_values(zone, klass);
|
44
|
+
z = (packet.zone)[0];
|
45
|
+
|
46
|
+
assert(packet, 'new() returned packet'); #2
|
47
|
+
assert_equal(packet.header.opcode, 'UPDATE', 'header opcode correct'); #3
|
48
|
+
assert_equal(z.zname, zone, 'zname correct'); #4
|
49
|
+
assert_equal(z.zclass, klass, 'zclass correct'); #5
|
50
|
+
assert_equal(z.ztype, 'SOA', 'ztype correct'); #6
|
51
|
+
|
52
|
+
#------------------------------------------------------------------------------
|
53
|
+
# RRset exists (value-independent).
|
54
|
+
#------------------------------------------------------------------------------
|
55
|
+
|
56
|
+
rr = Net::DNS.yxrrset("#{name} #{klass} #{type}");
|
57
|
+
|
58
|
+
assert(rr, 'yxrrset() returned RR'); #7
|
59
|
+
assert_equal(name, rr.name, 'yxrrset - right name'); #8
|
60
|
+
assert_equal(0, rr.ttl, 'yxrrset - right TTL'); #9
|
61
|
+
assert_equal('ANY', rr.rrclass, 'yxrrset - right class'); #10
|
62
|
+
assert_equal(type, rr.type, 'yxrrset - right type'); #11
|
63
|
+
assert(is_empty(rr.rdatastr), "yxrrset - data empty (#{rr.rdatastr})"); #12
|
64
|
+
|
65
|
+
rr = nil
|
66
|
+
|
67
|
+
#------------------------------------------------------------------------------
|
68
|
+
# RRset exists (value-dependent).
|
69
|
+
#------------------------------------------------------------------------------
|
70
|
+
|
71
|
+
rr = Net::DNS.yxrrset("#{name} #{klass} #{type} #{rdata}");
|
72
|
+
|
73
|
+
assert(rr, 'yxrrset() returned RR'); #13
|
74
|
+
assert_equal(name, rr.name, 'yxrrset - right name'); #14
|
75
|
+
assert_equal(0, rr.ttl, 'yxrrset - right TTL'); #15
|
76
|
+
assert_equal(klass, rr.rrclass, 'yxrrset - right class'); #16
|
77
|
+
assert_equal(type, rr.type, 'yxrrset - right type'); #17
|
78
|
+
assert_equal(rdata, rr.rdatastr, 'yxrrset - right data'); #18
|
79
|
+
|
80
|
+
rr=nil
|
81
|
+
|
82
|
+
#------------------------------------------------------------------------------
|
83
|
+
# RRset does not exist.
|
84
|
+
#------------------------------------------------------------------------------
|
85
|
+
|
86
|
+
rr = Net::DNS.nxrrset("#{name} #{klass} #{type}");
|
87
|
+
|
88
|
+
assert(rr, 'nxrrset() returned RR'); #19
|
89
|
+
assert_equal(name, rr.name, 'nxrrset - right name'); #20
|
90
|
+
assert_equal(0, rr.ttl, 'nxrrset - right ttl'); #21
|
91
|
+
assert_equal('NONE', rr.rrclass, 'nxrrset - right class'); #22
|
92
|
+
assert_equal(type, rr.type, 'nxrrset - right type'); #23
|
93
|
+
assert(is_empty(rr.rdatastr), 'nxrrset - data empty'); #24
|
94
|
+
|
95
|
+
rr = nil
|
96
|
+
|
97
|
+
#------------------------------------------------------------------------------
|
98
|
+
# Name is in use.
|
99
|
+
#------------------------------------------------------------------------------
|
100
|
+
|
101
|
+
rr = Net::DNS.yxdomain("#{name} #{klass}");
|
102
|
+
|
103
|
+
assert(rr, 'yxdomain() returned RR'); #25
|
104
|
+
assert_equal(rr.name, name, 'yxdomain - right name'); #26
|
105
|
+
assert_equal(rr.ttl, 0, 'yxdomain - right ttl'); #27
|
106
|
+
assert_equal(rr.rrclass, 'ANY', 'yxdomain - right class'); #28
|
107
|
+
assert_equal(rr.type, 'ANY', 'yxdomain - right type'); #29
|
108
|
+
assert(is_empty(rr.rdatastr), 'yxdomain - data empty'); #30
|
109
|
+
|
110
|
+
rr = nil
|
111
|
+
|
112
|
+
#------------------------------------------------------------------------------
|
113
|
+
# Name is not in use.
|
114
|
+
#------------------------------------------------------------------------------
|
115
|
+
|
116
|
+
rr = Net::DNS.nxdomain("#{name} #{klass}");
|
117
|
+
|
118
|
+
assert(rr, 'nxdomain() returned RR'); #31
|
119
|
+
assert_equal(rr.name, name, 'nxdomain - right name'); #32
|
120
|
+
assert_equal(rr.ttl, 0, 'nxdomain - right ttl'); #33
|
121
|
+
assert_equal(rr.rrclass, 'NONE', 'nxdomain - right class'); #34
|
122
|
+
assert_equal(rr.type, 'ANY', 'nxdomain - right type'); #35
|
123
|
+
assert(is_empty(rr.rdatastr), 'nxdomain - data empty'); #36
|
124
|
+
|
125
|
+
rr = nil
|
126
|
+
|
127
|
+
#------------------------------------------------------------------------------
|
128
|
+
# Name is not in use. (No Class)
|
129
|
+
#------------------------------------------------------------------------------
|
130
|
+
|
131
|
+
rr = Net::DNS.nxdomain("#{name}");
|
132
|
+
|
133
|
+
assert(rr, 'nxdomain() returned RR'); #31
|
134
|
+
assert_equal(rr.name, name, 'nxdomain - right name'); #32
|
135
|
+
assert_equal(rr.ttl, 0, 'nxdomain - right ttl'); #33
|
136
|
+
assert_equal(rr.rrclass, 'NONE', 'nxdomain - right class'); #34
|
137
|
+
assert_equal(rr.type, 'ANY', 'nxdomain - right type'); #35
|
138
|
+
assert(is_empty(rr.rdatastr), 'nxdomain - data empty'); #36
|
139
|
+
|
140
|
+
rr = nil
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
#------------------------------------------------------------------------------
|
145
|
+
# Add to an RRset.
|
146
|
+
#------------------------------------------------------------------------------
|
147
|
+
|
148
|
+
rr = Net::DNS.rr_add("#{name} #{ttl} #{klass} #{type} #{rdata}");
|
149
|
+
|
150
|
+
assert(rr, 'rr_add() returned RR'); #37
|
151
|
+
assert_equal(rr.name, name, 'rr_add - right name'); #38
|
152
|
+
assert_equal(rr.ttl, ttl, 'rr_add - right ttl'); #39
|
153
|
+
assert_equal(rr.rrclass, klass, 'rr_add - right class'); #40
|
154
|
+
assert_equal(rr.type, type, 'rr_add - right type'); #41
|
155
|
+
assert_equal(rr.rdatastr, rdata, 'rr_add - right data'); #42
|
156
|
+
|
157
|
+
rr = nil
|
158
|
+
|
159
|
+
#------------------------------------------------------------------------------
|
160
|
+
# Delete an RRset.
|
161
|
+
#------------------------------------------------------------------------------
|
162
|
+
|
163
|
+
rr = Net::DNS.rr_del("#{name} #{klass} #{type}");
|
164
|
+
|
165
|
+
assert(rr, 'rr_del() returned RR'); #43
|
166
|
+
assert_equal(name, rr.name, 'rr_del - right name'); #44
|
167
|
+
assert_equal(0, rr.ttl, 'rr_del - right ttl'); #45
|
168
|
+
assert_equal('ANY', rr.rrclass, 'rr_del - right class'); #46
|
169
|
+
assert_equal(type, rr.type, 'rr_del - right type'); #47
|
170
|
+
assert(is_empty(rr.rdatastr), 'rr_del - data empty'); #48
|
171
|
+
|
172
|
+
rr = nil
|
173
|
+
|
174
|
+
#------------------------------------------------------------------------------
|
175
|
+
# Delete All RRsets From A Name.
|
176
|
+
#------------------------------------------------------------------------------
|
177
|
+
|
178
|
+
rr = Net::DNS.rr_del("#{name} #{klass}");
|
179
|
+
|
180
|
+
assert(rr, 'rr_del() returned RR'); #49
|
181
|
+
assert_equal(name, rr.name, 'rr_del - right name'); #50
|
182
|
+
assert_equal(0, rr.ttl, 'rr_del - right ttl'); #51
|
183
|
+
assert_equal('ANY', rr.rrclass, 'rr_del - right class'); #52
|
184
|
+
assert_equal('ANY', rr.type, 'rr_del - right type'); #53
|
185
|
+
assert(is_empty(rr.rdatastr), 'rr_del - data empty'); #54
|
186
|
+
|
187
|
+
rr = nil
|
188
|
+
|
189
|
+
#------------------------------------------------------------------------------
|
190
|
+
# Delete An RR From An RRset.
|
191
|
+
#------------------------------------------------------------------------------
|
192
|
+
|
193
|
+
rr = Net::DNS.rr_del("#{name} #{klass} #{type} #{rdata}");
|
194
|
+
|
195
|
+
assert(rr, 'rr_del() returned RR'); #55
|
196
|
+
assert_equal(name, rr.name, 'rr_del - right name'); #56
|
197
|
+
assert_equal(0, rr.ttl, 'rr_del - right ttl'); #57
|
198
|
+
assert_equal('NONE', rr.rrclass, 'rr_del - right class'); #58
|
199
|
+
assert_equal(type, rr.type, 'rr_del - right type'); #59
|
200
|
+
assert_equal(rdata, rr.rdatastr, 'rr_del - right data'); #60
|
201
|
+
|
202
|
+
rr = nil
|
203
|
+
|
204
|
+
#------------------------------------------------------------------------------
|
205
|
+
# Make sure RRs in an update packet have the same class as the zone, unless
|
206
|
+
# the class is NONE or ANY.
|
207
|
+
#------------------------------------------------------------------------------
|
208
|
+
|
209
|
+
packet = Net::DNS::Update.new_from_values(zone, klass);
|
210
|
+
assert(packet, 'packet created'); #61
|
211
|
+
|
212
|
+
|
213
|
+
packet.push("pre", Net::DNS.yxrrset("#{name} #{klass} #{type} #{rdata}"));
|
214
|
+
packet.push("pre", Net::DNS.yxrrset("#{name} #{klass2} #{type} #{rdata}"));
|
215
|
+
packet.push("pre", Net::DNS.yxrrset("#{name} #{klass2} #{type}"));
|
216
|
+
packet.push("pre", Net::DNS.nxrrset("#{name} #{klass2} #{type}"));
|
217
|
+
|
218
|
+
pre = packet.pre;
|
219
|
+
|
220
|
+
assert_equal(4, pre.size, 'pushed inserted correctly'); #62
|
221
|
+
assert_equal(klass, pre[0].rrclass, 'first class right'); #63
|
222
|
+
assert_equal(klass, pre[1].rrclass, 'second class right'); #64
|
223
|
+
assert_equal('ANY', pre[2].rrclass, 'third class right'); #65
|
224
|
+
assert_equal('NONE', pre[3].rrclass, 'forth class right'); #66
|
225
|
+
end
|
226
|
+
end
|
data/test/ts_netdns.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# The contents of this file are subject to the Mozilla
|
2
|
+
# Public Licence Version 1.1 (the "Licence"); you may
|
3
|
+
# not use this file except in compliance with the
|
4
|
+
# Licence. You may obtain a copy of the Licence at
|
5
|
+
# http://www.mozilla.org/MPL
|
6
|
+
# Software distributed under the Licence is distributed
|
7
|
+
# on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
8
|
+
# either express or implied. See the Licence of the
|
9
|
+
# specific language governing rights and limitations
|
10
|
+
# under the Licence.
|
11
|
+
# The Original Code is pNet::DNS.
|
12
|
+
# The Initial Developer of the Original Code is
|
13
|
+
# Nominet UK (www.nominet.org.uk). Portions created by
|
14
|
+
# Nominet UK are Copyright (c) Nominet UK 2006.
|
15
|
+
# All rights reserved.
|
16
|
+
require "test/ts_online.rb"
|
17
|
+
require "test/ts_offline.rb"
|
data/test/ts_offline.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# The contents of this file are subject to the Mozilla
|
2
|
+
# Public Licence Version 1.1 (the "Licence"); you may
|
3
|
+
# not use this file except in compliance with the
|
4
|
+
# Licence. You may obtain a copy of the Licence at
|
5
|
+
# http://www.mozilla.org/MPL
|
6
|
+
# Software distributed under the Licence is distributed
|
7
|
+
# on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
8
|
+
# either express or implied. See the Licence of the
|
9
|
+
# specific language governing rights and limitations
|
10
|
+
# under the Licence.
|
11
|
+
# The Original Code is pNet::DNS.
|
12
|
+
# The Initial Developer of the Original Code is
|
13
|
+
# Nominet UK (www.nominet.org.uk). Portions created by
|
14
|
+
# Nominet UK are Copyright (c) Nominet UK 2006.
|
15
|
+
# All rights reserved.
|
16
|
+
require "test/unit"
|
17
|
+
require "test/tc_escapedchars.rb"
|
18
|
+
require "test/tc_header.rb"
|
19
|
+
require "test/tc_misc.rb"
|
20
|
+
require "test/tc_packet.rb"
|
21
|
+
require "test/tc_packet_unique_push.rb"
|
22
|
+
require "test/tc_question.rb"
|
23
|
+
require "test/tc_res_file.rb"
|
24
|
+
require "test/tc_res_opt.rb"
|
25
|
+
require "test/tc_rr-opt.rb"
|
26
|
+
require "test/tc_rr-rrsort.rb"
|
27
|
+
require "test/tc_rr-txt.rb"
|
28
|
+
require "test/tc_rr-unknown.rb"
|
29
|
+
require "test/tc_rr.rb"
|
30
|
+
require "test/tc_tkey.rb"
|
31
|
+
require "test/tc_update.rb"
|
32
|
+
require "test/tc_res_env.rb"
|
data/test/ts_online.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# The contents of this file are subject to the Mozilla
|
2
|
+
# Public Licence Version 1.1 (the "Licence"); you may
|
3
|
+
# not use this file except in compliance with the
|
4
|
+
# Licence. You may obtain a copy of the Licence at
|
5
|
+
# http://www.mozilla.org/MPL
|
6
|
+
# Software distributed under the Licence is distributed
|
7
|
+
# on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
8
|
+
# either express or implied. See the Licence of the
|
9
|
+
# specific language governing rights and limitations
|
10
|
+
# under the Licence.
|
11
|
+
# The Original Code is pNet::DNS.
|
12
|
+
# The Initial Developer of the Original Code is
|
13
|
+
# Nominet UK (www.nominet.org.uk). Portions created by
|
14
|
+
# Nominet UK are Copyright (c) Nominet UK 2006.
|
15
|
+
# All rights reserved.
|
16
|
+
require "test/unit"
|
17
|
+
# Disable these tests if we're not online
|
18
|
+
require 'socket'
|
19
|
+
sock = UDPSocket.new()
|
20
|
+
begin
|
21
|
+
sock.connect('193.0.14.129', # k.root-servers.net.
|
22
|
+
'25')
|
23
|
+
# OK - online and ready to go
|
24
|
+
require "test/tc_inet6.rb"
|
25
|
+
require "test/tc_online.rb"
|
26
|
+
require "test/tc_recurse.rb"
|
27
|
+
require "test/tc_resolver.rb"
|
28
|
+
require "test/tc_tcp.rb"
|
29
|
+
rescue Error
|
30
|
+
puts "Cannot bind to socket:\n\t"+$!+"\n"
|
31
|
+
puts "This is an indication you have network problems\n"
|
32
|
+
puts "\n\nNo online tests will be run!!\n\n"
|
33
|
+
end
|