net-dns 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.
@@ -0,0 +1,42 @@
1
+ require 'test/unit'
2
+ require 'net/dns/packet'
3
+
4
+ class Test_Packet < Test::Unit::TestCase
5
+ include Net::DNS
6
+
7
+ def setup
8
+ @domain = 'example.com'
9
+ @type = 'MX'
10
+ @cls = 'HS'
11
+
12
+ @default = Packet.new(@domain)
13
+ @string = Packet.new(@domain, MX, HS)
14
+
15
+ 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"
16
+
17
+ @binary = Packet.parse(packet)
18
+
19
+ end
20
+
21
+ def test_instances
22
+ assert_instance_of(Net::DNS::Packet, @string)
23
+ assert_instance_of(Net::DNS::Header, @string.header)
24
+ assert_instance_of(Array, @string.question)
25
+ assert_instance_of(Net::DNS::Question, @string.question[0])
26
+ assert_instance_of(Array, @string.answer)
27
+ assert_instance_of(Array, @string.authority)
28
+ assert_instance_of(Array, @string.additional)
29
+
30
+ assert_instance_of(Net::DNS::Packet, @binary)
31
+ assert_instance_of(Net::DNS::Header, @binary.header)
32
+ assert_instance_of(Array, @binary.question)
33
+ assert_instance_of(Net::DNS::Question, @binary.question[0])
34
+ assert_instance_of(Array, @binary.answer)
35
+ assert_instance_of(Net::DNS::RR::A, @binary.answer[0])
36
+ assert_instance_of(Array, @binary.authority)
37
+ assert_instance_of(Net::DNS::RR::NS, @binary.authority[0])
38
+ assert_instance_of(Array, @binary.additional)
39
+ assert_instance_of(Net::DNS::RR::A, @binary.additional[0])
40
+ end
41
+
42
+ end
@@ -0,0 +1,54 @@
1
+ require 'test/unit'
2
+ require 'net/dns/question'
3
+
4
+ class Test_Question < Test::Unit::TestCase
5
+ include Net::DNS
6
+
7
+ def setup
8
+ @domain = 'example.com.'
9
+ @type = 'MX'
10
+ @cls = 'HS'
11
+ @data = "\006google\003com\000\000\001\000\001"
12
+
13
+ @default = Question.new(@domain)
14
+ @string = Question.new(@domain,@type,@cls)
15
+ @binary = Question.parse(@data)
16
+ @binary2 = Question.parse(@string.data)
17
+ end
18
+
19
+ def test_simple
20
+ assert_equal(@default.qName, @domain)
21
+ assert_equal(@default.qType.to_s, "A")
22
+ assert_equal(@default.qClass.to_s, "IN")
23
+
24
+ assert_equal(@string.qName, @domain)
25
+ assert_equal(@string.qType.to_s, "MX")
26
+ assert_equal(@string.qClass.to_s, "HS")
27
+
28
+ assert_equal(@binary.qName, "google.com.")
29
+ assert_equal(@binary.qType.to_s, "A")
30
+ assert_equal(@binary.qClass.to_s, "IN")
31
+
32
+ assert_equal(@binary2.qName, @domain)
33
+ assert_equal(@binary2.qType.to_s, "MX")
34
+ assert_equal(@binary2.qClass.to_s, "HS")
35
+ end
36
+
37
+ def test_raise
38
+ assert_raise(QuestionNameError) do
39
+ Question.new(1)
40
+ end
41
+ assert_raise(QuestionNameError) do
42
+ Question.new("test{")
43
+ end
44
+ assert_raise(QuestionArgumentError) do
45
+ Question.parse(Array.new)
46
+ end
47
+ assert_raise(QuestionArgumentError) do
48
+ Question.parse("test")
49
+ end
50
+
51
+ end
52
+
53
+
54
+ end
@@ -0,0 +1,128 @@
1
+ require 'test/unit'
2
+ require 'net/dns/rr'
3
+
4
+ class Test_RR < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @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 => @name,
14
+ :rdata => @rdata)
15
+
16
+
17
+ @a_hash = Net::DNS::RR.new(:name => @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
+ end
38
+
39
+ def test_classes
40
+ assert_instance_of Net::DNS::RR::A, @a
41
+ assert_instance_of Net::DNS::RR::MX, @mx
42
+ assert_instance_of Net::DNS::RR::CNAME, @cname
43
+ assert_instance_of Net::DNS::RR::TXT, @txt
44
+ assert_instance_of Net::DNS::RR::A, @a_binary
45
+ assert_instance_of Net::DNS::RR::MX, @mx_binary
46
+ end
47
+
48
+ def test_ttl
49
+ assert_equal @a.ttl, 86400
50
+ assert_equal @mx.ttl, 7200
51
+ assert_equal @cname.ttl, 10800
52
+ assert_equal @txt.ttl, 3600
53
+ assert_equal @a_binary.ttl, 86400
54
+ assert_equal @mx_binary.ttl, 7200
55
+ end
56
+
57
+ def test_types
58
+ assert_equal @a.type, "A"
59
+ assert_equal @mx.type, "MX"
60
+ assert_equal @cname.type, "CNAME"
61
+ assert_equal @txt.type, "TXT"
62
+ assert_equal @a_binary.type, "A"
63
+ assert_equal @mx_binary.type, "MX"
64
+ end
65
+
66
+ def test_cls
67
+ assert_equal @a.cls, "IN"
68
+ assert_equal @mx.cls, "IN"
69
+ assert_equal @cname.cls, "IN"
70
+ assert_equal @txt.cls, "HS"
71
+ assert_equal @a_binary.cls, "IN"
72
+ assert_equal @mx_binary.cls, "IN"
73
+ end
74
+
75
+ def test_name
76
+ assert_equal @a.name, "foo.example.com."
77
+ assert_equal @mx.name, "example.com."
78
+ assert_equal @cname.name, "www.example.com"
79
+ assert_equal @txt.name, "baz.example.com"
80
+ assert_equal @a_binary.name, "foo.example.com."
81
+ assert_equal @mx_binary.name, "example.com."
82
+ end
83
+
84
+ def test_rdata
85
+ assert_equal @a.address.to_s, "10.1.2.3"
86
+ assert_equal @mx.preference, 10
87
+ assert_equal @mx.exchange, "mailhost.example.com."
88
+ assert_equal @cname.cname, "www1.example.com"
89
+ assert_equal @txt.txt, '"text record"'
90
+ assert_equal @a_binary.address.to_s, "10.1.2.3"
91
+ assert_equal @mx_binary.preference, 10
92
+ assert_equal @mx_binary.exchange, "mailhost.example.com."
93
+ end
94
+
95
+ def test_simple
96
+
97
+ assert_equal @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(@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(@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
+ end
120
+
121
+ def test_range
122
+ assert_raise(RRArgumentError) do
123
+ Net::DNS::RR.new("google.com. 10800 IM A")
124
+ end
125
+ end
126
+
127
+ end
128
+
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: net-dns
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.1"
7
+ date: 2007-01-23 00:00:00 +00:00
8
+ summary: Pure Ruby DNS library
9
+ require_paths:
10
+ - lib
11
+ email: ceresa@gmail.com
12
+ homepage: http://net-dns.rubyforge.org/
13
+ rubyforge_project:
14
+ description: A pure Ruby DNS library, similar to the Perl Net::DNS library
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Marco Ceresa
31
+ files:
32
+ - setup.rb
33
+ - AUTHORS
34
+ - INSTALL
35
+ - README
36
+ - THANKS
37
+ - demo
38
+ - lib
39
+ - gemspec
40
+ - test
41
+ - Rakefile
42
+ - demo/check_soa.rb
43
+ - demo/threads.rb
44
+ - lib/net
45
+ - lib/net/dns
46
+ - lib/net/dns/resolver
47
+ - lib/net/dns/rr
48
+ - lib/net/dns/resolver.rb
49
+ - lib/net/dns/rr.rb
50
+ - lib/net/dns/header.rb
51
+ - lib/net/dns/question.rb
52
+ - lib/net/dns/dns.rb
53
+ - lib/net/dns/packet.rb
54
+ - lib/net/dns/names
55
+ - lib/net/dns/resolver/timeouts.rb
56
+ - lib/net/dns/resolver/socks.rb
57
+ - lib/net/dns/rr/types.rb
58
+ - lib/net/dns/rr/classes.rb
59
+ - lib/net/dns/rr/a.rb
60
+ - lib/net/dns/rr/mx.rb
61
+ - lib/net/dns/rr/ns.rb
62
+ - lib/net/dns/rr/cname.rb
63
+ - lib/net/dns/rr/txt.rb
64
+ - lib/net/dns/rr/soa.rb
65
+ - lib/net/dns/rr/null.rb
66
+ - lib/net/dns/rr/ptr.rb
67
+ - lib/net/dns/rr/hinfo.rb
68
+ - lib/net/dns/rr/mr.rb
69
+ - lib/net/dns/rr/aaaa.rb
70
+ - lib/net/dns/names/names.rb
71
+ - test/net
72
+ - test/net/dns
73
+ - test/net/dns/resolver
74
+ - test/net/dns/rr
75
+ - test/net/dns/test_rr.rb
76
+ - test/net/dns/test_question.rb
77
+ - test/net/dns/test_header.rb
78
+ - test/net/dns/test_packet.rb
79
+ - test/net/dns/resolver/test_timeouts.rb
80
+ - test/net/dns/rr/test_ns.rb
81
+ - test/net/dns/rr/test_a.rb
82
+ - test/net/dns/rr/test_classes.rb
83
+ - test/net/dns/rr/test_types.rb
84
+ test_files: []
85
+
86
+ rdoc_options: []
87
+
88
+ extra_rdoc_files:
89
+ - README
90
+ executables: []
91
+
92
+ extensions: []
93
+
94
+ requirements: []
95
+
96
+ dependencies: []
97
+