2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2015-03-22 12:23:05 +00:00
|
|
|
require 'integration_test_helper'
|
|
|
|
|
|
|
|
class GeoIpTest < ActiveSupport::TestCase
|
|
|
|
|
|
|
|
# check
|
|
|
|
test 'check some results' do
|
|
|
|
|
2016-04-26 10:49:36 +00:00
|
|
|
result = Service::GeoIp.location('127.0.0.0.1')
|
2015-03-22 12:23:05 +00:00
|
|
|
assert(result)
|
2020-05-26 11:44:46 +00:00
|
|
|
assert_nil(result['country_name'])
|
|
|
|
assert_nil(result['city_name'])
|
|
|
|
assert_nil(result['country_code'])
|
|
|
|
assert_nil(result['continent_code'])
|
|
|
|
assert_nil(result['latitude'])
|
|
|
|
assert_nil(result['longitude'])
|
2015-03-22 12:23:05 +00:00
|
|
|
|
2016-04-26 10:49:36 +00:00
|
|
|
result = Service::GeoIp.location('127.0.0.1')
|
2015-09-22 14:48:43 +00:00
|
|
|
assert(result)
|
2020-05-26 11:44:46 +00:00
|
|
|
assert_nil(result['country_name'])
|
|
|
|
assert_nil(result['city_name'])
|
|
|
|
assert_nil(result['country_code'])
|
|
|
|
assert_nil(result['continent_code'])
|
|
|
|
assert_nil(result['latitude'])
|
|
|
|
assert_nil(result['longitude'])
|
2015-09-22 14:48:43 +00:00
|
|
|
|
2016-04-26 10:49:36 +00:00
|
|
|
result = Service::GeoIp.location('195.65.29.254')
|
2015-03-22 12:23:05 +00:00
|
|
|
assert(result)
|
|
|
|
assert_equal('Switzerland', result['country_name'])
|
2022-05-25 08:28:22 +00:00
|
|
|
assert_equal('Effretikon / Watt', result['city_name'])
|
2015-03-22 12:23:05 +00:00
|
|
|
assert_equal('CH', result['country_code'])
|
|
|
|
assert_equal('EU', result['continent_code'])
|
2022-05-25 08:28:22 +00:00
|
|
|
assert_equal(47.4288, result['latitude'])
|
|
|
|
assert_equal(8.7025, result['longitude'])
|
2015-03-22 12:23:05 +00:00
|
|
|
|
2016-04-26 10:49:36 +00:00
|
|
|
result = Service::GeoIp.location('134.109.140.74')
|
2015-03-22 12:23:05 +00:00
|
|
|
assert(result)
|
|
|
|
assert_equal('Germany', result['country_name'])
|
|
|
|
assert_equal('Chemnitz', result['city_name'])
|
|
|
|
assert_equal('DE', result['country_code'])
|
|
|
|
assert_equal('EU', result['continent_code'])
|
2022-01-17 07:43:38 +00:00
|
|
|
assert_equal(50.8191, result['latitude'])
|
|
|
|
assert_equal(12.9419, result['longitude'])
|
2015-03-22 12:23:05 +00:00
|
|
|
|
2016-04-26 10:49:36 +00:00
|
|
|
result = Service::GeoIp.location('46.253.55.170')
|
2015-03-22 12:23:05 +00:00
|
|
|
assert(result)
|
|
|
|
assert_equal('Germany', result['country_name'])
|
|
|
|
assert_equal('Halle', result['city_name'])
|
|
|
|
assert_equal('DE', result['country_code'])
|
|
|
|
assert_equal('EU', result['continent_code'])
|
2022-05-25 08:28:22 +00:00
|
|
|
assert_equal(51.5036, result['latitude'])
|
|
|
|
assert_equal(11.9594, result['longitude'])
|
2015-03-22 12:23:05 +00:00
|
|
|
|
2016-04-26 10:49:36 +00:00
|
|
|
result = Service::GeoIp.location('169.229.216.200')
|
2015-03-22 12:23:05 +00:00
|
|
|
assert(result)
|
|
|
|
assert_equal('United States', result['country_name'])
|
2022-01-17 07:43:38 +00:00
|
|
|
assert_equal('Oakland', result['city_name'])
|
2015-03-22 12:23:05 +00:00
|
|
|
assert_equal('US', result['country_code'])
|
|
|
|
assert_equal('NA', result['continent_code'])
|
2022-05-25 08:28:22 +00:00
|
|
|
assert_equal(37.7428, result['latitude'])
|
|
|
|
assert_equal(-122.1745, result['longitude'])
|
2015-03-22 12:23:05 +00:00
|
|
|
end
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|