1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[AWS | Compute] Validate region

This commit is contained in:
radekg 2014-02-11 13:53:28 +01:00
parent 4415e90610
commit acb9aed0b9
2 changed files with 15 additions and 0 deletions

View file

@ -386,6 +386,10 @@ module Fog
@instrumentor_name = options[:instrumentor_name] || 'fog.aws.compute'
@version = options[:version] || '2013-10-01'
unless ['ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2', 'sa-east-1'].include?(options[:region])
raise ArgumentError, "Unknown region: #{@region.inspect}"
end
if @endpoint = options[:endpoint]
endpoint = URI.parse(@endpoint)
@host = endpoint.host

View file

@ -18,6 +18,17 @@ Shindo.tests('Fog::Compute[:aws] | region requests', ['aws']) do
Fog::Compute[:aws].describe_regions('region-name' => 'us-east-1').body
end
tests("incorrect_region") do
raises(ArgumentError, "Incorrect region world-antarctica-1") do
Fog::Compute::AWS.new({:aws_access_key_id => 'dummykey',
:aws_secret_access_key => 'dummysecret',
:aws_session_token => 'dummytoken',
:region => "world-antarctica-1"})
end
end
end
end