pNet-DNS 0.0.1

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.
Files changed (71) hide show
  1. data/README +68 -0
  2. data/lib/Net/DNS.rb +879 -0
  3. data/lib/Net/DNS/Header.rb +303 -0
  4. data/lib/Net/DNS/Nameserver.rb +601 -0
  5. data/lib/Net/DNS/Packet.rb +851 -0
  6. data/lib/Net/DNS/Question.rb +117 -0
  7. data/lib/Net/DNS/RR.rb +630 -0
  8. data/lib/Net/DNS/RR/A.rb +103 -0
  9. data/lib/Net/DNS/RR/AAAA.rb +147 -0
  10. data/lib/Net/DNS/RR/AFSDB.rb +114 -0
  11. data/lib/Net/DNS/RR/CERT.rb +191 -0
  12. data/lib/Net/DNS/RR/CNAME.rb +89 -0
  13. data/lib/Net/DNS/RR/DNAME.rb +84 -0
  14. data/lib/Net/DNS/RR/EID.rb +70 -0
  15. data/lib/Net/DNS/RR/HINFO.rb +108 -0
  16. data/lib/Net/DNS/RR/ISDN.rb +118 -0
  17. data/lib/Net/DNS/RR/LOC.rb +341 -0
  18. data/lib/Net/DNS/RR/MB.rb +92 -0
  19. data/lib/Net/DNS/RR/MG.rb +96 -0
  20. data/lib/Net/DNS/RR/MINFO.rb +109 -0
  21. data/lib/Net/DNS/RR/MR.rb +92 -0
  22. data/lib/Net/DNS/RR/MX.rb +124 -0
  23. data/lib/Net/DNS/RR/NAPTR.rb +182 -0
  24. data/lib/Net/DNS/RR/NIMLOC.rb +70 -0
  25. data/lib/Net/DNS/RR/NS.rb +100 -0
  26. data/lib/Net/DNS/RR/NSAP.rb +273 -0
  27. data/lib/Net/DNS/RR/NULL.rb +68 -0
  28. data/lib/Net/DNS/RR/OPT.rb +251 -0
  29. data/lib/Net/DNS/RR/PTR.rb +93 -0
  30. data/lib/Net/DNS/RR/PX.rb +131 -0
  31. data/lib/Net/DNS/RR/RP.rb +108 -0
  32. data/lib/Net/DNS/RR/RT.rb +115 -0
  33. data/lib/Net/DNS/RR/SOA.rb +195 -0
  34. data/lib/Net/DNS/RR/SPF.rb +46 -0
  35. data/lib/Net/DNS/RR/SRV.rb +153 -0
  36. data/lib/Net/DNS/RR/SSHFP.rb +190 -0
  37. data/lib/Net/DNS/RR/TKEY.rb +219 -0
  38. data/lib/Net/DNS/RR/TSIG.rb +358 -0
  39. data/lib/Net/DNS/RR/TXT.rb +162 -0
  40. data/lib/Net/DNS/RR/UNKNOWN.rb +76 -0
  41. data/lib/Net/DNS/RR/X25.rb +90 -0
  42. data/lib/Net/DNS/Resolver.rb +2090 -0
  43. data/lib/Net/DNS/Resolver/Recurse.rb +478 -0
  44. data/lib/Net/DNS/Update.rb +189 -0
  45. data/test/custom.txt +4 -0
  46. data/test/resolv.conf +4 -0
  47. data/test/tc_escapedchars.rb +498 -0
  48. data/test/tc_header.rb +91 -0
  49. data/test/tc_inet6.rb +169 -0
  50. data/test/tc_misc.rb +137 -0
  51. data/test/tc_online.rb +236 -0
  52. data/test/tc_packet.rb +174 -0
  53. data/test/tc_packet_unique_push.rb +126 -0
  54. data/test/tc_question.rb +49 -0
  55. data/test/tc_recurse.rb +69 -0
  56. data/test/tc_res_env.rb +59 -0
  57. data/test/tc_res_file.rb +55 -0
  58. data/test/tc_res_opt.rb +135 -0
  59. data/test/tc_resolver.rb +102 -0
  60. data/test/tc_rr-opt.rb +40 -0
  61. data/test/tc_rr-rrsort.rb +116 -0
  62. data/test/tc_rr-txt.rb +138 -0
  63. data/test/tc_rr-unknown.rb +95 -0
  64. data/test/tc_rr.rb +246 -0
  65. data/test/tc_tcp.rb +34 -0
  66. data/test/tc_tkey.rb +115 -0
  67. data/test/tc_update.rb +226 -0
  68. data/test/ts_netdns.rb +17 -0
  69. data/test/ts_offline.rb +32 -0
  70. data/test/ts_online.rb +33 -0
  71. metadata +119 -0
