Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit 033e277

Browse files
author
Andy Newton
committed
added mocks for domains
1 parent a7eb3c9 commit 033e277

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

lib/nicinfo/domain.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def NicInfo.display_domain json_data, config, data_node
3232
end
3333
respObjs = ResponseObjSet.new config
3434
obj_array.each do |array_object|
35-
domain = Domain.new( config ).process( array_object )
35+
domain = config.factory.new_domain.process( array_object )
3636
root = domain.to_node
3737
data_node.add_root( root )
3838
if !domain.entities.empty? or !domain.nameservers.empty?
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
HTTP/1.1 200 OK
2+
Server: nginx
3+
Date: Wed, 20 Dec 2017 00:12:03 GMT
4+
Content-Type: application/rdap+json;charset=ISO-8859-1
5+
Content-Length: 3939
6+
Connection: keep-alive
7+
Set-Cookie: JSESSIONID=15726A3E6D1183A830C53EF99252F30C; Path=/; Secure; HttpOnly
8+
X-Frame-Options: DENY
9+
Strict-Transport-Security: max-age=15768000
10+
11+
{"objectClassName":"domain","port43":"whois.verisign-grs.com","notices":[{"description":["Service subject to Terms of Use."],"links":[{"href":"http:\/\/rdap-pilot.verisignlabs.com\/terms_of_use","type":"text\/html"}],"title":"Terms of Use"}],"nameservers":[{"objectClassName":"nameserver","port43":"whois.verisign-grs.com","handle":"140954367~VRSN","ipAddresses":{"v6":["2001:500:A9:0:0:0:0:108"],"v4":["199.5.26.108"]},"links":[{"rel":"self","href":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/nameserver\/NS3.ARIN.NET","type":"application\/rdap+json","value":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/nameserver\/NS3.ARIN.NET"}],"lang":"en-US","events":[{"eventAction":"registration","eventDate":"2015-09-29T13:56:25Z"},{"eventAction":"last changed","eventDate":"2015-09-29T13:56:25Z"}],"ldhName":"NS3.ARIN.NET","status":["active"]},{"objectClassName":"nameserver","port43":"whois.verisign-grs.com","handle":"88900117~VRSN","ipAddresses":{"v6":["2001:500:14:6050:AD:0:0:1"],"v4":["204.61.216.50"]},"links":[{"rel":"self","href":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/nameserver\/U.ARIN.NET","type":"application\/rdap+json","value":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/nameserver\/U.ARIN.NET"}],"lang":"en-US","events":[{"eventAction":"registration","eventDate":"2011-09-09T13:00:57Z"},{"eventAction":"last changed","eventDate":"2014-06-13T18:33:47Z"}],"ldhName":"U.ARIN.NET","status":["active"]},{"objectClassName":"nameserver","port43":"whois.verisign-grs.com","handle":"60625642~VRSN","ipAddresses":{"v6":["2001:500:31:0:0:0:0:108"],"v4":["199.71.0.108"]},"links":[{"rel":"self","href":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/nameserver\/NS2.ARIN.NET","type":"application\/rdap+json","value":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/nameserver\/NS2.ARIN.NET"}],"lang":"en-US","events":[{"eventAction":"registration","eventDate":"2007-10-09T12:45:17Z"},{"eventAction":"last changed","eventDate":"2014-06-13T18:33:47Z"}],"ldhName":"NS2.ARIN.NET","status":["active"]},{"objectClassName":"nameserver","port43":"whois.verisign-grs.com","handle":"60625639~VRSN","ipAddresses":{"v6":["2001:500:13:0:0:0:0:108"],"v4":["199.212.0.108"]},"links":[{"rel":"self","href":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/nameserver\/NS1.ARIN.NET","type":"application\/rdap+json","value":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/nameserver\/NS1.ARIN.NET"}],"lang":"en-US","events":[{"eventAction":"registration","eventDate":"2007-10-09T12:45:17Z"},{"eventAction":"last changed","eventDate":"2014-06-13T18:33:47Z"}],"ldhName":"NS1.ARIN.NET","status":["active"]}],"entities":[{"objectClassName":"entity","port43":"whois.verisign-grs.com","publicIds":[{"identifier":"93","type":"IANA Registrar ID"}],"vcardArray":["vcard",[["version",{},"text","4.0"],["fn",{},"text","GKG.Net, Inc.~VRSN"],["adr",{"type":"work"},"text",["","","302 N. Bryan Ave.","Bryan","Texas","77803","US"]],["email",{"type":"work"},"text","routine@gkg.net"]]],"roles":["registrar"],"handle":"93~VRSN","links":[{"rel":"self","href":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/entity\/93~VRSN","type":"application\/rdap+json","value":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/entity\/93~VRSN"}],"lang":"en-US","events":[{"eventAction":"registration","eventDate":"2000-01-18T14:47:13Z"},{"eventAction":"last changed","eventDate":"2017-12-18T09:10:06Z"}]}],"rdapConformance":["rdap_level_0"],"handle":"970402~VRSN","links":[{"rel":"self","href":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/domain\/ARIN.NET","type":"application\/rdap+json","value":"https:\/\/rdap-pilot.verisignlabs.com\/rdap\/v1\/domain\/ARIN.NET"}],"lang":"en-US","events":[{"eventAction":"registration","eventDate":"1996-12-19T00:00:00Z"},{"eventAction":"last changed","eventDate":"2017-02-23T12:15:01Z"},{"eventAction":"expiration","eventDate":"2024-06-13T18:33:47Z"}],"ldhName":"arin.net","status":["client transfer prohibited"]}

spec/webmock_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,34 @@
166166
expect( config.factory).to have_received(:new_ns).once
167167
expect(a_request(:get, "https://rdap-pilot.verisignlabs.com/rdap/v1/nameserver/ns1.arin.net")).to have_been_made.once
168168
end
169+
170+
it 'should process a domain lookup' do
171+
response = File.new( "spec/recorded_responses/arin_net.txt")
172+
stub_request(:get, "https://rdap-pilot.verisignlabs.com/rdap/v1/domain/arin.net").to_return(response)
173+
174+
dir = File.join( @work_dir, "test_lookup_ns1_arin_net_200" )
175+
logger = NicInfo::Logger.new
176+
logger.data_out = StringIO.new
177+
logger.message_out = StringIO.new
178+
logger.message_level = NicInfo::MessageLevel::NO_MESSAGES
179+
config = NicInfo::Config.new( dir )
180+
config.logger=logger
181+
config.config[ NicInfo::BOOTSTRAP ][ NicInfo::UPDATE_BSFILES ]=false
182+
183+
args = [ "arin.net" ]
184+
185+
allow( config.factory ).to receive(:new_error_code).and_call_original
186+
allow( config.factory ).to receive(:new_notices).and_call_original
187+
allow( config.factory ).to receive(:new_entity).and_call_original
188+
allow( config.factory ).to receive(:new_ns).and_call_original
189+
allow( config.factory ).to receive(:new_domain).and_call_original
190+
expect{ NicInfo::Main.new( args, config ).run }.to_not output.to_stdout
191+
expect( config.factory).to_not have_received(:new_error_code)
192+
expect( config.factory).to have_received(:new_notices).once
193+
expect( config.factory).to have_received(:new_entity).once
194+
expect( config.factory).to have_received(:new_ns).exactly( 4 ).times
195+
expect( config.factory).to have_received(:new_domain).once
196+
expect(a_request(:get, "https://rdap-pilot.verisignlabs.com/rdap/v1/domain/arin.net")).to have_been_made.once
197+
end
198+
169199
end

0 commit comments

Comments
 (0)