Skip to content

Commit 5bec3c7

Browse files
committed
Use HTTPS by default.
1 parent 9862947 commit 5bec3c7

12 files changed

Lines changed: 19 additions & 15 deletions

lib/geocoder/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def set_defaults
107107
@data[:ip_lookup] = :ipinfo_io # name of IP address geocoding service (symbol)
108108
@data[:language] = :en # ISO-639 language code
109109
@data[:http_headers] = {} # HTTP headers for lookup
110-
@data[:use_https] = false # use HTTPS for lookup requests? (if supported)
110+
@data[:use_https] = true # use HTTPS for lookup requests? (if supported)
111111
@data[:http_proxy] = nil # HTTP proxy server (user:pass@host:port)
112112
@data[:https_proxy] = nil # HTTPS proxy server (user:pass@host:port)
113113
@data[:api_key] = nil # API key for geocoding service

test/unit/cache_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def teardown
1515
end
1616

1717
def test_second_occurrence_of_request_is_cache_hit
18+
Geocoder.configure(:use_https => false)
1819
Geocoder.configure(:cache => {})
1920
Geocoder::Lookup.all_services_except_test.each do |l|
2021
next if

test/unit/lookups/db_ip_com_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_free_host_config
4646
configure_for_free_api_access
4747
lookup = Geocoder::Lookup::DbIpCom.new
4848
query = Geocoder::Query.new('23.255.240.0')
49-
assert_match 'http://api.db-ip.com/v2/MY_API_KEY/23.255.240.0', lookup.query_url(query)
49+
assert_match 'https://api.db-ip.com/v2/MY_API_KEY/23.255.240.0', lookup.query_url(query)
5050
end
5151

5252
def test_paid_host_config

test/unit/lookups/geoportail_lu_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ def test_query_for_geocode
1212
query = Geocoder::Query.new('55 route de luxembourg, pontpierre')
1313
lookup = Geocoder::Lookup.get(:geoportail_lu)
1414
res = lookup.query_url(query)
15-
assert_equal 'http://api.geoportail.lu/geocoder/search?queryString=55+route+de+luxembourg%2C+pontpierre', res
15+
assert_equal 'https://api.geoportail.lu/geocoder/search?queryString=55+route+de+luxembourg%2C+pontpierre', res
1616
end
1717

1818
def test_query_for_reverse_geocode
1919
query = Geocoder::Query.new([45.423733, -75.676333])
2020
lookup = Geocoder::Lookup.get(:geoportail_lu)
2121
res = lookup.query_url(query)
22-
assert_equal 'http://api.geoportail.lu/geocoder/reverseGeocode?lat=45.423733&lon=-75.676333', res
22+
assert_equal 'https://api.geoportail.lu/geocoder/reverseGeocode?lat=45.423733&lon=-75.676333', res
2323
end
2424

2525
def test_results_component

test/unit/lookups/ip2location_io_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def setup
1111

1212
def test_ip2location_io_query_url
1313
query = Geocoder::Query.new('8.8.8.8')
14-
assert_equal 'http://api.ip2location.io/?ip=8.8.8.8&key=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', query.url
14+
assert_equal 'https://api.ip2location.io/?ip=8.8.8.8&key=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', query.url
1515
end
1616

1717
def test_ip2location_io_lookup_address

test/unit/lookups/ip2location_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ def setup
1111

1212
def test_ip2location_query_url
1313
query = Geocoder::Query.new('8.8.8.8')
14-
assert_equal 'http://api.ip2location.com/v2/?ip=8.8.8.8&key=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', query.url
14+
assert_equal 'https://api.ip2location.com/v2/?ip=8.8.8.8&key=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', query.url
1515
end
1616

1717
def test_ip2location_query_url_with_package
1818
Geocoder.configure(ip2location: {package: 'WS3'})
1919
query = Geocoder::Query.new('8.8.8.8')
20-
assert_equal 'http://api.ip2location.com/v2/?ip=8.8.8.8&key=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&package=WS3', query.url
20+
assert_equal 'https://api.ip2location.com/v2/?ip=8.8.8.8&key=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&package=WS3', query.url
2121
end
2222

