hexillion 1.2.0 → 1.3.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +5 -0
- data/hexillion.gemspec +5 -6
- data/lib/hexillion.rb +84 -65
- data/lib/hexillion/version.rb +1 -1
- data/spec/client_spec.rb +48 -49
- data/spec/spec_helper.rb +3 -1
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e8cfd9597be0f53d98aa7a46153a7ed32a1f66d
|
4
|
+
data.tar.gz: 5b64a7a7bebd0b67f082c3d19d9ffa2e689b995c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f8f4e9d592aae5b187a176aa637decbb211fc555d1d22b2cc3998adb45b2f77f04b221da0fc5e4065a18a464496287c983754d9f0d23ea020ee76f7186cdd4f
|
7
|
+
data.tar.gz: 9a17946de7e3c0eb7f5fe10f71a04db3aafcca1534878588cd0b06fbe5912a069f667826fa23a0037991dc11c069f61c9a2802f4c931a3fc8fae01a1167095e3
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/hexillion.gemspec
CHANGED
@@ -2,16 +2,15 @@
|
|
2
2
|
require File.expand_path('../lib/hexillion/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["
|
6
|
-
gem.email = ["
|
5
|
+
gem.authors = ["Flippa Developers"]
|
6
|
+
gem.email = ["developers@flippa.com"]
|
7
7
|
gem.description = %q{Hexillion WhoIs API Client for Ruby}
|
8
8
|
gem.summary = %q{Provides a simple client for the Hexillion API}
|
9
|
-
gem.homepage = ''
|
9
|
+
gem.homepage = 'https://github.com/flippa/hexillion'
|
10
10
|
|
11
|
-
gem.add_dependency "
|
12
|
-
gem.add_dependency "nokogiri", ">= 1.5"
|
11
|
+
gem.add_dependency "nokogiri", ">= 1.5"
|
13
12
|
|
14
|
-
gem.add_development_dependency "rspec", "~>
|
13
|
+
gem.add_development_dependency "rspec", "~> 3.6"
|
15
14
|
gem.add_development_dependency "rake"
|
16
15
|
|
17
16
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
data/lib/hexillion.rb
CHANGED
@@ -1,99 +1,118 @@
|
|
1
1
|
require 'date'
|
2
|
-
require '
|
2
|
+
require 'net/http'
|
3
3
|
require 'nokogiri'
|
4
|
+
require 'openssl'
|
5
|
+
require 'uri'
|
4
6
|
|
5
7
|
module Hexillion
|
6
8
|
class Client
|
9
|
+
AUTH_ENDPOINT = "https://hexillion.com/rf/xml/1.0/auth/".freeze
|
10
|
+
DATA_ENDPOINT = "http://hexillion.com/rf/xml/1.0/whois/".freeze
|
11
|
+
|
7
12
|
def initialize(options)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@session_key = doc.at_css('SessionKey').content
|
12
|
-
rescue
|
13
|
-
raise "Authentication failed"
|
14
|
-
end
|
13
|
+
@session_key = fetch_session_key(options)
|
14
|
+
rescue
|
15
|
+
raise "Authentication failed"
|
15
16
|
end
|
16
17
|
|
17
18
|
# Query the API for a given domain
|
18
19
|
#
|
19
20
|
# @example
|
20
|
-
# client.whois('flippa.com', {optional_param: value, ...})
|
21
|
+
# client.whois('flippa.com', {optional_param: value, ...})
|
21
22
|
#
|
22
23
|
#
|
23
24
|
|
24
25
|
def whois(domain, extra_params = {})
|
25
|
-
|
26
|
-
|
26
|
+
params = {sessionkey: @session_key, query: domain}.merge(extra_params)
|
27
|
+
|
28
|
+
uri = URI(DATA_ENDPOINT)
|
29
|
+
uri.query = URI.encode_www_form(params)
|
27
30
|
|
28
|
-
response =
|
31
|
+
response = Net::HTTP.get_response(uri)
|
29
32
|
parse_xml(response.body)
|
30
33
|
end
|
31
34
|
|
32
35
|
private
|
33
36
|
|
37
|
+
def fetch_session_key(options = {})
|
38
|
+
uri = URI(AUTH_ENDPOINT)
|
39
|
+
|
40
|
+
http = Net::HTTP.new(uri.host, uri.port).tap do |http|
|
41
|
+
http.use_ssl = true
|
42
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
43
|
+
end
|
44
|
+
|
45
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
46
|
+
request.set_form_data(username: options[:username], password: options[:password])
|
47
|
+
response = http.request(request)
|
48
|
+
|
49
|
+
doc = Nokogiri::XML(response.body)
|
50
|
+
doc.at_css('SessionKey').content
|
51
|
+
end
|
52
|
+
|
34
53
|
def parse_xml(xml)
|
35
54
|
doc = Nokogiri::XML(xml)
|
36
55
|
records = doc.xpath(".//QueryResult[ErrorCode='Success' and FoundMatch='Yes']/WhoisRecord")
|
37
56
|
|
38
57
|
strings = {
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
77
|
-
:
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
58
|
+
registrant_name: "Registrant Name",
|
59
|
+
registrant_person: "Registrant Person",
|
60
|
+
registrant_handle: "Registrant Handle",
|
61
|
+
registrant_address: "Registrant Address",
|
62
|
+
registrant_city: "Registrant City",
|
63
|
+
registrant_state_province: "Registrant StateProvince",
|
64
|
+
registrant_postal_code: "Registrant PostalCode",
|
65
|
+
registrant_country: "Registrant Country",
|
66
|
+
registrant_country_code: "Registrant CountryCode",
|
67
|
+
registrant_email: "Registrant Email",
|
68
|
+
registrar_name: "Registrar Name",
|
69
|
+
registrar_whois_server: "Registrar WhoisServer",
|
70
|
+
registrar_homepage: "Registrar HomePage",
|
71
|
+
admin_contact_name: "AdminContact Name",
|
72
|
+
admin_contact_person: "AdminContact Person",
|
73
|
+
admin_contact_handle: "AdminContact Handle",
|
74
|
+
admin_contact_address: "AdminContact Address",
|
75
|
+
admin_contact_state_province: "AdminContact StateProvince",
|
76
|
+
admin_contact_postal_code: "AdminContact PostalCode",
|
77
|
+
admin_contact_country_code: "AdminContact CountryCode",
|
78
|
+
admin_contact_country: "AdminContact Country",
|
79
|
+
admin_contact_email: "AdminContact Email",
|
80
|
+
admin_contact_phone: "AdminContact Phone",
|
81
|
+
admin_contact_fax: "AdminContact Fax",
|
82
|
+
tech_contact_name: "TechContact Name",
|
83
|
+
tech_contact_person: "TechContact Person",
|
84
|
+
tech_contact_handle: "TechContact Handle",
|
85
|
+
tech_contact_address: "TechContact Address",
|
86
|
+
tech_contact_state_province: "TechContact StateProvince",
|
87
|
+
tech_contact_postal_code: "TechContact PostalCode",
|
88
|
+
tech_contact_country_code: "TechContact CountryCode",
|
89
|
+
tech_contact_country: "TechContact Country",
|
90
|
+
tech_contact_email: "TechContact Email",
|
91
|
+
tech_contact_phone: "TechContact Phone",
|
92
|
+
tech_contact_fax: "TechContact Fax",
|
93
|
+
zone_contact_name: "ZoneContact Name",
|
94
|
+
zone_contact_person: "ZoneContact Person",
|
95
|
+
zone_contact_handle: "ZoneContact Handle",
|
96
|
+
zone_contact_address: "ZoneContact Address",
|
97
|
+
zone_contact_state_province: "ZoneContact StateProvince",
|
98
|
+
zone_contact_postal_code: "ZoneContact PostalCode",
|
99
|
+
zone_contact_country_code: "ZoneContact CountryCode",
|
100
|
+
zone_contact_country: "ZoneContact Country",
|
101
|
+
zone_contact_email: "ZoneContact Email",
|
102
|
+
zone_contact_phone: "ZoneContact Phone",
|
103
|
+
zone_contact_fax: "ZoneContact Fax",
|
104
|
+
header_text: "HeaderText",
|
105
|
+
stripped_text: "StrippedText",
|
106
|
+
raw_text: "RawText",
|
88
107
|
}
|
89
108
|
|
90
109
|
dates = {
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
110
|
+
created_date: './CreatedDate',
|
111
|
+
expires_date: './ExpiresDate',
|
112
|
+
updated_date: './UpdatedDate',
|
94
113
|
}
|
95
114
|
|
96
|
-
result = { :
|
115
|
+
result = { xml_response: xml }
|
97
116
|
|
98
117
|
records.each do |record|
|
99
118
|
result[:nameservers] = record.css('Domain NameServer').map { |x| x.content unless x.content == '' }
|
data/lib/hexillion/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -10,60 +10,66 @@ AUTH_RESPONSE = '<?xml version="1.0" encoding="utf-8" ?>
|
|
10
10
|
describe Hexillion::Client do
|
11
11
|
describe '#initialize' do
|
12
12
|
it "requests a session key from Hexillion and assigns it as an instance variable" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
http = double(Net::HTTP, :'use_ssl=' => 1, :'verify_mode=' => 1)
|
14
|
+
post = double(Net::HTTP::Post, 'set_form_data' => 1)
|
15
|
+
resp = double(body: AUTH_RESPONSE)
|
16
|
+
|
17
|
+
allow(Net::HTTP).to receive(:new) { http }
|
18
|
+
allow(Net::HTTP::Post).to receive(:new) { post }
|
19
|
+
|
20
|
+
expect(http).to receive(:request).with(post).and_return(resp)
|
21
|
+
|
17
22
|
hex = Hexillion::Client.new(:username => "username", :password => "password")
|
18
|
-
hex.instance_variable_get('@session_key').
|
23
|
+
expect(hex.instance_variable_get('@session_key')).to eq('nOIANdfjL4524ynjlssasjfDFaqe4')
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
22
27
|
describe "#whois" do
|
23
28
|
before(:each) do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
allow_any_instance_of(Net::HTTP)
|
30
|
+
.to receive(:request)
|
31
|
+
.with(an_instance_of(Net::HTTP::Post))
|
32
|
+
.and_return(double(body: AUTH_RESPONSE))
|
33
|
+
|
34
|
+
@response_body = ""
|
35
|
+
|
36
|
+
allow(@response).to receive(:body) { @response_body }
|
37
|
+
allow(Net::HTTP).to receive(:get_response) { @response }
|
38
|
+
|
28
39
|
@hex = Hexillion::Client.new(:username => "username", :password => "password")
|
29
40
|
end
|
30
41
|
|
31
42
|
it "queries the API and passes all the params to the endpoint" do
|
32
43
|
domain_name = "example.com"
|
33
44
|
extra_params = {:data => "awesome", :more_data => "awesomer"}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
expect(RestClient).to receive(:get).with(*payload)
|
45
|
+
|
46
|
+
request_uri = URI([
|
47
|
+
"http://hexillion.com/rf/xml/1.0/whois/",
|
48
|
+
"?sessionkey=nOIANdfjL4524ynjlssasjfDFaqe4",
|
49
|
+
"&query=#{domain_name}",
|
50
|
+
"&data=#{extra_params[:data]}",
|
51
|
+
"&more_data=#{extra_params[:more_data]}",
|
52
|
+
].join)
|
53
|
+
|
54
|
+
expect(Net::HTTP).to receive(:get_response).with(request_uri)
|
46
55
|
@hex.whois(domain_name, extra_params)
|
47
56
|
end
|
48
57
|
|
49
58
|
it "concats multiline address fields" do
|
50
|
-
@
|
51
|
-
<<-XML
|
59
|
+
@response_body = <<-XML
|
52
60
|
<QueryResult><ErrorCode>Success</ErrorCode><FoundMatch>Yes</FoundMatch><WhoisRecord>
|
53
61
|
<Registrant>
|
54
62
|
<Address>48 Cambridge Street</Address>
|
55
63
|
<Address>Level 3</Address>
|
56
64
|
</Registrant>
|
57
65
|
</WhoisRecord></QueryResult>
|
58
|
-
|
59
|
-
end
|
66
|
+
XML
|
60
67
|
|
61
|
-
@hex.whois("example.com")[:registrant_address].
|
68
|
+
expect(@hex.whois("example.com")[:registrant_address]).to eq("48 Cambridge Street\nLevel 3")
|
62
69
|
end
|
63
70
|
|
64
71
|
it "provides the registrant email address" do
|
65
|
-
@
|
66
|
-
<<-XML
|
72
|
+
@response_body = <<-XML
|
67
73
|
<QueryResult><ErrorCode>Success</ErrorCode><FoundMatch>Yes</FoundMatch><WhoisRecord>
|
68
74
|
<Registrant>
|
69
75
|
<Address>48 Cambridge Street</Address>
|
@@ -71,30 +77,26 @@ describe Hexillion::Client do
|
|
71
77
|
<Email>me@example.com</Email>
|
72
78
|
</Registrant>
|
73
79
|
</WhoisRecord></QueryResult>
|
74
|
-
|
75
|
-
end
|
80
|
+
XML
|
76
81
|
|
77
|
-
@hex.whois("example.com")[:registrant_email].
|
82
|
+
expect(@hex.whois("example.com")[:registrant_email]).to eq("me@example.com")
|
78
83
|
end
|
79
84
|
|
80
85
|
it "returns the first email when multiple specified" do
|
81
|
-
@
|
82
|
-
<<-XML
|
86
|
+
@response_body = <<-XML
|
83
87
|
<QueryResult><ErrorCode>Success</ErrorCode><FoundMatch>Yes</FoundMatch><WhoisRecord>
|
84
88
|
<AdminContact>
|
85
89
|
<Email>john@example.com</Email>
|
86
90
|
<Email>fred@example.com</Email>
|
87
91
|
</AdminContact>
|
88
92
|
</WhoisRecord></QueryResult>
|
89
|
-
|
90
|
-
end
|
93
|
+
XML
|
91
94
|
|
92
|
-
@hex.whois("example.com")[:admin_contact_email].
|
95
|
+
expect(@hex.whois("example.com")[:admin_contact_email]).to eq("john@example.com")
|
93
96
|
end
|
94
97
|
|
95
98
|
it "makes an array of nameservers" do
|
96
|
-
@
|
97
|
-
<<-XML
|
99
|
+
@response_body = <<-XML
|
98
100
|
<QueryResult><ErrorCode>Success</ErrorCode><FoundMatch>Yes</FoundMatch><WhoisRecord>
|
99
101
|
<Domain>
|
100
102
|
<NameServer>ns1.registrar.com</NameServer>
|
@@ -102,24 +104,21 @@ describe Hexillion::Client do
|
|
102
104
|
<NameServer>ns3.registrar.com</NameServer>
|
103
105
|
</Domain>
|
104
106
|
</WhoisRecord></QueryResult>
|
105
|
-
|
106
|
-
end
|
107
|
+
XML
|
107
108
|
|
108
|
-
@hex.whois("example.com")[:nameservers].
|
109
|
+
expect(@hex.whois("example.com")[:nameservers]).to eq(['ns1.registrar.com', 'ns2.registrar.com', 'ns3.registrar.com'])
|
109
110
|
end
|
110
111
|
|
111
112
|
it "parses date fields" do
|
112
|
-
@
|
113
|
-
<<-XML
|
113
|
+
@response_body = <<-XML
|
114
114
|
<QueryResult><ErrorCode>Success</ErrorCode><FoundMatch>Yes</FoundMatch><WhoisRecord>
|
115
115
|
<CreatedDate>1999-10-04T00:00:00Z</CreatedDate>
|
116
116
|
<UpdatedDate>2010-11-25T00:00:00Z</UpdatedDate>
|
117
117
|
<ExpiresDate>2019-10-04T00:00:00Z</ExpiresDate>
|
118
118
|
</WhoisRecord></QueryResult>
|
119
|
-
|
120
|
-
end
|
119
|
+
XML
|
121
120
|
|
122
|
-
@hex.whois("example.com")[:created_date].
|
121
|
+
expect(@hex.whois("example.com")[:created_date]).to eq(DateTime::civil(1999,10,4))
|
123
122
|
end
|
124
123
|
|
125
124
|
it "returns the entire xml response as :xml_response" do
|
@@ -129,11 +128,11 @@ describe Hexillion::Client do
|
|
129
128
|
<UpdatedDate>2010-11-25T00:00:00Z</UpdatedDate>
|
130
129
|
<ExpiresDate>2019-10-04T00:00:00Z</ExpiresDate>
|
131
130
|
</WhoisRecord></QueryResult>
|
132
|
-
|
131
|
+
XML
|
133
132
|
|
134
|
-
@
|
133
|
+
@response_body = xml
|
135
134
|
|
136
|
-
@hex.whois("example.com")[:xml_response].
|
135
|
+
expect(@hex.whois("example.com")[:xml_response]).to eq(xml)
|
137
136
|
end
|
138
137
|
end
|
139
138
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexillion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Flippa Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rest-client
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.7'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.7'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: nokogiri
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +30,14 @@ dependencies:
|
|
44
30
|
requirements:
|
45
31
|
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '3.6'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
40
|
+
version: '3.6'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,7 +54,7 @@ dependencies:
|
|
68
54
|
version: '0'
|
69
55
|
description: Hexillion WhoIs API Client for Ruby
|
70
56
|
email:
|
71
|
-
-
|
57
|
+
- developers@flippa.com
|
72
58
|
executables: []
|
73
59
|
extensions: []
|
74
60
|
extra_rdoc_files: []
|
@@ -85,7 +71,7 @@ files:
|
|
85
71
|
- lib/hexillion/version.rb
|
86
72
|
- spec/client_spec.rb
|
87
73
|
- spec/spec_helper.rb
|
88
|
-
homepage:
|
74
|
+
homepage: https://github.com/flippa/hexillion
|
89
75
|
licenses: []
|
90
76
|
metadata: {}
|
91
77
|
post_install_message:
|
@@ -104,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
90
|
version: '0'
|
105
91
|
requirements: []
|
106
92
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.6.8
|
108
94
|
signing_key:
|
109
95
|
specification_version: 4
|
110
96
|
summary: Provides a simple client for the Hexillion API
|