mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
catch invalid uri
if URI.parse does not result in a host we don't continue and raise an error
This commit is contained in:
parent
06a0c77fc1
commit
40a95259c8
2 changed files with 15 additions and 4 deletions
|
@ -153,6 +153,8 @@ module Fog
|
||||||
request :monitor_instances
|
request :monitor_instances
|
||||||
request :unmonitor_instances
|
request :unmonitor_instances
|
||||||
|
|
||||||
|
class InvalidURIError < Exception; end
|
||||||
|
|
||||||
# deprecation
|
# deprecation
|
||||||
class Real
|
class Real
|
||||||
def modify_image_attributes(*params)
|
def modify_image_attributes(*params)
|
||||||
|
@ -297,7 +299,7 @@ module Fog
|
||||||
|
|
||||||
if @endpoint = options[:endpoint]
|
if @endpoint = options[:endpoint]
|
||||||
endpoint = URI.parse(@endpoint)
|
endpoint = URI.parse(@endpoint)
|
||||||
@host = endpoint.host
|
@host = endpoint.host or raise InvalidURIError.new("could not parse endpoint: #{@endpoint}")
|
||||||
@path = endpoint.path
|
@path = endpoint.path
|
||||||
@port = endpoint.port
|
@port = endpoint.port
|
||||||
@scheme = endpoint.scheme
|
@scheme = endpoint.scheme
|
||||||
|
@ -308,7 +310,6 @@ module Fog
|
||||||
@port = options[:port] || 443
|
@port = options[:port] || 443
|
||||||
@scheme = options[:scheme] || 'https'
|
@scheme = options[:scheme] || 'https'
|
||||||
end
|
end
|
||||||
|
|
||||||
validate_aws_region(@host, @region)
|
validate_aws_region(@host, @region)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -460,7 +461,7 @@ module Fog
|
||||||
|
|
||||||
if @endpoint = options[:endpoint]
|
if @endpoint = options[:endpoint]
|
||||||
endpoint = URI.parse(@endpoint)
|
endpoint = URI.parse(@endpoint)
|
||||||
@host = endpoint.host
|
@host = endpoint.host or raise InvalidURIError.new("could not parse endpoint: #{@endpoint}")
|
||||||
@path = endpoint.path
|
@path = endpoint.path
|
||||||
@port = endpoint.port
|
@port = endpoint.port
|
||||||
@scheme = endpoint.scheme
|
@scheme = endpoint.scheme
|
||||||
|
|
|
@ -34,7 +34,17 @@ Shindo.tests('Fog::Compute[:aws] | region requests', ['aws']) do
|
||||||
:aws_secret_access_key => 'dummysecret',
|
:aws_secret_access_key => 'dummysecret',
|
||||||
:aws_session_token => 'dummytoken',
|
:aws_session_token => 'dummytoken',
|
||||||
:region => 'world-antarctica-1',
|
:region => 'world-antarctica-1',
|
||||||
:endpoint => 'aws-clone.example'}).describe_regions.body
|
:endpoint => 'http://aws-clone.example'}).describe_regions.body
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#invalid_endpoint") do
|
||||||
|
raises(Fog::Compute::AWS::InvalidURIError) do
|
||||||
|
Fog::Compute::AWS.new({:aws_access_key_id => 'dummykey',
|
||||||
|
:aws_secret_access_key => 'dummysecret',
|
||||||
|
:aws_session_token => 'dummytoken',
|
||||||
|
:region => 'world-antarctica-1',
|
||||||
|
:endpoint => 'aws-clone.example'})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue