bluemonk-net-dns 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,133 @@
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
+ @array = [@name,@ttl,@cls,@type,@rdata]
38
+
39
+ end
40
+
41
+ def test_classes
42
+ assert_instance_of Net::DNS::RR::A, @a
43
+ assert_instance_of Net::DNS::RR::MX, @mx
44
+ assert_instance_of Net::DNS::RR::CNAME, @cname
45
+ assert_instance_of Net::DNS::RR::TXT, @txt
46
+ assert_instance_of Net::DNS::RR::A, @a_binary
47
+ assert_instance_of Net::DNS::RR::MX, @mx_binary
48
+ end
49
+
50
+ def test_ttl
51
+ assert_equal @a.ttl, 86400
52
+ assert_equal @mx.ttl, 7200
53
+ assert_equal @cname.ttl, 10800
54
+ assert_equal @txt.ttl, 3600
55
+ assert_equal @a_binary.ttl, 86400
56
+ assert_equal @mx_binary.ttl, 7200
57
+ end
58
+
59
+ def test_types
60
+ assert_equal @a.type, "A"
61
+ assert_equal @mx.type, "MX"
62
+ assert_equal @cname.type, "CNAME"
63
+ assert_equal @txt.type, "TXT"
64
+ assert_equal @a_binary.type, "A"
65
+ assert_equal @mx_binary.type, "MX"
66
+ end
67
+
68
+ def test_cls
69
+ assert_equal @a.cls, "IN"
70
+ assert_equal @mx.cls, "IN"
71
+ assert_equal @cname.cls, "IN"
72
+ assert_equal @txt.cls, "HS"
73
+ assert_equal @a_binary.cls, "IN"
74
+ assert_equal @mx_binary.cls, "IN"
75
+ end
76
+
77
+ def test_name
78
+ assert_equal @a.name, "foo.example.com."
79
+ assert_equal @mx.name, "example.com."
80
+ assert_equal @cname.name, "www.example.com"
81
+ assert_equal @txt.name, "baz.example.com"
82
+ assert_equal @a_binary.name, "foo.example.com."
83
+ assert_equal @mx_binary.name, "example.com."
84
+ end
85
+
86
+ def test_rdata
87
+ assert_equal @a.address.to_s, "10.1.2.3"
88
+ assert_equal @mx.preference, 10
89
+ assert_equal @mx.exchange, "mailhost.example.com."
90
+ assert_equal @cname.cname, "www1.example.com"
91
+ assert_equal @txt.txt, '"text record"'
92
+ assert_equal @a_binary.address.to_s, "10.1.2.3"
93
+ assert_equal @mx_binary.preference, 10
94
+ assert_equal @mx_binary.exchange, "mailhost.example.com."
95
+ end
96
+
97
+ def test_simple
98
+
99
+ assert_equal @name, @defaults.name
100
+ assert_equal @type, @defaults.type
101
+ assert_equal @cls, @defaults.cls
102
+ assert_equal @ttl, @defaults.ttl
103
+ assert_equal @rdata, @defaults.rdata.to_s
104
+
105
+ assert_equal(@str,@a_hash.inspect)
106
+ assert_equal(@name, @a_hash.name)
107
+ assert_equal(@type, @a_hash.type)
108
+ assert_equal(@cls, @a_hash.cls)
109
+ assert_equal(@ttl, @a_hash.ttl)
110
+ assert_equal(@rdata, @a_hash.address.to_s)
111
+
112
+ assert_equal(@str, @a_string.inspect)
113
+ assert_equal(@name, @a_string.name)
114
+ assert_equal(@type, @a_string.type)
115
+ assert_equal(@cls, @a_string.cls)
116
+ assert_equal(@ttl, @a_string.ttl)
117
+ assert_equal(@rdata, @a_string.address.to_s)
118
+
119
+ assert_equal(@a_data, @a_binary.data)
120
+ assert_equal(@mx_data, @mx_binary.data)
121
+
122
+ assert_equal(@str, @a_hash.to_s)
123
+ assert_equal(@array, @a_hash.to_a)
124
+ end
125
+
126
+ def test_range
127
+ assert_raise(RRArgumentError) do
128
+ Net::DNS::RR.new("google.com. 10800 IM A")
129
+ end
130
+ end
131
+
132
+ end
133
+
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bluemonk-net-dns
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Marco Ceresa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-10 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Net::DNS is a pure Ruby DNS library, with a clean OO interface and an extensible API
17
+ email: ceresa@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - AUTHORS
24
+ - INSTALL
25
+ - README.rdoc
26
+ - THANKS
27
+ files:
28
+ - AUTHORS
29
+ - CHANGELOG
30
+ - INSTALL
31
+ - README.rdoc
32
+ - Rakefile
33
+ - THANKS
34
+ - VERSION.yml
35
+ - demo/check_soa.rb
36
+ - demo/threads.rb
37
+ - lib/net/dns/dns.rb
38
+ - lib/net/dns/header.rb
39
+ - lib/net/dns/names/names.rb
40
+ - lib/net/dns/packet.rb
41
+ - lib/net/dns/question.rb
42
+ - lib/net/dns/resolver.rb
43
+ - lib/net/dns/resolver/socks.rb
44
+ - lib/net/dns/resolver/timeouts.rb
45
+ - lib/net/dns/rr.rb
46
+ - lib/net/dns/rr/a.rb
47
+ - lib/net/dns/rr/aaaa.rb
48
+ - lib/net/dns/rr/classes.rb
49
+ - lib/net/dns/rr/cname.rb
50
+ - lib/net/dns/rr/hinfo.rb
51
+ - lib/net/dns/rr/mr.rb
52
+ - lib/net/dns/rr/mx.rb
53
+ - lib/net/dns/rr/ns.rb
54
+ - lib/net/dns/rr/null.rb
55
+ - lib/net/dns/rr/ptr.rb
56
+ - lib/net/dns/rr/soa.rb
57
+ - lib/net/dns/rr/srv.rb
58
+ - lib/net/dns/rr/txt.rb
59
+ - lib/net/dns/rr/types.rb
60
+ - setup.rb
61
+ - test/net/dns/resolver/test_timeouts.rb
62
+ - test/net/dns/rr/test_a.rb
63
+ - test/net/dns/rr/test_classes.rb
64
+ - test/net/dns/rr/test_ns.rb
65
+ - test/net/dns/rr/test_types.rb
66
+ - test/net/dns/test_header.rb
67
+ - test/net/dns/test_packet.rb
68
+ - test/net/dns/test_question.rb
69
+ - test/net/dns/test_rr.rb
70
+ has_rdoc: false
71
+ homepage: http://github.com/bluemonk/net-dns
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --charset=UTF-8
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ version:
89
+ requirements: []
90
+
91
+ rubyforge_project:
92
+ rubygems_version: 1.2.0
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Pure Ruby DNS library
96
+ test_files:
97
+ - test/net/dns/test_header.rb
98
+ - test/net/dns/rr/test_types.rb
99
+ - test/net/dns/rr/test_a.rb
100
+ - test/net/dns/rr/test_ns.rb
101
+ - test/net/dns/rr/test_classes.rb
102
+ - test/net/dns/resolver/test_timeouts.rb
103
+ - test/net/dns/test_rr.rb
104
+ - test/net/dns/test_packet.rb
105
+ - test/net/dns/test_question.rb