-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from ipinfo/saad/support-for-ipv6-host
Support for IPv6 Host
- Loading branch information
Showing
5 changed files
with
102 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module IPinfo | ||
VERSION = '2.1.0' | ||
VERSION = '2.2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,6 @@ class IPinfoTest < Minitest::Test | |
TEST_IPV4 = '8.8.8.8' | ||
TEST_IPV6 = '2601:9:7680:363:75df:f491:6f85:352f' | ||
|
||
def test_that_it_has_a_version_number | ||
refute_nil ::IPinfo::VERSION | ||
end | ||
|
||
def test_set_adapter | ||
ipinfo = IPinfo.create( | ||
ENV['IPINFO_TOKEN'], | ||
{ http_client: :excon } | ||
) | ||
|
||
assert(ipinfo.httpc = :excon) | ||
end | ||
|
||
def assert_ip6(resp) | ||
assert_equal(resp.ip, TEST_IPV6) | ||
assert_equal(resp.ip_address, IPAddr.new(TEST_IPV6)) | ||
|
@@ -48,7 +35,7 @@ def assert_ip6(resp) | |
{ | ||
"name": 'Comcast Cable Communications, LLC', | ||
"domain": 'comcast.com', | ||
"type": '' | ||
"type": 'isp' | ||
} | ||
) | ||
assert_equal( | ||
|
@@ -84,16 +71,6 @@ def assert_ip6(resp) | |
) | ||
end | ||
|
||
def test_lookup_ip6 | ||
ipinfo = IPinfo.create(ENV['IPINFO_TOKEN']) | ||
|
||
# multiple checks for cache | ||
(0...5).each do |_| | ||
resp = ipinfo.details(TEST_IPV6) | ||
assert_ip6(resp) | ||
end | ||
end | ||
|
||
def assert_ip4(resp) | ||
assert_equal(resp.ip, TEST_IPV4) | ||
assert_equal(resp.ip_address, IPAddr.new(TEST_IPV4)) | ||
|
@@ -149,7 +126,7 @@ def assert_ip4(resp) | |
resp.abuse, | ||
{ | ||
"address": 'US, CA, Mountain View, ' \ | ||
'1600 Amphitheatre Parkway, 94043', | ||
'1600 Amphitheatre Parkway, 94043', | ||
"country": 'US', | ||
"email": '[email protected]', | ||
"name": 'Abuse', | ||
|
@@ -162,6 +139,40 @@ def assert_ip4(resp) | |
refute_nil(resp.domains[:domains]) | ||
end | ||
|
||
def test_that_it_has_a_version_number | ||
refute_nil ::IPinfo::VERSION | ||
end | ||
|
||
def test_set_adapter_v4 | ||
ipinfo = IPinfo.create( | ||
ENV['IPINFO_TOKEN'], | ||
{ http_client: :excon } | ||
) | ||
|
||
assert(ipinfo.httpc = :excon) | ||
end | ||
|
||
def test_lookup_ip6 | ||
ipinfo = IPinfo.create(ENV['IPINFO_TOKEN']) | ||
|
||
# multiple checks for cache | ||
(0...5).each do |_| | ||
resp = ipinfo.details(TEST_IPV6) | ||
assert_ip6(resp) | ||
end | ||
end | ||
|
||
# # Requires IPv6 support | ||
# def test_lookup_ip6_on_host_v6 | ||
# ipinfo = IPinfo.create(ENV['IPINFO_TOKEN']) | ||
|
||
# # multiple checks for cache | ||
# (0...5).each do |_| | ||
# resp = ipinfo.details_v6(TEST_IPV6) | ||
# assert_ip6(resp) | ||
# end | ||
# end | ||
|
||
def test_lookup_ip4 | ||
ipinfo = IPinfo.create(ENV['IPINFO_TOKEN']) | ||
|
||
|
@@ -171,4 +182,15 @@ def test_lookup_ip4 | |
assert_ip4(resp) | ||
end | ||
end | ||
|
||
# # Requires IPv6 support | ||
# def test_lookup_ip4_on_host_v6 | ||
# ipinfo = IPinfo.create(ENV['IPINFO_TOKEN']) | ||
|
||
# # multiple checks for cache | ||
# (0...5).each do |_| | ||
# resp = ipinfo.details_v6(TEST_IPV4) | ||
# assert_ip4(resp) | ||
# end | ||
# end | ||
end |