whois 0.5.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/CHANGELOG.rdoc +55 -0
  2. data/Manifest +43 -8
  3. data/README.rdoc +53 -20
  4. data/lib/whois.rb +69 -1
  5. data/lib/whois/answer.rb +126 -0
  6. data/lib/whois/answer/contact.rb +55 -0
  7. data/lib/whois/answer/parser.rb +110 -0
  8. data/lib/whois/answer/parser/README.rdoc +21 -0
  9. data/lib/whois/answer/parser/base.rb +144 -0
  10. data/lib/whois/answer/parser/blank.rb +45 -0
  11. data/lib/whois/answer/parser/whois.crsnic.net.rb +209 -0
  12. data/lib/whois/answer/parser/whois.denic.de.rb +202 -0
  13. data/lib/whois/answer/parser/whois.nic.it.rb +330 -0
  14. data/lib/whois/answer/parser/whois.publicinterestregistry.net.rb +232 -0
  15. data/lib/whois/answer/part.rb +35 -0
  16. data/lib/whois/answer/registrar.rb +42 -0
  17. data/lib/whois/answer/super_struct.rb +57 -0
  18. data/lib/whois/client.rb +6 -0
  19. data/lib/whois/definitions/tlds.rb +2 -2
  20. data/lib/whois/errors.rb +25 -8
  21. data/lib/whois/server.rb +0 -1
  22. data/lib/whois/server/adapters/afilias.rb +5 -5
  23. data/lib/whois/server/adapters/base.rb +31 -4
  24. data/lib/whois/server/adapters/formatted.rb +3 -1
  25. data/lib/whois/server/adapters/none.rb +20 -1
  26. data/lib/whois/server/adapters/pir.rb +5 -5
  27. data/lib/whois/server/adapters/standard.rb +13 -2
  28. data/lib/whois/server/adapters/verisign.rb +5 -5
  29. data/lib/whois/server/adapters/web.rb +15 -0
  30. data/lib/whois/version.rb +2 -2
  31. data/lib/whois/whois.rb +2 -2
  32. data/test/answer/parser/base_test.rb +27 -0
  33. data/test/answer/parser/blank_test.rb +19 -0
  34. data/test/answer/parser/whois_crsnic_net_test.rb +175 -0
  35. data/test/answer/parser/whois_denic_de_test.rb +209 -0
  36. data/test/answer/parser/whois_nic_it_test.rb +255 -0
  37. data/test/answer/parser/whois_publicinterestregistry_net_test.rb +210 -0
  38. data/test/answer/parser_test.rb +77 -0
  39. data/test/answer_test.rb +99 -0
  40. data/test/client_test.rb +3 -3
  41. data/test/integration_test.rb +31 -0
  42. data/test/{adapters → server/adapters}/afilias_test.rb +10 -5
  43. data/test/server/adapters/base_test.rb +15 -0
  44. data/test/server/adapters/formatted_test.rb +26 -0
  45. data/test/{adapters → server/adapters}/none_test.rb +0 -0
  46. data/test/{adapters → server/adapters}/not_implemented_test.rb +0 -0
  47. data/test/{adapters → server/adapters}/pir_test.rb +10 -5
  48. data/test/server/adapters/standard_test.rb +29 -0
  49. data/test/{adapters → server/adapters}/verisign_test.rb +10 -5
  50. data/test/{adapters → server/adapters}/web_test.rb +0 -0
  51. data/test/server_test.rb +5 -1
  52. data/test/testcases/responses/super_struct_test.rb +25 -0
  53. data/test/testcases/responses/whois.crsnic.net/available.txt +43 -0
  54. data/test/testcases/responses/whois.crsnic.net/registered.txt +57 -0
  55. data/test/testcases/responses/whois.denic.de/available.txt +30 -0
  56. data/test/testcases/responses/whois.denic.de/registered.txt +77 -0
  57. data/test/testcases/responses/whois.nic.it/available.txt +2 -0
  58. data/test/testcases/responses/{it.txt → whois.nic.it/registered.txt} +1 -0
  59. data/test/testcases/responses/whois.nic.it/status_active.txt +53 -0
  60. data/test/testcases/responses/whois.nic.it/status_available.txt +2 -0
  61. data/test/testcases/responses/whois.publicinterestregistry.net/available.txt +1 -0
  62. data/test/testcases/responses/whois.publicinterestregistry.net/registered.txt +85 -0
  63. data/test/whois_test.rb +23 -1
  64. data/utils/bm_delegation_vs_inheritance.rb +150 -0
  65. data/whois.gemspec +6 -6
  66. metadata +78 -18
  67. data/test/adapters/standard_test.rb +0 -23