@@ -0,0 +1,55 @@
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 TestAResolverFile < Test::Unit::TestCase
19
+ def test_resFile
20
+ #~ BEGIN {
21
+ #~ chdir 't/' || die "Couldn't chdir to t/\n"
22
+ #~ unshift(@INC, '../blib/lib', '../blib/arch')
23
+ #~ use_ok('Net::DNS')
24
+ #~ }
25
+
26
+ #~ SKIP: {
27
+
28
+ #~ skip 'File parsing only supported on unix.', 7
29
+ #~ unless $Net::DNS::Resolver::ISA[0] eq 'Net::DNS::Resolver::UNIX'
30
+
31
+ #~ skip 'Could not read configuration file', 7
32
+ #~ unless -r '.resolv.conf' && -o _
33
+
34
+ res = Net::DNS::Resolver.new(:config_file => "test/resolv.conf")
35
+
36
+ assert(res, "new() returned something")
37
+ assert(res.nameservers, "nameservers() works")
38
+
39
+ servers = res.nameservers
40
+
41
+ assert_equal(servers[0], '10.0.1.128', 'Nameserver set correctly')
42
+ assert_equal(servers[1], '10.0.2.128', 'Nameserver set correctly')
43
+
44
+
45
+ search = res.searchlist
46
+ assert_equal(search[0], 'net-dns.org', 'Search set correctly' )
47
+ assert_equal(search[1], 'lib.net-dns.org', 'Search set correctly' )
48
+
49
+ assert_equal(res.domain, 't.net-dns.org', 'Local domain works' )
50
+ #~ }
51
+
52
+
53
+
54
+ end
55
+ end
@@ -0,0 +1,135 @@
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 TestResOpt < Test::Unit::TestCase
19
+ def test_res_opt
20
+
21
+ # .txt because this test will run under windows, unlike the other file
22
+ # configuration tests.
23
+ #test_file = File::Spec.catfile('t', 'custom.txt')
24
+
25
+ #res = Net::DNS::Resolver.new(:config_file => :test_file)
26
+ res = Net::DNS::Resolver.new(:config_file => 'test/custom.txt')
27
+
28
+ assert(res, 'new() returned something')
29
+ assert_instance_of(Net::DNS::Resolver, res, 'new() returns an object of the correct class.')
30
+ assert(res.nameservers, 'nameservers() works')
31
+
32
+ servers = res.nameservers
33
+
34
+ assert_equal(servers[0], '10.0.1.42', 'Nameserver set correctly')
35
+ assert_equal(servers[1], '10.0.2.42', 'Nameserver set correctly')
36
+
37
+
38
+ search = res.searchlist
39
+ assert_equal(search[0], 'alt.net-dns.org', 'Search set correctly' )
40
+ assert_equal(search[1], 'ext.net-dns.org', 'Search set correctly' )
41
+
42
+ assert_equal(res.domain, 't2.net-dns.org', 'Local domain works' )
43
+ end
44
+
45
+ def test_no_file
46
+ res=nil
47
+ begin
48
+ res = Net::DNS::Resolver.new(:config_file => 'nosuch.txt')
49
+ assert(false, "Should throw error trying to open non-existant file.")
50
+ rescue Exception
51
+ #assert($@, 'Error thrown trying to open non-existant file.')
52
+ assert(res==nil, 'Net::DNS::Resolver->new returned undef')
53
+ end
54
+ end
55
+
56
+ def test_config
57
+ #
58
+ # Check that we can set things in new()
59
+ #
60
+ res=nil
61
+
62
+ test_config = {
63
+ :nameservers => ['10.0.0.1', '10.0.0.2'],
64
+ :port => 54,
65
+ :srcaddr => '10.1.0.1',
66
+ :srcport => 53,
67
+ :domain => 'net-dns.org',
68
+ :searchlist => ['net-dns.org', 't.net-dns.org'],
69
+ :retrans => 6,
70
+ :retry => 5,
71
+ :usevc => 1,
72
+ :stayopen => 1,
73
+ :igntc => 1,
74
+ :recurse => 0,
75
+ :defnames => 0,
76
+ :dnsrch => 0,
77
+ :debug => 1,
78
+ :tcp_timeout => 60,
79
+ :udp_timeout => 60,
80
+ :persistent_tcp => 1,
81
+ #@todo Add dnssec when dnssec added to Net::DNS
82
+ # 'dnssec' => 1,
83
+ }
84
+
85
+ res = Net::DNS::Resolver.new(test_config)
86
+
87
+
88
+ test_config.keys.each do |item|
89
+ assert_equal(res.send_method(item), test_config[item], "#{item} is correct")
90
+ end
91
+ end
92
+
93
+ def test_bad_input
94
+ #
95
+ # Check that new() is vetting things properly.
96
+ #
97
+
98
+ [:nameservers, :searchlist].each do |test|
99
+ [{}, 'string',1,'\1',nil].each do |input|
100
+ res=nil
101
+ begin
102
+ res = Net::DNS::Resolver.new({test => input})
103
+ assert(false, "Accepted invalid input")
104
+ rescue
105
+ assert(res==nil, 'No resolver should be returned for #{test} = #{input}')
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+
112
+ def test_bad_config
113
+ res=nil
114
+
115
+ bad_input = {
116
+ :tsig_rr => 'set',
117
+ :errorstring => 'set',
118
+ :answerfrom => 'set',
119
+ :answersize => 'set',
120
+ :querytime => 'set',
121
+ :axfr_sel => 'set',
122
+ :axfr_rr => 'set',
123
+ :axfr_soa_count => 'set',
124
+ :udppacketsize => 'set',
125
+ :cdflag => 'set',
126
+ }
127
+
128
+ res = Net::DNS::Resolver.new(bad_input)
129
+
130
+ bad_input.keys.each do |key|
131
+ assert_not_equal(res.send_method(key), 'set', "#{key} is not set")
132
+ end
133
+
134
+ end
135
+ end
@@ -0,0 +1,102 @@
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 TestResolver < Test::Unit::TestCase
19
+ def test_resolver
20
+ res = Net::DNS::Resolver.new();
21
+ assert(res, "new returned something");
22
+ assert_instance_of(Net::DNS::Resolver, res, "new() returns an object of the correct class.");
23
+
24
+ assert(res.nameservers, 'nameservers() works');
25
+
26
+ searchlist = ["t.net-dns.org", "t2.net-dns.org"];
27
+ assert_equal(res.searchlist=searchlist, searchlist, 'setting searchlist returns correctly.');
28
+ assert_equal(res.searchlist, searchlist, 'setting searchlist stickts.');
29
+
30
+
31
+ good_input = {
32
+ "port" => 54,
33
+ "srcaddr" => '10.1.0.1',
34
+ "srcport" => 53,
35
+ "domain" => 'net-dns.org',
36
+ "retrans" => 6,
37
+ "retry" => 5,
38
+ "usevc" => 1,
39
+ "stayopen" => 1,
40
+ "igntc" => 1,
41
+ "recurse" => 0,
42
+ "defnames" => 0,
43
+ "dnsrch" => 0,
44
+ "debug" => 1,
45
+ "tcp_timeout" => 60,
46
+ "udp_timeout" => 60,
47
+ "persistent_tcp" => 1,
48
+ "dnssec" => 1,
49
+ "force_v4" => 1,
50
+ };
51
+
52
+ #~ #diag "\n\nIf you do not have Net::DNS::SEC installed you will see a warning.\n";
53
+ #~ #diag "It is safe to ignore this\n";
54
+
55
+ good_input.each do | param, value |
56
+ # puts("Setting " + param);
57
+ assert_equal(res.port=(value), value, "setting " + param + " returns correctly");
58
+ assert_equal(res.port, value, "setting #param sticks");
59
+ end;
60
+
61
+ bad_input = {
62
+ "tsig_rr" => 'set',
63
+ "errorstring" => 'set',
64
+ "answerfrom" => 'set',
65
+ "answersize" => 'set',
66
+ "querytime" => 'set',
67
+ "axfr_sel" => 'set',
68
+ "axfr_rr" => 'set',
69
+ "axfr_soa_count" => 'set',
70
+ "udppacketsize" => 'set',
71
+ "cdflag" => 'set',
72
+ };
73
+
74
+ # Some people try to run these on private address space."
75
+
76
+ #~ use Net::IP;
77
+
78
+ #~ use IO::Socket::INET;
79
+ #~ sock = IO::Socket::INET.new(PeerAddr => '193.0.14.129', # k.root-servers.net.
80
+ #~ PeerPort => '25',
81
+ #~ Proto => 'udp');
82
+
83
+
84
+ #~ ip=Net::IP.new(inet_ntoa(sock.sockaddr));
85
+
86
+ # @todo Test whether we are online
87
+ # If we are online, then run the next set of tests
88
+
89
+ res = Net::DNS::Resolver.new
90
+
91
+ res.nameservers=('a.t.net-dns.org')
92
+ ip = res.nameservers()[0]
93
+ print ip.inspect
94
+ assert_equal('10.0.1.128', ip, 'Nameservers() looks up IP.')
95
+
96
+ res.nameservers=('cname.t.net-dns.org')
97
+ ip = (res.nameservers)[0]
98
+ assert_equal(ip, '10.0.1.128', 'Nameservers() looks up cname.')
99
+
100
+
101
+ end
102
+ end
@@ -0,0 +1,40 @@
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 TestRrOpt < Test::Unit::TestCase
19
+ def test_RrOpt
20
+ size=2048;
21
+ ednsflags=0x9e22;
22
+
23
+
24
+ optrr= Net::DNS::RR.create( { :type => 'OPT',
25
+ :name => '',
26
+ :class => size, # Decimal UDPpayload
27
+ :ednsflags => ednsflags # first bit set see RFC 3225
28
+ })
29
+ # @TODO replace DO bit stuff when DNSSEC is implemented
30
+ #assert(optrr.do,"DO bit set")
31
+ #assert_equal(optrr.clear_do,0x1e22,"Clearing do, leaving the other bits ");
32
+ #assert(!optrr.do,"DO bit cleared")
33
+ #assert_equal(optrr.set_do,0x9e22,"Clearing do, leaving the other bits ");
34
+
35
+
36
+ assert_equal(optrr.size,2048,"Size read")
37
+ assert_equal(optrr.size=(1498),1498,"Size set")
38
+
39
+ end
40
+ end
@@ -0,0 +1,116 @@
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 TestRrRrSort < Test::Unit::TestCase
19
+ def test_RrRrSort
20
+ rr1=Net::DNS::RR.create("example.com. 600 IN SRV 0 0 5060 A.example.com.")
21
+ assert_instance_of(Net::DNS::RR::SRV,rr1,"SRV RR1 created")
22
+ rr2=Net::DNS::RR.create("example.com. 600 IN SRV 1 0 5060 A.example.com.")
23
+ assert_instance_of(Net::DNS::RR::SRV,rr2,"SRV RR2 created")
24
+ rr3=Net::DNS::RR.create("example.com. 600 IN SRV 2 0 5060 A.example.com.")
25
+ assert_instance_of(Net::DNS::RR::SRV,rr3,"SRV RR3 created")
26
+ rr4=Net::DNS::RR.create("example.com. 600 IN SRV 3 0 5060 A.example.com.")
27
+ assert_instance_of(Net::DNS::RR::SRV,rr4,"SRV RR4 created")
28
+ rr5=Net::DNS::RR.create("example.com. 600 IN SRV 3 1 5060 A.example.com.")
29
+ assert_instance_of(Net::DNS::RR::SRV,rr5,"SRV RR5 created")
30
+ rr6=Net::DNS::RR.create("example.com. 600 IN SRV 3 2 5060 A.example.com.")
31
+ assert_instance_of(Net::DNS::RR::SRV,rr6,"SRV RR6 created")
32
+ rr7=Net::DNS::RR.create("example.com. 600 IN SRV 1 3 5070 A.example.com.")
33
+ assert_instance_of(Net::DNS::RR::SRV,rr7,"SRV RR7 created")
34
+ rr8=Net::DNS::RR.create("example.com. 600 IN SRV 3 3 5070 A.example.com.")
35
+ assert_instance_of(Net::DNS::RR::SRV,rr8,"SRV RR8 created")
36
+ rr9=Net::DNS::RR.create("example.com. 600 IN A 192.168.0.1")
37
+ assert_instance_of(Net::DNS::RR::A,rr9,"A RR9 created")
38
+
39
+
40
+ rrarray=[rr1, rr2, rr3, rr4, rr5, rr6, rr7, rr8, rr9]
41
+ expectedrdata=[rr1, rr2, rr3, rr7, rr4, rr5, rr6, rr8]
42
+ expectedpriority=[rr1, rr7, rr2, rr3, rr8, rr6, rr5, rr4]
43
+ expectedweight=[rr7, rr8, rr6, rr5, rr1, rr2, rr3, rr4]
44
+
45
+
46
+
47
+ assert_equal(nil,Net::DNS.rrsort("SRV"),"rrsort returns rrerly whith undefined arguments")
48
+
49
+ assert_equal(8,Net::DNS.rrsort("SRV",rrarray).length,"rrsort returns properly whith undefined attribute (1)")
50
+
51
+ #assert_equal(rrsort("SRV",,@rrarray),8,"rrsort returns properly whith undefined attribute (2)")
52
+
53
+ assert_equal(8,Net::DNS.rrsort("SRV","",rrarray).length,"rrsort returns properly whith undefined attribute (3)")
54
+
55
+ prioritysorted= Net::DNS.rrsort("SRV","priority",rrarray)
56
+ weightsorted= Net::DNS.rrsort("SRV","weight",rrarray)
57
+ defaultsorted= Net::DNS.rrsort("SRV",rrarray)
58
+ portsorted= Net::DNS.rrsort("SRV","port",rrarray)
59
+
60
+ foosorted= Net::DNS.rrsort("SRV","foo",rrarray)
61
+ assert_equal(8,foosorted.length,"rrsort returns properly whith undefined attribute (3)")
62
+
63
+ assert_equal(8, prioritysorted.length,"rrsort correctly maintains RRs test 2")
64
+
65
+
66
+ # assert_equal(expectedpriority, prioritysorted, "Sorting on SRV priority works")
67
+ max = 0
68
+ prioritysorted.each { |i| assert(i.priority >= max); max = i.priority}
69
+ # assert_equal(expectedpriority, defaultsorted, "Default SRV sort works")
70
+ max = 0
71
+ defaultsorted.each { |i| assert(i.priority >= max); max = i.priority}
72
+ # assert_equal(expectedweight, weightsorted, "Weight sorted SRV sort works")
73
+ max = 0
74
+ weightsorted.each { |i| assert(i.weight >= max); max = i.weight}
75
+
76
+
77
+ assert_equal(1, Net::DNS.rrsort("A","priority",rrarray).length,"rrsort correctly maintains RRs test 1")
78
+ assert_equal(nil, Net::DNS.rrsort("MX","priority",rrarray),"rrsort correctly maintains RRs test 3")
79
+
80
+
81
+ #
82
+ # Test with MX RRs.
83
+ #
84
+
85
+ mxrr1=Net::DNS::RR.create("example.com. 600 IN MX 10 mx1.example.com")
86
+ mxrr2=Net::DNS::RR.create("example.com. 600 IN MX 6 mx2.example.com")
87
+
88
+ mxrr3=Net::DNS::RR.create("example.com. 600 IN MX 66 mx3.example.com")
89
+ mxrr4=Net::DNS::RR.create("example.com. 600 IN RT 6 rt1.example.com")
90
+
91
+
92
+ mxrrarray=[mxrr1, mxrr2, mxrr3, mxrr4]
93
+ expectedmxarray=[mxrr2,mxrr1,mxrr3]
94
+ sortedmxarray=Net::DNS.rrsort("MX",mxrrarray)
95
+
96
+ assert_equal(expectedmxarray,sortedmxarray,"MX sorting")
97
+
98
+
99
+
100
+
101
+ nsrr1=Net::DNS::RR.create("example.com. 600 IN NS ns2.example.com")
102
+ nsrr2=Net::DNS::RR.create("example.com. 600 IN NS ns4.example.com")
103
+ nsrr3=Net::DNS::RR.create("example.com. 600 IN NS ns1.example.com")
104
+ nsrr4=Net::DNS::RR.create("example.com. 600 IN RT 6 rt1.example.com")
105
+
106
+ nsrrarray=[nsrr1, nsrr2, nsrr3, nsrr4]
107
+ expectednsarray=[nsrr3,nsrr1,nsrr2]
108
+ sortednsarray=Net::DNS.rrsort("NS",nsrrarray)
109
+
110
+
111
+
112
+
113
+ assert_equal(expectednsarray,sortednsarray,"NS sorting")
114
+
115
+ end
116
+ end