mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace] updated to normalize endpoints before detecting a standard endpoint.
This commit is contained in:
parent
f66dbe1162
commit
8fb41614f7
8 changed files with 34 additions and 6 deletions
|
@ -90,6 +90,13 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
def self.normalize_url(endpoint)
|
||||
return nil unless endpoint
|
||||
str = endpoint.chomp " "
|
||||
str = str.chomp "/"
|
||||
str.downcase
|
||||
end
|
||||
|
||||
# CGI.escape, but without special treatment on spaces
|
||||
def self.escape(str,extra_exclude_chars = '')
|
||||
str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do
|
||||
|
|
|
@ -136,7 +136,7 @@ module Fog
|
|||
private
|
||||
|
||||
def setup_custom_endpoint(options)
|
||||
@rackspace_endpoint = options[:rackspace_block_storage_url] || options[:rackspace_endpoint]
|
||||
@rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_block_storage_url] || options[:rackspace_endpoint])
|
||||
|
||||
if v2_authentication?
|
||||
case @rackspace_endpoint
|
||||
|
|
|
@ -188,7 +188,7 @@ module Fog
|
|||
@rackspace_auth_url = options[:rackspace_auth_url]
|
||||
@rackspace_servicenet = options[:rackspace_servicenet]
|
||||
@rackspace_auth_token = options[:rackspace_auth_token]
|
||||
@rackspace_endpoint = options[:rackspace_compute_v1_url] || options[:rackspace_management_url]
|
||||
@rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_compute_v1_url] || options[:rackspace_management_url])
|
||||
@rackspace_must_reauthenticate = false
|
||||
@connection_options = options[:connection_options] || {}
|
||||
authenticate
|
||||
|
|
|
@ -168,7 +168,7 @@ module Fog
|
|||
private
|
||||
|
||||
def setup_custom_endpoint(options)
|
||||
@rackspace_endpoint = options[:rackspace_compute_url] || options[:rackspace_endpoint]
|
||||
@rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_compute_url] || options[:rackspace_endpoint])
|
||||
|
||||
if v2_authentication?
|
||||
case @rackspace_endpoint
|
||||
|
|
|
@ -127,7 +127,7 @@ module Fog
|
|||
private
|
||||
|
||||
def setup_custom_endpoint(options)
|
||||
@rackspace_endpoint = options[:rackspace_database_url] || options[:rackspace_endpoint]
|
||||
@rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_database_url] || options[:rackspace_endpoint])
|
||||
|
||||
if v2_authentication?
|
||||
case @rackspace_endpoint
|
||||
|
|
|
@ -87,7 +87,7 @@ module Fog
|
|||
@rackspace_username = options[:rackspace_username]
|
||||
@rackspace_auth_url = options[:rackspace_auth_url]
|
||||
@connection_options = options[:connection_options] || {}
|
||||
@rackspace_endpoint = options[:rackspace_dns_url] || options[:rackspace_dns_endpoint]
|
||||
@rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_dns_url] || options[:rackspace_dns_endpoint])
|
||||
@rackspace_region = options[:rackspace_region]
|
||||
|
||||
authenticate
|
||||
|
|
|
@ -169,7 +169,7 @@ module Fog
|
|||
private
|
||||
|
||||
def setup_custom_endpoint(options)
|
||||
@rackspace_endpoint = options[:rackspace_load_balancers_url] || options[:rackspace_lb_endpoint]
|
||||
@rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_load_balancers_url] || options[:rackspace_lb_endpoint])
|
||||
|
||||
if v2_authentication?
|
||||
case @rackspace_endpoint
|
||||
|
|
21
tests/rackspace/rackspace_tests.rb
Normal file
21
tests/rackspace/rackspace_tests.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
Shindo.tests('Fog::Rackspace', ['rackspace']) do
|
||||
|
||||
tests('normalize_url') do
|
||||
tests('should return nil if endpoint is nil').returns(nil) do
|
||||
Fog::Rackspace.normalize_url nil
|
||||
end
|
||||
tests('should remove trailing spaces').returns("https://dfw.blockstorage.api.rackspacecloud.com/v1") do
|
||||
Fog::Rackspace.normalize_url "https://dfw.blockstorage.api.rackspacecloud.com/v1 "
|
||||
end
|
||||
tests('should remove trailing /').returns("https://dfw.blockstorage.api.rackspacecloud.com/v1") do
|
||||
Fog::Rackspace.normalize_url "https://dfw.blockstorage.api.rackspacecloud.com/v1/"
|
||||
end
|
||||
tests('should downcase url').returns("https://dfw.blockstorage.api.rackspacecloud.com/v1") do
|
||||
Fog::Rackspace.normalize_url "HTTPS://DFW.BLOCKSTORAGE.API.RACKSPACECLOUD.COM/V1"
|
||||
end
|
||||
tests('show do all three').returns("https://dfw.blockstorage.api.rackspacecloud.com/v1") do
|
||||
Fog::Rackspace.normalize_url "HTTPS://DFW.BLOCKSTORAGE.API.RACKSPACECLOUD.COM/V1/ "
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue