dnsruby 1.55 → 1.56.0
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 +4 -4
- data/README.md +96 -0
- data/Rakefile +30 -29
- data/demo/axfr.rb +93 -93
- data/demo/check_soa.rb +99 -99
- data/demo/check_zone.rb +59 -59
- data/demo/digdlv.rb +43 -43
- data/demo/digroot.rb +34 -34
- data/demo/example_recurse.rb +14 -14
- data/demo/mresolv.rb +30 -30
- data/demo/mx.rb +31 -31
- data/demo/rubydig.rb +37 -37
- data/demo/to_resolve.txt +3088 -3088
- data/demo/trace_dns.rb +46 -46
- data/lib/dnsruby.rb +161 -526
- data/lib/dnsruby/DNS.rb +305 -0
- data/lib/{Dnsruby/Cache.rb → dnsruby/cache.rb} +152 -152
- data/lib/{Dnsruby → dnsruby}/code_mapper.rb +48 -52
- data/lib/dnsruby/code_mappers.rb +295 -0
- data/lib/{Dnsruby/Config.rb → dnsruby/config.rb} +454 -454
- data/lib/{Dnsruby → dnsruby}/dnssec.rb +91 -91
- data/lib/{Dnsruby/Hosts.rb → dnsruby/hosts.rb} +125 -125
- data/lib/{Dnsruby → dnsruby}/ipv4.rb +26 -26
- data/lib/{Dnsruby → dnsruby}/ipv6.rb +42 -42
- data/lib/{Dnsruby → dnsruby}/key_cache.rb +29 -29
- data/lib/dnsruby/message/decoder.rb +164 -0
- data/lib/dnsruby/message/encoder.rb +75 -0
- data/lib/dnsruby/message/header.rb +249 -0
- data/lib/dnsruby/message/message.rb +629 -0
- data/lib/dnsruby/message/question.rb +86 -0
- data/lib/dnsruby/message/section.rb +96 -0
- data/lib/{Dnsruby → dnsruby}/name.rb +141 -141
- data/lib/dnsruby/packet_sender.rb +661 -0
- data/lib/{Dnsruby/Recursor.rb → dnsruby/recursor.rb} +235 -233
- data/lib/dnsruby/resolv.rb +113 -0
- data/lib/dnsruby/resolver.rb +1192 -0
- data/lib/dnsruby/resource/A.rb +56 -0
- data/lib/dnsruby/resource/AAAA.rb +54 -0
- data/lib/{Dnsruby → dnsruby}/resource/AFSDB.rb +68 -68
- data/lib/{Dnsruby → dnsruby}/resource/CERT.rb +105 -105
- data/lib/{Dnsruby → dnsruby}/resource/DHCID.rb +54 -54
- data/lib/dnsruby/resource/DLV.rb +27 -0
- data/lib/{Dnsruby → dnsruby}/resource/DNSKEY.rb +372 -372
- data/lib/{Dnsruby → dnsruby}/resource/DS.rb +255 -255
- data/lib/{Dnsruby → dnsruby}/resource/HINFO.rb +71 -71
- data/lib/{Dnsruby → dnsruby}/resource/HIP.rb +29 -29
- data/lib/{Dnsruby → dnsruby}/resource/IN.rb +30 -30
- data/lib/{Dnsruby → dnsruby}/resource/IPSECKEY.rb +31 -31
- data/lib/{Dnsruby → dnsruby}/resource/ISDN.rb +62 -62
- data/lib/{Dnsruby → dnsruby}/resource/KX.rb +65 -65
- data/lib/{Dnsruby → dnsruby}/resource/LOC.rb +263 -263
- data/lib/{Dnsruby → dnsruby}/resource/MINFO.rb +69 -69
- data/lib/{Dnsruby → dnsruby}/resource/MX.rb +65 -65
- data/lib/{Dnsruby → dnsruby}/resource/NAPTR.rb +98 -98
- data/lib/{Dnsruby → dnsruby}/resource/NSAP.rb +171 -171
- data/lib/dnsruby/resource/NSEC.rb +275 -0
- data/lib/dnsruby/resource/NSEC3.rb +332 -0
- data/lib/dnsruby/resource/NSEC3PARAM.rb +135 -0
- data/lib/dnsruby/resource/OPT.rb +272 -0
- data/lib/{Dnsruby → dnsruby}/resource/PX.rb +70 -70
- data/lib/{Dnsruby → dnsruby}/resource/RP.rb +75 -75
- data/lib/dnsruby/resource/RR.rb +421 -0
- data/lib/dnsruby/resource/RRSIG.rb +275 -0
- data/lib/dnsruby/resource/RRSet.rb +190 -0
- data/lib/{Dnsruby → dnsruby}/resource/RT.rb +67 -67
- data/lib/{Dnsruby → dnsruby}/resource/SOA.rb +94 -94
- data/lib/dnsruby/resource/SPF.rb +29 -0
- data/lib/dnsruby/resource/SRV.rb +112 -0
- data/lib/{Dnsruby → dnsruby}/resource/SSHFP.rb +14 -14
- data/lib/dnsruby/resource/TKEY.rb +163 -0
- data/lib/dnsruby/resource/TSIG.rb +593 -0
- data/lib/{Dnsruby → dnsruby}/resource/TXT.rb +191 -191
- data/lib/dnsruby/resource/X25.rb +55 -0
- data/lib/{Dnsruby → dnsruby}/resource/domain_name.rb +25 -25
- data/lib/{Dnsruby → dnsruby}/resource/generic.rb +80 -80
- data/lib/dnsruby/resource/resource.rb +25 -0
- data/lib/{Dnsruby → dnsruby}/select_thread.rb +148 -148
- data/lib/{Dnsruby/SingleResolver.rb → dnsruby/single_resolver.rb} +60 -60
- data/lib/{Dnsruby → dnsruby}/single_verifier.rb +344 -344
- data/lib/dnsruby/the_log.rb +44 -0
- data/lib/dnsruby/update.rb +278 -0
- data/lib/dnsruby/validator_thread.rb +124 -0
- data/lib/dnsruby/version.rb +3 -0
- data/lib/{Dnsruby → dnsruby}/zone_reader.rb +93 -93
- data/lib/{Dnsruby → dnsruby}/zone_transfer.rb +377 -377
- data/test/spec_helper.rb +16 -0
- data/test/tc_axfr.rb +31 -34
- data/test/tc_cache.rb +32 -32
- data/test/tc_dlv.rb +28 -28
- data/test/tc_dns.rb +73 -76
- data/test/tc_dnskey.rb +31 -32
- data/test/tc_dnsruby.rb +50 -44
- data/test/tc_ds.rb +36 -36
- data/test/tc_escapedchars.rb +252 -255
- data/test/tc_hash.rb +17 -21
- data/test/tc_header.rb +48 -57
- data/test/tc_hip.rb +19 -22
- data/test/tc_ipseckey.rb +18 -21
- data/test/tc_keith.rb +300 -0
- data/test/tc_message.rb +87 -0
- data/test/tc_misc.rb +83 -87
- data/test/tc_name.rb +81 -84
- data/test/tc_naptr.rb +18 -21
- data/test/tc_nsec.rb +55 -55
- data/test/tc_nsec3.rb +23 -24
- data/test/tc_nsec3param.rb +20 -21
- data/test/tc_packet.rb +90 -93
- data/test/tc_packet_unique_push.rb +48 -51
- data/test/tc_question.rb +30 -33
- data/test/tc_queue.rb +16 -17
- data/test/tc_recur.rb +16 -17
- data/test/tc_res_config.rb +38 -41
- data/test/tc_res_env.rb +29 -32
- data/test/tc_res_file.rb +26 -29
- data/test/tc_res_opt.rb +62 -65
- data/test/tc_resolver.rb +287 -242
- data/test/tc_rr-opt.rb +70 -63
- data/test/tc_rr-txt.rb +68 -71
- data/test/tc_rr-unknown.rb +45 -48
- data/test/tc_rr.rb +76 -70
- data/test/tc_rrset.rb +21 -22
- data/test/tc_rrsig.rb +19 -20
- data/test/tc_single_resolver.rb +294 -297
- data/test/tc_soak.rb +199 -202
- data/test/tc_soak_base.rb +29 -34
- data/test/tc_sshfp.rb +20 -23
- data/test/tc_tcp.rb +32 -35
- data/test/tc_tkey.rb +41 -44
- data/test/tc_tsig.rb +81 -84
- data/test/tc_update.rb +108 -111
- data/test/tc_validator.rb +29 -29
- data/test/tc_verifier.rb +81 -82
- data/test/ts_dnsruby.rb +16 -15
- data/test/ts_offline.rb +62 -63
- data/test/ts_online.rb +115 -115
- metadata +155 -90
- data/README +0 -59
- data/lib/Dnsruby/DNS.rb +0 -305
- data/lib/Dnsruby/PacketSender.rb +0 -656
- data/lib/Dnsruby/Resolver.rb +0 -1189
- data/lib/Dnsruby/TheLog.rb +0 -44
- data/lib/Dnsruby/message.rb +0 -1230
- data/lib/Dnsruby/resource/A.rb +0 -56
- data/lib/Dnsruby/resource/AAAA.rb +0 -54
- data/lib/Dnsruby/resource/DLV.rb +0 -27
- data/lib/Dnsruby/resource/NSEC.rb +0 -298
- data/lib/Dnsruby/resource/NSEC3.rb +0 -340
- data/lib/Dnsruby/resource/NSEC3PARAM.rb +0 -135
- data/lib/Dnsruby/resource/OPT.rb +0 -213
- data/lib/Dnsruby/resource/RRSIG.rb +0 -275
- data/lib/Dnsruby/resource/SPF.rb +0 -29
- data/lib/Dnsruby/resource/SRV.rb +0 -112
- data/lib/Dnsruby/resource/TKEY.rb +0 -163
- data/lib/Dnsruby/resource/TSIG.rb +0 -593
- data/lib/Dnsruby/resource/X25.rb +0 -55
- data/lib/Dnsruby/resource/resource.rb +0 -678
- data/lib/Dnsruby/update.rb +0 -278
- data/lib/Dnsruby/validator_thread.rb +0 -124
data/test/spec_helper.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
if ENV['RUN_EXTRA_TASK'] == 'TRUE'
|
|
2
|
+
require 'coveralls'
|
|
3
|
+
Coveralls.wear!
|
|
4
|
+
|
|
5
|
+
require 'simplecov'
|
|
6
|
+
|
|
7
|
+
SimpleCov.formatter =
|
|
8
|
+
SimpleCov::Formatter::MultiFormatter[SimpleCov::Formatter::HTMLFormatter,
|
|
9
|
+
Coveralls::SimpleCov::Formatter]
|
|
10
|
+
SimpleCov.start do
|
|
11
|
+
add_filter 'test/'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
require 'minitest/autorun'
|
|
16
|
+
require 'dnsruby'
|
data/test/tc_axfr.rb
CHANGED
|
@@ -1,35 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
#Copyright 2007 Nominet UK
|
|
3
|
-
#
|
|
4
|
-
#Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
#you may not use this file except in compliance with the License.
|
|
6
|
-
#You may obtain a copy of the License at
|
|
7
|
-
#
|
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
#
|
|
10
|
-
#Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
#distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
#See the License for the specific language governing permissions and
|
|
14
|
-
#limitations under the License.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
zt.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# NB - test_ixfr is in tc_tsig.rg - this is becuase it requires
|
|
34
|
-
# TSIG to make an update (which we can then test for with ixfr)
|
|
1
|
+
# --
|
|
2
|
+
# Copyright 2007 Nominet UK
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
# ++
|
|
16
|
+
|
|
17
|
+
require_relative 'spec_helper'
|
|
18
|
+
|
|
19
|
+
class TestAxfr < Minitest::Test
|
|
20
|
+
def test_axfr
|
|
21
|
+
zt = Dnsruby::ZoneTransfer.new
|
|
22
|
+
zt.transfer_type = Dnsruby::Types.AXFR
|
|
23
|
+
zt.server = "ns0.validation-test-servers.nominet.org.uk"
|
|
24
|
+
zone = zt.transfer("validation-test-servers.nominet.org.uk")
|
|
25
|
+
assert(zone.length > 0)
|
|
26
|
+
assert(zt.last_tsigstate==nil)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# NB - test_ixfr is in tc_tsig.rg - this is becuase it requires
|
|
31
|
+
# TSIG to make an update (which we can then test for with ixfr)
|
|
35
32
|
end
|
data/test/tc_cache.rb
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
#Copyright 2007 Nominet UK
|
|
3
|
-
#
|
|
4
|
-
#Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
#you may not use this file except in compliance with the License.
|
|
6
|
-
#You may obtain a copy of the License at
|
|
7
|
-
#
|
|
1
|
+
# --
|
|
2
|
+
# Copyright 2007 Nominet UK
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
8
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
#
|
|
10
|
-
#Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
#distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
#See the License for the specific language governing permissions and
|
|
14
|
-
#limitations under the License.
|
|
15
|
-
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
# ++
|
|
16
|
+
|
|
17
|
+
require_relative 'spec_helper'
|
|
16
18
|
|
|
17
|
-
require 'test/unit'
|
|
18
|
-
require 'dnsruby'
|
|
19
19
|
include Dnsruby
|
|
20
20
|
|
|
21
|
-
class TestCache < Test
|
|
21
|
+
class TestCache < Minitest::Test
|
|
22
22
|
def test_cache
|
|
23
23
|
cache = Cache.new
|
|
24
24
|
m1 = Message.new("example.com.", Types.A, Classes.IN)
|
|
@@ -53,10 +53,10 @@ class TestCache < Test::Unit::TestCase
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def test_opt_record
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
56
|
+
# Create a very large message, encode it and decode it - there should be an opt record
|
|
57
|
+
# test getting that in and out the cache
|
|
58
|
+
# We should be able to do this in the online test by getting back a very big
|
|
59
|
+
# record from the test zone
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def test_negative
|
|
@@ -64,7 +64,7 @@ class TestCache < Test::Unit::TestCase
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
def test_resolver_do_caching
|
|
67
|
-
#
|
|
67
|
+
# Get the records back from the test zone
|
|
68
68
|
Dnsruby::PacketSender.clear_caches
|
|
69
69
|
res = Resolver.new("ns0.validation-test-servers.nominet.org.uk.")
|
|
70
70
|
res.do_caching = false
|
|
@@ -75,12 +75,12 @@ class TestCache < Test::Unit::TestCase
|
|
|
75
75
|
assert(!ret.cached)
|
|
76
76
|
assert(ret.rcode == RCode.NoError)
|
|
77
77
|
assert(ret.header.aa)
|
|
78
|
-
#
|
|
78
|
+
# Store the ttls
|
|
79
79
|
first_ttls = ret.answer.rrset(
|
|
80
80
|
"overflow.dnsruby.validation-test-servers.nominet.org.uk", Types.TXT).ttl
|
|
81
|
-
#
|
|
81
|
+
# Wait a while
|
|
82
82
|
sleep(1)
|
|
83
|
-
#
|
|
83
|
+
# Ask for the same records
|
|
84
84
|
ret = res.query("overflow.dnsruby.validation-test-servers.nominet.org.uk", Types.TXT)
|
|
85
85
|
# print "#{ret}\n"
|
|
86
86
|
assert(ret.rcode == RCode.NoError)
|
|
@@ -88,7 +88,7 @@ class TestCache < Test::Unit::TestCase
|
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
def test_online
|
|
91
|
-
#
|
|
91
|
+
# Get the records back from the test zone
|
|
92
92
|
Dnsruby::PacketSender.clear_caches
|
|
93
93
|
Dnsruby::Recursor.clear_caches
|
|
94
94
|
res = SingleResolver.new("ns0.validation-test-servers.nominet.org.uk.")
|
|
@@ -99,12 +99,12 @@ class TestCache < Test::Unit::TestCase
|
|
|
99
99
|
assert(!ret.cached)
|
|
100
100
|
assert(ret.rcode == RCode.NoError)
|
|
101
101
|
assert(ret.header.aa)
|
|
102
|
-
#
|
|
102
|
+
# Store the ttls
|
|
103
103
|
first_ttls = ret.answer.rrset(
|
|
104
104
|
"overflow.dnsruby.validation-test-servers.nominet.org.uk", Types.TXT).ttl
|
|
105
|
-
#
|
|
105
|
+
# Wait a while
|
|
106
106
|
sleep(1)
|
|
107
|
-
#
|
|
107
|
+
# Ask for the same records
|
|
108
108
|
query = Message.new("overflow.dnsruby.validation-test-servers.nominet.org.uk", Types.TXT)
|
|
109
109
|
ret = res.send_message(query)
|
|
110
110
|
# print "#{ret}\n"
|
|
@@ -112,16 +112,16 @@ class TestCache < Test::Unit::TestCase
|
|
|
112
112
|
assert(ret.cached)
|
|
113
113
|
second_ttls = ret.answer.rrset(
|
|
114
114
|
"overflow.dnsruby.validation-test-servers.nominet.org.uk", Types.TXT).ttl
|
|
115
|
-
#
|
|
115
|
+
# make sure the ttl is less the time we waited
|
|
116
116
|
assert((second_ttls == first_ttls - 1) || (second_ttls == first_ttls - 2),
|
|
117
117
|
"First ttl = #{first_ttls}, second = #{second_ttls}\n")
|
|
118
|
-
#
|
|
118
|
+
# make sure the header flags (and ID) are right
|
|
119
119
|
assert(ret.header.id == query.header.id, "First id = #{query.header.id}, cached response was #{ret.header.id}\n")
|
|
120
120
|
assert(!ret.header.aa)
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
def test_online_uncached
|
|
124
|
-
#
|
|
124
|
+
# @TODO@ Check that wildcard queries are not cached
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
end
|
data/test/tc_dlv.rb
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
#Copyright 2007 Nominet UK
|
|
3
|
-
#
|
|
4
|
-
#Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
#you may not use this file except in compliance with the License.
|
|
6
|
-
#You may obtain a copy of the License at
|
|
7
|
-
#
|
|
1
|
+
# --
|
|
2
|
+
# Copyright 2007 Nominet UK
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
8
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
#
|
|
10
|
-
#Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
#distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
#See the License for the specific language governing permissions and
|
|
14
|
-
#limitations under the License.
|
|
15
|
-
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
# ++
|
|
16
|
+
|
|
17
|
+
require_relative 'spec_helper'
|
|
16
18
|
|
|
17
|
-
require 'test/unit'
|
|
18
|
-
require 'dnsruby'
|
|
19
19
|
include Dnsruby
|
|
20
20
|
|
|
21
|
-
class TestDlv < Test
|
|
21
|
+
class TestDlv < Minitest::Test
|
|
22
22
|
def test_dlv
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
23
|
+
# Enable DLV (only) for validation.
|
|
24
|
+
# Try to validate some records which can only be done through dlv
|
|
25
|
+
# OK - if we don't configure trust anchors, and there is no signed root, then this is easy!
|
|
26
26
|
Dnsruby::Dnssec.clear_trusted_keys
|
|
27
27
|
Dnsruby::Dnssec.clear_trust_anchors
|
|
28
28
|
Dnsruby::PacketSender.clear_caches
|
|
29
29
|
# Dnssec.do_validation_with_recursor(true)
|
|
30
|
-
#
|
|
31
|
-
#
|
|
30
|
+
# @TODO@ Should use whole RRSet of authoritative NS for these resolvers,
|
|
31
|
+
# not individual servers!
|
|
32
32
|
res = Dnsruby::Resolver.new("a.ns.se")
|
|
33
33
|
res.add_server("b.ns.se")
|
|
34
34
|
res.dnssec=true
|
|
@@ -43,31 +43,31 @@ class TestDlv < Test::Unit::TestCase
|
|
|
43
43
|
ret = res.query("ns2.nic.se", Dnsruby::Types.A)
|
|
44
44
|
assert(ret.security_level == Dnsruby::Message::SecurityLevel::UNCHECKED)
|
|
45
45
|
|
|
46
|
-
#
|
|
46
|
+
# Load DLV key
|
|
47
47
|
dlv_key = RR.create("dlv.isc.org. IN DNSKEY 257 3 5 BEAAAAPHMu/5onzrEE7z1egmhg/WPO0+juoZrW3euWEn4MxDCE1+lLy2 brhQv5rN32RKtMzX6Mj70jdzeND4XknW58dnJNPCxn8+jAGl2FZLK8t+ 1uq4W+nnA3qO2+DL+k6BD4mewMLbIYFwe0PG73Te9fZ2kJb56dhgMde5 ymX4BI/oQ+cAK50/xvJv00Frf8kw6ucMTwFlgPe+jnGxPPEmHAte/URk Y62ZfkLoBAADLHQ9IrS2tryAe7mbBZVcOwIeU/Rw/mRx/vwwMCTgNboM QKtUdvNXDrYJDSHZws3xiRXF1Rf+al9UmZfSav/4NWLKjHzpT59k/VSt TDN0YUuWrBNh")
|
|
48
48
|
Dnssec.add_dlv_key(dlv_key)
|
|
49
49
|
Dnsruby::PacketSender.clear_caches
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
#
|
|
52
|
+
# SE no longer in DLV
|
|
53
53
|
# res = Dnsruby::Recursor.new()
|
|
54
54
|
# ret = res.query("ns2.nic.se", Dnsruby::Types.A)
|
|
55
55
|
# assert(ret.security_level == Dnsruby::Message::SecurityLevel::SECURE)
|
|
56
56
|
|
|
57
|
-
#
|
|
57
|
+
# .cz no longer in dlv?
|
|
58
58
|
# ret = res.query("b.ns.nic.cz", Dnsruby::Types.A)
|
|
59
59
|
# assert(ret.security_level == Dnsruby::Message::SecurityLevel::SECURE)
|
|
60
60
|
|
|
61
|
-
#
|
|
61
|
+
# Test .gov
|
|
62
62
|
# Dnsruby::TheLog.level = Logger::DEBUG
|
|
63
63
|
res = Resolver.new
|
|
64
64
|
ret = res.query("nih.gov", "NS")
|
|
65
65
|
assert(ret.security_level = Dnsruby::Message::SecurityLevel::SECURE)
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
#
|
|
68
|
+
# se no longer in dlv
|
|
69
69
|
# def test_scrub_non_authoritative
|
|
70
|
-
|
|
70
|
+
# # Dnssec.do_validation_with_recursor(true)
|
|
71
71
|
# res = Dnsruby::Recursor.new()
|
|
72
72
|
# ret = res.query("frobbit.se")
|
|
73
73
|
# res.prune_rrsets_to_rfc5452(ret, "frobbit.se.")
|
data/test/tc_dns.rb
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
#Copyright 2007 Nominet UK
|
|
3
|
-
#
|
|
4
|
-
#Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
#you may not use this file except in compliance with the License.
|
|
6
|
-
#You may obtain a copy of the License at
|
|
7
|
-
#
|
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
#
|
|
10
|
-
#Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
#distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
#See the License for the specific language governing permissions and
|
|
14
|
-
#limitations under the License.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
require 'test/unit'
|
|
21
|
-
require 'dnsruby'
|
|
1
|
+
# --
|
|
2
|
+
# Copyright 2007 Nominet UK
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
# ++
|
|
16
|
+
|
|
17
|
+
require_relative 'spec_helper'
|
|
18
|
+
|
|
22
19
|
include Dnsruby
|
|
23
|
-
class TestDNS < Test
|
|
20
|
+
class TestDNS < Minitest::Test
|
|
24
21
|
def setup
|
|
25
22
|
Dnsruby::Config.reset
|
|
26
23
|
end
|
|
27
|
-
|
|
24
|
+
|
|
28
25
|
def test_ipv4_address
|
|
29
26
|
Dnsruby::DNS.open { |dns| dns.getnames(Dnsruby::IPv4.create("221.186.184.68")) }
|
|
30
27
|
end
|
|
31
|
-
|
|
28
|
+
|
|
32
29
|
def test_resolv_rb_api
|
|
33
30
|
DNS.open {|dns|
|
|
34
31
|
dns.getresources("www.ruby-lang.org", Types.A).each {|r| assert_equal(r.address.to_s, "221.186.184.68")}
|
|
@@ -59,7 +56,7 @@ class TestDNS < Test::Unit::TestCase
|
|
|
59
56
|
assert_equal(r[0].exchange.to_s, "carbon.ruby-lang.org")
|
|
60
57
|
assert_equal(r[0].klass, Classes.IN)
|
|
61
58
|
assert_equal(r[0].type, Types.MX)
|
|
62
|
-
r = d.each_resource("www.ruby-lang.org", Types.ANY) {|r|
|
|
59
|
+
r = d.each_resource("www.ruby-lang.org", Types.ANY) {|r|
|
|
63
60
|
assert_equal(r.name.to_s, "www.ruby-lang.org")
|
|
64
61
|
assert_equal(r.domainname.to_s, "carbon.ruby-lang.org")
|
|
65
62
|
assert_equal(r.klass, Classes.IN)
|
|
@@ -67,20 +64,20 @@ class TestDNS < Test::Unit::TestCase
|
|
|
67
64
|
}
|
|
68
65
|
d.close
|
|
69
66
|
end
|
|
70
|
-
|
|
67
|
+
|
|
71
68
|
def test_async_api
|
|
72
|
-
|
|
73
|
-
#Or would users be better off with Resolver async API?
|
|
69
|
+
# @TODO@ Do we really want an async API for Resolv/DNS?
|
|
70
|
+
# Or would users be better off with Resolver async API?
|
|
74
71
|
end
|
|
75
|
-
|
|
72
|
+
|
|
76
73
|
def test_concurrent
|
|
77
|
-
|
|
74
|
+
# @TODO@ What kind of concurrent testing are we going to do on the top-level API?
|
|
78
75
|
end
|
|
79
|
-
|
|
76
|
+
|
|
80
77
|
def test_bad_input
|
|
81
|
-
#
|
|
82
|
-
#
|
|
83
|
-
#
|
|
78
|
+
#
|
|
79
|
+
# Check that new() is vetting things properly.
|
|
80
|
+
#
|
|
84
81
|
Dnsruby.log.level=Logger::FATAL
|
|
85
82
|
[:nameserver].each do |test|
|
|
86
83
|
# [{}, 'kjghdfkjhase',1,'\1',nil].each do |input|
|
|
@@ -96,7 +93,7 @@ class TestDNS < Test::Unit::TestCase
|
|
|
96
93
|
end
|
|
97
94
|
end
|
|
98
95
|
end
|
|
99
|
-
|
|
96
|
+
|
|
100
97
|
def test_online
|
|
101
98
|
res = DNS.new
|
|
102
99
|
rrs = [
|
|
@@ -120,47 +117,47 @@ class TestDNS < Test::Unit::TestCase
|
|
|
120
117
|
:type => Types.TXT,
|
|
121
118
|
:name => 'txt.t.dnsruby.validation-test-servers.nominet.org.uk',
|
|
122
119
|
:strings => ['Net-DNS']
|
|
123
|
-
}
|
|
124
|
-
]
|
|
125
|
-
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
|
|
126
123
|
rrs.each do |data|
|
|
127
124
|
answer = res.getresource(data[:name], data[:type])
|
|
128
125
|
assert(answer)
|
|
129
126
|
assert_equal(answer.klass, 'IN', 'Class correct' )
|
|
130
|
-
|
|
127
|
+
|
|
131
128
|
packet, queried_name = res.send_query(data[:name], data[:type])
|
|
132
|
-
|
|
129
|
+
|
|
133
130
|
assert(packet, "Got an answer for #{data[:name]} IN #{data[:type]}")
|
|
134
131
|
assert_equal(1, packet.header.qdcount, 'Only one question')
|
|
135
132
|
assert_equal(1, packet.header.ancount, 'Got single answer')
|
|
136
|
-
|
|
133
|
+
|
|
137
134
|
question = (packet.question)[0]
|
|
138
135
|
answer = (packet.answer)[0]
|
|
139
|
-
|
|
136
|
+
|
|
140
137
|
assert(question, 'Got question' )
|
|
141
138
|
assert_equal(data[:name], question.qname.to_s, 'Question has right name' )
|
|
142
139
|
assert_equal(data[:name], queried_name.to_s, 'queried_name has right name' )
|
|
143
140
|
assert_equal(Types.new(data[:type]), question.qtype, 'Question has right type' )
|
|
144
141
|
assert_equal('IN', question.qclass.string, 'Question has right class')
|
|
145
|
-
|
|
142
|
+
|
|
146
143
|
assert(answer)
|
|
147
144
|
assert_equal(answer.klass, 'IN', 'Class correct' )
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
data.keys.each do |meth|
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
data.keys.each do |meth|
|
|
151
148
|
if (meth == :type)
|
|
152
|
-
assert_equal(Types.new(data[meth]).to_s, answer.send(meth).to_s, "#{meth} correct (#{data[:name]})")
|
|
153
|
-
else
|
|
154
|
-
assert_equal(data[meth].to_s, answer.send(meth).to_s, "#{meth} correct (#{data[:name]})")
|
|
149
|
+
assert_equal(Types.new(data[meth]).to_s, answer.send(meth).to_s, "#{meth} correct (#{data[:name]})")
|
|
150
|
+
else
|
|
151
|
+
assert_equal(data[meth].to_s, answer.send(meth).to_s, "#{meth} correct (#{data[:name]})")
|
|
155
152
|
end
|
|
156
153
|
end
|
|
157
154
|
end # do
|
|
158
155
|
end # test_online
|
|
159
|
-
|
|
160
|
-
def test_search_query_reverse
|
|
161
|
-
#
|
|
162
|
-
#
|
|
163
|
-
#
|
|
156
|
+
|
|
157
|
+
def test_search_query_reverse
|
|
158
|
+
#
|
|
159
|
+
# test that getname() DTRT with reverse lookups
|
|
160
|
+
#
|
|
164
161
|
tests = [
|
|
165
162
|
{
|
|
166
163
|
:ip => '198.41.0.4',
|
|
@@ -171,31 +168,31 @@ class TestDNS < Test::Unit::TestCase
|
|
|
171
168
|
:host => 'h.root-servers.net',
|
|
172
169
|
},
|
|
173
170
|
]
|
|
174
|
-
|
|
171
|
+
|
|
175
172
|
res = DNS.new
|
|
176
|
-
tests.each do |test|
|
|
173
|
+
tests.each do |test|
|
|
177
174
|
name = res.getname(test[:ip])
|
|
178
|
-
|
|
175
|
+
|
|
179
176
|
assert_instance_of(Name,name)
|
|
180
|
-
|
|
177
|
+
|
|
181
178
|
next unless name
|
|
182
|
-
|
|
179
|
+
|
|
183
180
|
assert_equal(name.to_s, test[:host], "getname(#{test[:ip]}) works")
|
|
184
181
|
end # do
|
|
185
182
|
end # test
|
|
186
|
-
|
|
183
|
+
|
|
187
184
|
def test_searchlist
|
|
188
185
|
res = DNS.new(
|
|
189
186
|
:domain => 't.dnsruby.validation-test-servers.nominet.org.uk',
|
|
190
187
|
:search => ["t.dnsruby.validation-test-servers.nominet.org.uk", "dnsruby.validation-test-servers.nominet.org.uk"]
|
|
191
188
|
)
|
|
192
|
-
|
|
193
|
-
#
|
|
194
|
-
#
|
|
195
|
-
#
|
|
196
|
-
#
|
|
197
|
-
|
|
198
|
-
|
|
189
|
+
|
|
190
|
+
#
|
|
191
|
+
# test the send_query() appends the default domain and
|
|
192
|
+
# searchlist correctly.
|
|
193
|
+
#
|
|
194
|
+
# @TODO@ Should really be done in Config test!
|
|
195
|
+
|
|
199
196
|
tests = [
|
|
200
197
|
{
|
|
201
198
|
:method => 'search',
|
|
@@ -210,30 +207,30 @@ class TestDNS < Test::Unit::TestCase
|
|
|
210
207
|
:name => 'a'
|
|
211
208
|
}
|
|
212
209
|
]
|
|
213
|
-
|
|
210
|
+
|
|
214
211
|
res.send_query("a.t.dnsruby.validation-test-servers.nominet.org.uk", "A")
|
|
215
212
|
res.config.ndots=2
|
|
216
|
-
|
|
213
|
+
|
|
217
214
|
tests.each do |test|
|
|
218
215
|
method = test[:method]
|
|
219
|
-
|
|
216
|
+
|
|
220
217
|
if (method=="query")
|
|
221
218
|
res.config.apply_search_list=false
|
|
222
219
|
else
|
|
223
220
|
res.config.apply_search_list=true
|
|
224
221
|
end
|
|
225
|
-
|
|
222
|
+
|
|
226
223
|
ans, query = res.send_query(test[:name])
|
|
227
|
-
|
|
224
|
+
|
|
228
225
|
assert_instance_of(Message, ans)
|
|
229
|
-
|
|
226
|
+
|
|
230
227
|
assert_equal(1, ans.header.ancount, "Correct answer count (with persistent socket and #{method})")
|
|
231
|
-
|
|
228
|
+
|
|
232
229
|
a = ans.answer
|
|
233
|
-
|
|
230
|
+
|
|
234
231
|
assert_instance_of(RR::IN::A, a[0])
|
|
235
232
|
assert_equal(a[0].name.to_s, 'a.t.dnsruby.validation-test-servers.nominet.org.uk',"Correct name (with persistent socket and #{method})")
|
|
236
233
|
end
|
|
237
|
-
|
|
234
|
+
|
|
238
235
|
end
|
|
239
236
|
end
|