|
| 1 | +require File.expand_path(File.dirname(__FILE__) + '/spec_helper') |
| 2 | + |
| 3 | +describe "Ip2proxy" do |
| 4 | + it "work correctly with invalid ip" do |
| 5 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 6 | + record = i2p.get_all('1.0.0.x') |
| 7 | + expect(record['country_short']).to eq 'INVALID IP ADDRESS' |
| 8 | + end |
| 9 | + |
| 10 | + it "work correctly with get_all ipv4" do |
| 11 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 12 | + record = i2p.get_all('1.0.0.8') |
| 13 | + expect(record['country_short']).to eq 'US' |
| 14 | + end |
| 15 | + |
| 16 | + it "work correctly with get_country_short" do |
| 17 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 18 | + record = i2p.get_country_short('1.0.0.8') |
| 19 | + expect(record).to eq 'US' |
| 20 | + end |
| 21 | + |
| 22 | + it "work correctly with get_country_long" do |
| 23 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 24 | + record = i2p.get_country_long('1.0.0.8') |
| 25 | + expect(record).to eq 'United States of America' |
| 26 | + end |
| 27 | + |
| 28 | + it "work correctly with get_region" do |
| 29 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 30 | + record = i2p.get_region('1.0.0.8') |
| 31 | + expect(record).to eq 'California' |
| 32 | + end |
| 33 | + |
| 34 | + it "work correctly with get_city" do |
| 35 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 36 | + record = i2p.get_city('1.0.0.8') |
| 37 | + expect(record).to eq 'Los Angeles' |
| 38 | + end |
| 39 | + |
| 40 | + it "work correctly with get_isp" do |
| 41 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 42 | + record = i2p.get_isp('1.0.0.8') |
| 43 | + expect(record).to eq 'APNIC and CloudFlare DNS Resolver Project' |
| 44 | + end |
| 45 | + |
| 46 | + it "work correctly with get_domain" do |
| 47 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 48 | + record = i2p.get_domain('1.0.0.8') |
| 49 | + expect(record).to eq 'cloudflare.com' |
| 50 | + end |
| 51 | + |
| 52 | + it "work correctly with get_usagetype" do |
| 53 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 54 | + record = i2p.get_usagetype('1.0.0.8') |
| 55 | + expect(record).to eq 'CDN' |
| 56 | + end |
| 57 | + |
| 58 | + it "work correctly with get_asn" do |
| 59 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 60 | + record = i2p.get_asn('1.0.0.8') |
| 61 | + expect(record).to eq '13335' |
| 62 | + end |
| 63 | + |
| 64 | + it "work correctly with get_as" do |
| 65 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 66 | + record = i2p.get_as('1.0.0.8') |
| 67 | + expect(record).to eq 'CLOUDFLARENET' |
| 68 | + end |
| 69 | + |
| 70 | + it "work correctly with get_last_seen" do |
| 71 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 72 | + record = i2p.get_last_seen('1.0.0.8') |
| 73 | + expect(record).to eq '22' |
| 74 | + end |
| 75 | + |
| 76 | + it "work correctly with get_threat" do |
| 77 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 78 | + record = i2p.get_threat('1.0.0.8') |
| 79 | + expect(record).to eq '-' |
| 80 | + end |
| 81 | + |
| 82 | + it "work correctly with is_proxy" do |
| 83 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 84 | + record = i2p.is_proxy('1.0.0.8') |
| 85 | + expect(record).to eq 2 |
| 86 | + end |
| 87 | + |
| 88 | + it "work correctly with get_proxytype" do |
| 89 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 90 | + record = i2p.get_proxytype('1.0.0.8') |
| 91 | + expect(record).to eq 'DCH' |
| 92 | + end |
| 93 | + |
| 94 | + it "work correctly with get_all ipv6" do |
| 95 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 96 | + record = i2p.get_all('2c0f:ffa0::4') |
| 97 | + expect(record['country_short']).to eq 'UG' |
| 98 | + end |
| 99 | + |
| 100 | + it "work correctly with get_module_version" do |
| 101 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 102 | + record = i2p.get_module_version() |
| 103 | + expect(record).to eq '3.0.1' |
| 104 | + end |
| 105 | + |
| 106 | + it "work correctly with get_package_version" do |
| 107 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 108 | + record = i2p.get_package_version() |
| 109 | + expect(record).to eq '10' |
| 110 | + end |
| 111 | + |
| 112 | + it "work correctly with get_database_version" do |
| 113 | + i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX10.SAMPLE.BIN") |
| 114 | + record = i2p.get_database_version() |
| 115 | + expect(record).to eq '2020.10.23' |
| 116 | + end |
| 117 | +end |
0 commit comments