@@ -0,0 +1,209 @@
1
+ require 'test_helper'
2
+ require 'whois/answer/parser/whois.denic.de'
3
+
4
+ class AnswerParserWhoisDenicDeTest < Test::Unit::TestCase
5
+
6
+ TESTCASE_PATH = File.expand_path(File.dirname(__FILE__) + '/../../testcases/responses/whois.denic.de')
7
+
8
+ def setup
9
+ @klass = Whois::Answer::Parser::WhoisDenicDe
10
+ @host = "whois.denic.de"
11
+ end
12
+
13
+
14
+ def test_disclaimer
15
+ expected = <<-EOS.strip
16
+ All the domain data that is visible in the whois search is protected \
17
+ by law. It is not permitted to use it for any purpose other than \
18
+ technical or administrative requirements associated with the \
19
+ operation of the Internet or in order to contact the domain holder \
20
+ over legal problems. You are not permitted to save it electronically \
21
+ or in any other way without DENIC's express written permission. It \
22
+ is prohibited, in particular, to use it for advertising or any similar \
23
+ purpose. By maintaining the connection you assure that you have a legitimate \
24
+ interest in the data and that you will only use it for the stated \
25
+ purposes. You are aware that DENIC maintains the right to initiate \
26
+ legal proceedings against you in the event of any breach of this \
27
+ assurance and to bar you from using its whois query.
28
+ EOS
29
+ assert_equal expected,
30
+ @klass.new(load_part('/registered.txt')).disclaimer
31
+ end
32
+
33
+ def test_disclaimer_with_available
34
+ expected = <<-EOS.strip
35
+ All the domain data that is visible in the whois search is protected \
36
+ by law. It is not permitted to use it for any purpose other than \
37
+ technical or administrative requirements associated with the \
38
+ operation of the Internet or in order to contact the domain holder \
39
+ over legal problems. You are not permitted to save it electronically \
40
+ or in any other way without DENIC's express written permission. It \
41
+ is prohibited, in particular, to use it for advertising or any similar \
42
+ purpose. By maintaining the connection you assure that you have a legitimate \
43
+ interest in the data and that you will only use it for the stated \
44
+ purposes. You are aware that DENIC maintains the right to initiate \
45
+ legal proceedings against you in the event of any breach of this \
46
+ assurance and to bar you from using its whois query.
47
+ EOS
48
+ assert_equal expected,
49
+ @klass.new(load_part('/available.txt')).disclaimer
50
+ end
51
+
52
+
53
+ def test_domain
54
+ assert_equal nil,
55
+ @klass.new(load_part('/available.txt')).domain
56
+ assert_equal 'google.de',
57
+ @klass.new(load_part('/registered.txt')).domain
58
+ end
59
+
60
+ def test_domain_id
61
+ assert_equal nil,
62
+ @klass.new(load_part('/available.txt')).domain_id
63
+ assert_equal nil,
64
+ @klass.new(load_part('/registered.txt')).domain_id
65
+ end
66
+
67
+
68
+ def test_status
69
+ assert_equal nil,
70
+ @klass.new(load_part('/available.txt')).status
71
+ assert_equal 'connect',
72
+ @klass.new(load_part('/registered.txt')).status
73
+ end
74
+
75
+ def test_registered?
76
+ assert !@klass.new(load_part('/available.txt')).registered?
77
+ assert @klass.new(load_part('/registered.txt')).registered?
78
+ end
79
+
80
+ def test_available?
81
+ assert @klass.new(load_part('/available.txt')).available?
82
+ assert !@klass.new(load_part('/registered.txt')).available?
83
+ end
84
+
85
+
86
+ def test_created_on_with_available
87
+ assert_equal nil,
88
+ @klass.new(load_part('/available.txt')).created_on
89
+ end
90
+
91
+ def test_updated_on
92
+ assert_equal Time.parse('2009-02-28T12:03:09+01:00'),
93
+ @klass.new(load_part('/registered.txt')).updated_on
94
+ end
95
+
96
+ def test_updated_on_with_available
97
+ assert_equal nil,
98
+ @klass.new(load_part('/available.txt')).updated_on
99
+ end
100
+
101
+ def test_expires_on_with_available
102
+ assert_equal nil,
103
+ @klass.new(load_part('/available.txt')).expires_on
104
+ end
105
+
106
+
107
+ def test_registrar
108
+ registrar = @klass.new(load_part('/registered.txt')).registrar
109
+ assert_instance_of(Whois::Answer::Registrar, registrar)
110
+ assert_equal(nil, registrar.id)
111
+ assert_equal('Domain Billing', registrar.name)
112
+ assert_equal('MarkMonitor', registrar.organization)
113
+ assert_equal(nil, registrar.url)
114
+ end
115
+
116
+ def test_registrar_for_available
117
+ assert_equal nil,
118
+ @klass.new(load_part('/available.txt')).registrar
119
+ end
120
+
121
+ def test_registrant
122
+ contact = @klass.new(load_part('/registered.txt')).registrant
123
+ assert_instance_of(Whois::Answer::Contact, contact)
124
+ assert_equal(nil, contact.id)
125
+ assert_equal('Google Inc.', contact.name)
126
+ assert_equal(nil, contact.organization)
127
+ assert_equal('1600 Amphitheatre Parkway', contact.address)
128
+ assert_equal('Mountain View', contact.city)
129
+ assert_equal(nil, contact.state)
130
+ assert_equal('94043', contact.zip)
131
+ assert_equal(nil, contact.country)
132
+ assert_equal('US', contact.country_code)
133
+ assert_equal(nil, contact.phone)
134
+ assert_equal(nil, contact.fax)
135
+ assert_equal(nil, contact.email)
136
+ end
137
+
138
+ def test_registrant_for_available
139
+ assert_equal nil,
140
+ @klass.new(load_part('/available.txt')).registrant
141
+ end
142
+
143
+ def test_admin
144
+ contact = @klass.new(load_part('/registered.txt')).admin
145
+ assert_instance_of(Whois::Answer::Contact, contact)
146
+ assert_equal(nil, contact.id)
147
+ assert_equal('Lena Tangermann', contact.name)
148
+ assert_equal('Google Germany GmbH', contact.organization)
149
+ assert_equal('ABC-Strasse 19', contact.address)
150
+ assert_equal('Hamburg', contact.city)
151
+ assert_equal(nil, contact.state)
152
+ assert_equal('20354', contact.zip)
153
+ assert_equal(nil, contact.country)
154
+ assert_equal('DE', contact.country_code)
155
+ assert_equal(nil, contact.phone)
156
+ assert_equal(nil, contact.fax)
157
+ assert_equal(nil, contact.email)
158
+ end
159
+
160
+ def test_admin_for_available
161
+ assert_equal nil,
162
+ @klass.new(load_part('/available.txt')).admin
163
+ end
164
+
165
+ def test_technical
166
+ contact = @klass.new(load_part('/registered.txt')).technical
167
+ assert_instance_of(Whois::Answer::Contact, contact)
168
+ assert_equal(nil, contact.id)
169
+ assert_equal('Google Inc.', contact.name)
170
+ assert_equal(nil, contact.organization)
171
+ assert_equal(['Google Inc.', '1600 Amphitheatre Parkway'], contact.address)
172
+ assert_equal('Mountain View', contact.city)
173
+ assert_equal(nil, contact.state)
174
+ assert_equal('94043', contact.zip)
175
+ assert_equal(nil, contact.country)
176
+ assert_equal('US', contact.country_code)
177
+ assert_equal('+1-6503300100', contact.phone)
178
+ assert_equal('+1-6506188571', contact.fax)
179
+ assert_equal('dns-admin@google.com', contact.email)
180
+ end
181
+
182
+ def test_technical_for_available
183
+ assert_equal nil,
184
+ @klass.new(load_part('/available.txt')).technical
185
+ end
186
+
187
+
188
+ def test_nameservers
189
+ assert_equal %w(ns1.google.com ns4.google.com ns3.google.com ns2.google.com),
190
+ @klass.new(load_part('/registered.txt')).nameservers
191
+ end
192
+
193
+ def test_nameservers_for_available
194
+ assert_equal nil,
195
+ @klass.new(load_part('/available.txt')).nameservers
196
+ end
197
+
198
+
199
+ protected
200
+
201
+ def load_part(path)
202
+ part(File.read(TESTCASE_PATH + path), @host)
203
+ end
204
+
205
+ def part(*args)
206
+ Whois::Answer::Part.new(*args)
207
+ end
208
+
209
+ end
@@ -0,0 +1,255 @@
1
+ require 'test_helper'
2
+ require 'whois/answer/parser/whois.nic.it.rb'
3
+
4
+ class AnswerParserWhoisNicItTest < Test::Unit::TestCase
5
+
6
+ TESTCASE_PATH = File.expand_path(File.dirname(__FILE__) + '/../../testcases/responses/whois.nic.it')
7
+
8
+ def setup
9
+ @klass = Whois::Answer::Parser::WhoisNicIt
10
+ @host = "whois.nic.it"
11
+ end
12
+
13
+
14
+ def test_disclaimer
15
+ assert_equal "Please note that the following result could be a subgroup of the data contained in the database. Additional information can be visualized at: http://www.nic.it/cgi-bin/Whois/whois.cgi",
16
+ @klass.new(load_part('/registered.txt')).disclaimer
17
+ end
18
+
19
+ def test_disclaimer_with_available
20
+ assert_equal nil,
21
+ @klass.new(load_part('/available.txt')).disclaimer
22
+ end
23
+
24
+
25
+ def test_domain
26
+ assert_equal "google.it",
27
+ @klass.new(load_part('/available.txt')).domain
28
+ assert_equal "google.it",
29
+ @klass.new(load_part('/registered.txt')).domain
30
+ end
31
+
32
+ def test_domain_id
33
+ assert_equal nil,
34
+ @klass.new(load_part('/available.txt')).domain_id
35
+ assert_equal nil,
36
+ @klass.new(load_part('/registered.txt')).domain_id
37
+ end
38
+
39
+
40
+ def test_status
41
+ assert_equal :available,
42
+ @klass.new(load_part('/status_available.txt')).status
43
+ assert_equal :active,
44
+ @klass.new(load_part('/status_active.txt')).status
45
+ end
46
+
47
+ def test_available?
48
+ assert !@klass.new(load_part('/registered.txt')).available?
49
+ assert @klass.new(load_part('/available.txt')).available?
50
+ end
51
+
52
+ def test_registered?
53
+ assert !@klass.new(load_part('/available.txt')).registered?
54
+ assert @klass.new(load_part('/registered.txt')).registered?
55
+ end
56
+
57
+
58
+ def test_created_on
59
+ assert_equal Time.parse("1999-12-10 00:00:00"),
60
+ @klass.new(load_part('/registered.txt')).created_on
61
+ end
62
+
63
+ def test_created_on_with_available
64
+ assert_equal nil,
65
+ @klass.new(load_part('/available.txt')).created_on
66
+ end
67
+
68
+ def test_updated_on
69
+ assert_equal Time.parse("2008-11-27 16:47:22"),
70
+ @klass.new(load_part('/registered.txt')).updated_on
71
+ end
72
+
73
+ def test_updated_on_with_available
74
+ assert_equal nil,
75
+ @klass.new(load_part('/available.txt')).updated_on
76
+ end
77
+
78
+ def test_expires_on
79
+ assert_equal Time.parse("2009-11-27"),
80
+ @klass.new(load_part('/registered.txt')).expires_on
81
+ end
82
+
83
+ def test_expires_on_with_available
84
+ assert_equal nil,
85
+ @klass.new(load_part('/available.txt')).expires_on
86
+ end
87
+
88
+
89
+ def test_registrar
90
+ registrar = @klass.new(load_part('/registered.txt')).registrar
91
+ assert_instance_of Whois::Answer::Registrar, registrar
92
+ assert_equal "REGISTER-MNT", registrar.id
93
+ assert_equal "REGISTER-MNT", registrar.name
94
+ assert_equal "Register.it s.p.a.", registrar.organization
95
+ end
96
+
97
+ def test_registrar_with_available
98
+ assert_equal nil,
99
+ @klass.new(load_part('/available.txt')).registrar
100
+ end
101
+
102
+
103
+ def test_registrant
104
+ contact = @klass.new(load_part('/registered.txt')).registrant
105
+ assert_instance_of Whois::Answer::Contact, contact
106
+ assert_equal "GOOG175-ITNIC", contact.id
107
+ assert_equal "Google Ireland Holdings", contact.name
108
+ assert_equal nil, contact.organization
109
+ assert_equal "30 Herbert Street", contact.address
110
+ assert_equal "Dublin", contact.city
111
+ assert_equal nil, contact.country
112
+ assert_equal "IE", contact.country_code
113
+ assert_equal Time.parse("2008-11-27 16:47:22"), contact.created_on
114
+ assert_equal Time.parse("2008-11-27 16:47:22"), contact.updated_on
115
+ end
116
+
117
+ def test_registrant_with_available
118
+ assert_equal nil,
119
+ @klass.new(load_part('/available.txt')).registrant
120
+ end
121
+
122
+
123
+ def test_admin
124
+ contact = @klass.new(load_part('/registered.txt')).admin
125
+ assert_instance_of Whois::Answer::Contact, contact
126
+ assert_equal "TT4277-ITNIC", contact.id
127
+ assert_equal "Tsao Tu", contact.name
128
+ assert_equal "Tu Tsao", contact.organization
129
+ assert_equal "30 Herbert Street", contact.address
130
+ assert_equal "Dublin", contact.city
131
+ assert_equal nil, contact.country
132
+ assert_equal "IE", contact.country_code
133
+ assert_equal Time.parse("2008-11-27 16:47:22"), contact.created_on
134
+ assert_equal Time.parse("2008-11-27 16:47:22"), contact.updated_on
135
+ end
136
+
137
+ def test_admin_with_available
138
+ assert_equal nil,
139
+ @klass.new(load_part('/available.txt')).admin
140
+ end
141
+
142
+
143
+ def test_technical
144
+ contact = @klass.new(load_part('/registered.txt')).technical
145
+ assert_instance_of Whois::Answer::Contact, contact
146
+ assert_equal "TS7016-ITNIC", contact.id
147
+ assert_equal "Technical Services", contact.name
148
+ assert_equal nil, contact.organization
149
+ assert_equal nil, contact.address
150
+ assert_equal nil, contact.city
151
+ assert_equal nil, contact.country
152
+ assert_equal nil, contact.country_code
153
+ assert_equal nil, contact.created_on
154
+ assert_equal nil, contact.updated_on
155
+ end
156
+
157
+ def test_technical_with_available
158
+ assert_equal nil,
159
+ @klass.new(load_part('/available.txt')).technical
160
+ end
161
+
162
+
163
+ def test_nameservers
164
+ assert_equal %w(ns1.google.com ns4.google.com ns2.google.com ns3.google.com),
165
+ @klass.new(load_part('/registered.txt')).nameservers
166
+ end
167
+
168
+ def test_nameservers_with_available
169
+ assert_equal nil,
170
+ @klass.new(load_part('/available.txt')).nameservers
171
+ end
172
+
173
+
174
+ def test_changed_question_check_self
175
+ parser = @klass.new(load_part('/registered.txt'))
176
+ assert !parser.changed?(parser)
177
+ end
178
+
179
+ def test_changed_question_check_internals
180
+ parser = @klass.new(load_part('/registered.txt'))
181
+ assert parser.changed?(@klass.new(load_part('/available.txt')))
182
+ end
183
+
184
+ def test_changed_question_check_self_with_available
185
+ parser = @klass.new(part(<<-RESPONSE, @host))
186
+ Domain: google.it
187
+ Status: AVAILABLE
188
+ RESPONSE
189
+
190
+ assert !parser.changed?(parser)
191
+ end
192
+
193
+ def test_changed_question_check_internals_with_available
194
+ parser = @klass.new(part(<<-RESPONSE, @host))
195
+ Domain: google.it
196
+ Status: AVAILABLE
197
+ RESPONSE
198
+
199
+ assert parser.changed?(@klass.new(part(<<-RESPONSE, @host)))
200
+ Domain: weppos.it
201
+ Status: AVAILABLE
202
+ RESPONSE
203
+ assert !parser.changed?(@klass.new(part(<<-RESPONSE, @host)))
204
+ Domain: google.it
205
+ Status: AVAILABLE
206
+ RESPONSE
207
+ end
208
+
209
+ def test_unchanged_question_check_self
210
+ parser = @klass.new(load_part('/registered.txt'))
211
+ assert parser.unchanged?(parser)
212
+ end
213
+
214
+ def test_unchanged_question_check_internals
215
+ parser = @klass.new(load_part('/registered.txt'))
216
+ assert parser.unchanged?(@klass.new(load_part('/registered.txt')))
217
+ end
218
+
219
+ def test_unchanged_question_check_self_with_available
220
+ parser = @klass.new(part(<<-RESPONSE, @host))
221
+ Domain: google.it
222
+ Status: AVAILABLE
223
+ RESPONSE
224
+
225
+ assert parser.unchanged?(parser)
226
+ end
227
+
228
+ def test_unchanged_question_check_internals_with_available
229
+ parser = @klass.new(part(<<-RESPONSE, @host))
230
+ Domain: google.it
231
+ Status: AVAILABLE
232
+ RESPONSE
233
+
234
+ assert parser.unchanged?(@klass.new(part(<<-RESPONSE, @host)))
235
+ Domain: google.it
236
+ Status: AVAILABLE
237
+ RESPONSE
238
+ assert !parser.unchanged?(@klass.new(part(<<-RESPONSE, @host)))
239
+ Domain: weppos.it
240
+ Status: AVAILABLE
241
+ RESPONSE
242
+ end
243
+
244
+
245
+ protected
246
+
247
+ def load_part(path)
248
+ part(File.read(TESTCASE_PATH + path), @host)
249
+ end
250
+
251
+ def part(*args)
252
+ Whois::Answer::Part.new(*args)
253
+ end
254
+
255
+ end