2323
def test_ip2location_lookup_address

test/unit/lookups/ipapi_com_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_api_key
6969
def test_url_with_api_key_and_fields
7070
Geocoder.configure(:api_key => "MY_KEY", :ipapi_com => {:fields => "lat,lon,xyz"})
7171
g = Geocoder::Lookup::IpapiCom.new
72-
assert_equal "http://pro.ip-api.com/json/74.200.247.59?fields=lat%2Clon%2Cxyz&key=MY_KEY", g.query_url(Geocoder::Query.new("74.200.247.59"))
72+
assert_equal "https://pro.ip-api.com/json/74.200.247.59?fields=lat%2Clon%2Cxyz&key=MY_KEY", g.query_url(Geocoder::Query.new("74.200.247.59"))
7373
end
7474

7575
def test_url_with_fields

test/unit/lookups/ipstack_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_localhost_private
124124

125125
def test_api_request_adds_access_key
126126
lookup = Geocoder::Lookup.get(:ipstack)
127-
assert_match 'http://api.ipstack.com/74.200.247.59?access_key=123', lookup.query_url(Geocoder::Query.new("74.200.247.59"))
127+
assert_match 'https://api.ipstack.com/74.200.247.59?access_key=123', lookup.query_url(Geocoder::Query.new("74.200.247.59"))
128128
end
129129

130130
def test_api_request_adds_security_when_specified
@@ -177,7 +177,7 @@ def test_uses_lookup_specific_configuration
177177
Geocoder.configure(api_key: '123', ip_lookup: :ipstack, logger: @logger, ipstack: { api_key: '345'})
178178

179179
lookup = Geocoder::Lookup.get(:ipstack)
180-
assert_match 'http://api.ipstack.com/74.200.247.59?access_key=345', lookup.query_url(Geocoder::Query.new("74.200.247.59"))
180+
assert_match 'https://api.ipstack.com/74.200.247.59?access_key=345', lookup.query_url(Geocoder::Query.new("74.200.247.59"))
181181
end
182182

183183
def test_not_authorized lookup = Geocoder::Lookup.get(:ipstack)

test/unit/lookups/mapquest_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ def setup
1212
def test_url_contains_api_key
1313
Geocoder.configure(mapquest: {api_key: "abc123"})
1414
query = Geocoder::Query.new("Bluffton, SC")
15-
assert_equal "http://www.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC", query.url
15+
assert_equal "https://www.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC", query.url
1616
end
1717

1818
def test_url_for_open_street_maps
1919
Geocoder.configure(mapquest: {api_key: "abc123", open: true})
2020
query = Geocoder::Query.new("Bluffton, SC")
21-
assert_equal "http://open.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC", query.url
21+
assert_equal "https://open.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC", query.url
2222
end
2323

2424
def test_result_components

test/unit/lookups/pelias_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ def setup
1010

1111
def test_configure_default_endpoint
1212
query = Geocoder::Query.new('Madison Square Garden, New York, NY')
13-
assert_true query.url.start_with?('http://localhost/v1/search'), query.url
13+
assert_true query.url.start_with?('https://localhost/v1/search'), query.url
1414
end
1515

1616
def test_configure_custom_endpoint
1717
Geocoder.configure(lookup: :pelias, api_key: 'abc123', pelias: {endpoint: 'self.hosted.pelias/proxy'})
1818
query = Geocoder::Query.new('Madison Square Garden, New York, NY')
19-
assert_true query.url.start_with?('http://self.hosted.pelias/proxy/v1/search'), query.url
19+
assert_true query.url.start_with?('https://self.hosted.pelias/proxy/v1/search'), query.url
2020
end
2121

2222
def test_query_for_reverse_geocode

0 commit comments

Comments
 (0)