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

[rackspace] updated service endpoint handling; improved service endpoint tests

This commit is contained in:
Kyle Rames 2013-03-15 16:38:33 -05:00
parent e482b706fb
commit 4cdbc4ebd0
12 changed files with 209 additions and 81 deletions

View file

@ -76,8 +76,7 @@ module Fog
@rackspace_auth_url = options[:rackspace_auth_url]
@rackspace_must_reauthenticate = false
@connection_options = options[:connection_options] || {}
@rackspace_endpoint = options[:rackspace_block_storage_url] || options[:rackspace_endpoint]
@rackspace_region = options[:rackspace_region] || :dfw
setup_custom_endpoint(options)
authenticate
@ -136,6 +135,29 @@ module Fog
private
def setup_custom_endpoint(options)
@rackspace_endpoint = options[:rackspace_block_storage_url] || options[:rackspace_endpoint]
if v2_authentication?
case @rackspace_endpoint
when DFW_ENDPOINT
@rackspace_endpoint = nil
@rackspace_region = :dfw
when ORD_ENDPOINT
@rackspace_endpoint = nil
@rackspace_region = :ord
when LON_ENDPOINT
@rackspace_endpoint = nil
@rackspace_region = :lon
else
@rackspace_region = options[:rackspace_region] || :dfw
end
else
#if we are using auth1 and the endpoint is not set, default to DFW_ENDPOINT for historical reasons
@rackspace_endpoint ||= DFW_ENDPOINT
end
end
def deprecation_warnings(options)
Fog::Logger.deprecation("The :rackspace_endpoint option is deprecated. Please use :rackspace_block_storage_url for custom endpoints") if options[:rackspace_endpoint]
@ -145,7 +167,7 @@ module Fog
end
end
def setup_endpoint(credentials)
def append_tenant_v1(credentials)
account_id = credentials['X-Server-Management-Url'].match(/.*\/([\d]+)$/)[1]
endpoint = @rackspace_endpoint || credentials['X-Server-Management-Url'] || DFW_ENDPOINT
@ -155,7 +177,7 @@ module Fog
def authenticate_v1(options)
credentials = Fog::Rackspace.authenticate(options, @connection_options)
setup_endpoint credentials
append_tenant_v1 credentials
@auth_token = credentials['X-Auth-Token']
end

View file

@ -187,6 +187,9 @@ module Fog
# we are actually using a custom endpoint
@rackspace_region = options[:rackspace_region] || :dfw
end
else
#if we are using auth1 and the endpoint is not set, default to DFW_ENDPOINT for historical reasons
@rackspace_endpoint ||= DFW_ENDPOINT
end
end

View file

@ -74,8 +74,7 @@ module Fog
@rackspace_auth_url = options[:rackspace_auth_url]
@rackspace_must_reauthenticate = false
@connection_options = options[:connection_options] || {}
@rackspace_endpoint = options[:rackspace_database_url] || options[:rackspace_endpoint]
@rackspace_region = options[:rackspace_region] || :dfw
setup_custom_endpoint(options)
authenticate
@ -127,6 +126,30 @@ module Fog
private
def setup_custom_endpoint(options)
@rackspace_endpoint = options[:rackspace_database_url] || options[:rackspace_endpoint]
if v2_authentication?
case @rackspace_endpoint
when DFW_ENDPOINT
@rackspace_endpoint = nil
@rackspace_region = :dfw
when ORD_ENDPOINT
@rackspace_endpoint = nil
@rackspace_region = :ord
when LON_ENDPOINT
@rackspace_endpoint = nil
@rackspace_region = :lon
else
# we are actually using a custom endpoint
@rackspace_region = options[:rackspace_region] || :dfw
end
else
#if we are using auth1 and the endpoint is not set, default to DFW_ENDPOINT for historical reasons
@rackspace_endpoint ||= DFW_ENDPOINT
end
end
def deprecation_warnings(options)
Fog::Logger.deprecation("The :rackspace_endpoint option is deprecated. Please use :rackspace_database_url for custom endpoints") if options[:rackspace_endpoint]
@ -136,7 +159,7 @@ module Fog
end
end
def setup_endpoint(credentials)
def append_tenant_v1(credentials)
account_id = credentials['X-Server-Management-Url'].match(/.*\/([\d]+)$/)[1]
endpoint = @rackspace_endpoint || credentials['X-Server-Management-Url'] || DFW_ENDPOINT
@ -146,7 +169,7 @@ module Fog
def authenticate_v1(options)
credentials = Fog::Rackspace.authenticate(options, @connection_options)
setup_endpoint credentials
append_tenant_v1 credentials
@auth_token = credentials['X-Auth-Token']
end
end

View file

@ -9,9 +9,9 @@ module Fog
class InternalServerError < Fog::Rackspace::Errors::InternalServerError; end
class BadRequest < Fog::Rackspace::Errors::BadRequest; end
DFW_ENDPOINT = 'https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/'
ORD_ENDPOINT = 'https://ord.loadbalancers.api.rackspacecloud.com/v1.0/'
LON_ENDPOINT = 'https://lon.loadbalancers.api.rackspacecloud.com/v1.0/'
DFW_ENDPOINT = 'https://dfw.loadbalancers.api.rackspacecloud.com/v1.0'
ORD_ENDPOINT = 'https://ord.loadbalancers.api.rackspacecloud.com/v1.0'
LON_ENDPOINT = 'https://lon.loadbalancers.api.rackspacecloud.com/v1.0'
requires :rackspace_api_key, :rackspace_username
recognizes :rackspace_auth_url
@ -109,8 +109,8 @@ module Fog
@rackspace_auth_url = options[:rackspace_auth_url]
@rackspace_must_reauthenticate = false
@connection_options = options[:connection_options] || {}
@rackspace_endpoint = options[:rackspace_load_balancers_url] || options[:rackspace_lb_endpoint]
@rackspace_region = options[:rackspace_region] || :dfw
setup_custom_endpoint(options)
authenticate
@ -125,7 +125,7 @@ module Fog
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Auth-Token' => @auth_token
'X-Auth-Token' => auth_token
}.merge!(params[:headers] || {}),
:host => endpoint_uri.host,
:path => "#{endpoint_uri.path}/#{params[:path]}"
@ -168,6 +168,30 @@ module Fog
private
def setup_custom_endpoint(options)
@rackspace_endpoint = options[:rackspace_load_balancers_url] || options[:rackspace_lb_endpoint]
if v2_authentication?
case @rackspace_endpoint
when DFW_ENDPOINT
@rackspace_endpoint = nil
@rackspace_region = :dfw
when ORD_ENDPOINT
@rackspace_endpoint = nil
@rackspace_region = :ord
when LON_ENDPOINT
@rackspace_endpoint = nil
@rackspace_region = :lon
else
# we are actually using a custom endpoint
@rackspace_region = options[:rackspace_region] || :dfw
end
else
#if we are using auth1 and the endpoint is not set, default to DFW_ENDPOINT for historical reasons
@rackspace_endpoint ||= DFW_ENDPOINT
end
end
def deprecation_warnings(options)
Fog::Logger.deprecation("The :rackspace_lb_endpoint option is deprecated. Please use :rackspace_load_balancers_url for custom endpoints") if options[:rackspace_lb_endpoint]
@ -177,7 +201,7 @@ module Fog
end
end
def setup_endpoint(credentials)
def append_tenant_v1(credentials)
account_id = credentials['X-Server-Management-Url'].match(/.*\/([\d]+)$/)[1]
endpoint = @rackspace_endpoint || credentials['X-Server-Management-Url'] || DFW_ENDPOINT
@ -187,7 +211,7 @@ module Fog
def authenticate_v1(options)
credentials = Fog::Rackspace.authenticate(options, @connection_options)
setup_endpoint credentials
append_tenant_v1 credentials
@auth_token = credentials['X-Auth-Token']
end

View file

@ -25,15 +25,16 @@ Shindo.tests('Fog::Rackspace::BlockStorage', ['rackspace']) do
tests('legacy authentication') do
pending if Fog.mocking?
@service = Fog::Rackspace::BlockStorage.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Rackspace::BlockStorage.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").path.nil? }
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
@service.list_volumes
end
tests('custom endpoint') do
tests('custom endpoint') do
@service = Fog::Rackspace::BlockStorage.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0',
:rackspace_block_storage_url => 'https://my-custom-endpoint.com'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
@ -43,22 +44,25 @@ Shindo.tests('Fog::Rackspace::BlockStorage', ['rackspace']) do
tests('current authentation') do
pending if Fog.mocking?
@service = Fog::Rackspace::BlockStorage.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Rackspace::BlockStorage.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
@service.list_volumes
end
tests('dfw region') do
tests('dfw region').succeeds do
@service = Fog::Rackspace::BlockStorage.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :dfw
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
@service.list_volumes
end
tests('ord region') do
tests('ord region').succeeds do
@service = Fog::Rackspace::BlockStorage.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/) != nil }
@service.list_volumes
end
tests('custom endpoint') do
@service = Fog::Rackspace::BlockStorage.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
@ -71,15 +75,21 @@ Shindo.tests('Fog::Rackspace::BlockStorage', ['rackspace']) do
tests('default auth') do
pending if Fog.mocking?
tests('no params') do
tests('no params').succeeds do
@service = Fog::Rackspace::BlockStorage.new
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
@service.list_volumes
end
tests('specify old contstant style service endoint').succeeds do
@service = Fog::Rackspace::BlockStorage.new :rackspace_endpoint => Fog::Rackspace::BlockStorage::ORD_ENDPOINT
@service.list_volumes
end
tests('specify region') do
@service = Fog::Rackspace::BlockStorage.new :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/ ) != nil }
@service.list_volumes
end
tests('custom endpoint') do
@service = Fog::Rackspace::BlockStorage.new :rackspace_block_storage_url => 'https://my-custom-endpoint.com'

View file

@ -23,12 +23,13 @@ Shindo.tests('Fog::CDN::Rackspace', ['rackspace']) do
tests('authentication v1') do
pending if Fog.mocking?
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").path.nil? }
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
@service.get_containers
end
tests('custom endpoint') do
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0',
@ -40,22 +41,25 @@ Shindo.tests('Fog::CDN::Rackspace', ['rackspace']) do
tests('authentication v2') do
pending if Fog.mocking?
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").path.nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
@service.get_containers
end
tests('dfw region') do
tests('dfw region').succeeds do
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :dfw
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /cdn1/) != nil }
@service.get_containers
end
tests('ord region') do
tests('ord region').succeeds do
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /cdn2/) != nil }
@service.get_containers
end
tests('custom endpoint') do
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
@ -68,16 +72,18 @@ Shindo.tests('Fog::CDN::Rackspace', ['rackspace']) do
tests('default auth') do
pending if Fog.mocking?
tests('no params') do
tests('no params').succeeds do
@service = Fog::CDN::Rackspace.new
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true, "uses DFW") { (@service.instance_variable_get("@uri").host =~ /cdn1/) != nil }
@service.get_containers
end
tests('specify region') do
tests('specify region').succeeds do
@service = Fog::CDN::Rackspace.new :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /cdn2/) != nil }
@service.get_containers
end
tests('custom endpoint') do

View file

@ -23,12 +23,13 @@ Shindo.tests('Rackspace | Compute', ['rackspace']) do
tests('authentication v1') do
pending if Fog.mocking?
@service = Fog::Compute::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Compute::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").nil? }
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
@service.list_flavors
end
tests('custom endpoint') do
@service = Fog::Compute::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0',
@ -40,13 +41,14 @@ Shindo.tests('Rackspace | Compute', ['rackspace']) do
tests('authentication v2') do
pending if Fog.mocking?
@service = Fog::Compute::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Compute::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host == 'servers.api.rackspacecloud.com') != nil }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
@service.list_flavors
end
tests('custom endpoint') do
@ -60,15 +62,17 @@ Shindo.tests('Rackspace | Compute', ['rackspace']) do
tests('default auth') do
pending if Fog.mocking?
tests('no params') do
tests('no params').succeeds do
@service = Fog::Compute::Rackspace.new
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host == 'servers.api.rackspacecloud.com') != nil }
@service.list_flavors
end
tests('specify region') do
tests('specify region').succeeds do
@service = Fog::Compute::Rackspace.new :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host == 'servers.api.rackspacecloud.com') != nil }
@service.list_flavors
end
tests('custom endpoint') do
@service = Fog::Compute::Rackspace.new :rackspace_compute_v1_url => 'https://my-custom-endpoint.com'

View file

@ -25,12 +25,13 @@ Shindo.tests('Fog::Compute::RackspaceV2', ['rackspace']) do
tests('legacy authentication') do
pending if Fog.mocking?
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").path.nil? }
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
@service.list_flavors
end
tests('custom endpoint') do
@ -43,22 +44,25 @@ Shindo.tests('Fog::Compute::RackspaceV2', ['rackspace']) do
tests('current authentation') do
pending if Fog.mocking?
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
@service.list_flavors
end
tests('dfw region') do
tests('dfw region').succeeds do
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :dfw
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
@service.list_flavors
end
tests('ord region') do
tests('ord region').succeeds do
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/) != nil }
@service.list_flavors
end
tests('custom endpoint') do
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
@ -71,19 +75,21 @@ Shindo.tests('Fog::Compute::RackspaceV2', ['rackspace']) do
tests('default auth') do
pending if Fog.mocking?
tests('no params') do
tests('no params').succeeds do
@service = Fog::Compute::RackspaceV2.new
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
@service.list_flavors
end
tests('specify old contstant style service endoint').succeeds do
@service = Fog::Compute::RackspaceV2.new :rackspace_endpoint => Fog::Compute::RackspaceV2::ORD_ENDPOINT
@service.list_flavors
end
tests('specify region') do
tests('specify region').succeeds do
@service = Fog::Compute::RackspaceV2.new :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/ ) != nil }
@service.list_flavors
end
tests('custom endpoint') do
@service = Fog::Compute::RackspaceV2.new :rackspace_compute_url => 'https://my-custom-endpoint.com'

View file

@ -26,12 +26,13 @@ Shindo.tests('Fog::Rackspace::Databases', ['rackspace']) do |variable|
tests('authentication v1') do
pending if Fog.mocking?
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
tests('variables populated') do
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").nil? }
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
@service.flavors
end
tests('custom endpoint') do
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0',
@ -43,23 +44,25 @@ Shindo.tests('Fog::Rackspace::Databases', ['rackspace']) do |variable|
tests('authentication v2') do
pending if Fog.mocking?
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
@service.flavors
end
tests('dfw region') do
tests('dfw region').succeeds do
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :dfw
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
puts @service.instance_variable_get("@uri").host
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
@service.flavors
end
tests('ord region') do
tests('ord region').succeeds do
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/) != nil }
@service.flavors
end
tests('custom endpoint') do
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
@ -72,15 +75,22 @@ Shindo.tests('Fog::Rackspace::Databases', ['rackspace']) do |variable|
tests('default auth') do
pending if Fog.mocking?
tests('no params') do
tests('no params').succeeds do
@service = Fog::Rackspace::Databases.new
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
@service.flavors
end
tests('specify region') do
tests('specify old contstant style service endoint').succeeds do
@service = Fog::Rackspace::Databases.new :rackspace_endpoint => Fog::Rackspace::Databases::ORD_ENDPOINT
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/ ) != nil }
@service.flavors
end
tests('specify region').succeeds do
@service = Fog::Rackspace::Databases.new :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/ ) != nil }
@service.flavors
end
tests('custom endpoint') do
@service = Fog::Rackspace::Databases.new :rackspace_database_url => 'https://my-custom-endpoint.com'

View file

@ -25,12 +25,13 @@ Shindo.tests('Fog::DNS::Rackspace', ['rackspace']) do
tests('legacy authentication') do
pending if Fog.mocking?
@service = Fog::DNS::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::DNS::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").path.nil? }
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
@service.list_domains
end
tests('custom endpoint') do
@ -43,12 +44,13 @@ Shindo.tests('Fog::DNS::Rackspace', ['rackspace']) do
tests('current authentication') do
pending if Fog.mocking?
@service = Fog::DNS::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::DNS::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
@service.list_domains
end
tests('custom endpoint') do
@service = Fog::DNS::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
@ -61,10 +63,11 @@ Shindo.tests('Fog::DNS::Rackspace', ['rackspace']) do
tests('default auth') do
pending if Fog.mocking?
tests('no params') do
tests('no params').succeeds do
@service = Fog::DNS::Rackspace.new
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
@service.list_domains
end
tests('custom endpoint') do
@service = Fog::DNS::Rackspace.new :rackspace_dns_url => 'https://my-custom-endpoint.com'

View file

@ -25,12 +25,13 @@ Shindo.tests('Fog::Rackspace::LoadBalancers', ['rackspace']) do
tests('legacy authentication') do
pending if Fog.mocking?
@service = Fog::Rackspace::LoadBalancers.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Rackspace::LoadBalancers.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").path.nil? }
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
@service.list_load_balancers
end
tests('custom endpoint') do
@ -43,22 +44,25 @@ Shindo.tests('Fog::Rackspace::LoadBalancers', ['rackspace']) do
tests('current authentation') do
pending if Fog.mocking?
@service = Fog::Rackspace::LoadBalancers.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Rackspace::LoadBalancers.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
@service.list_load_balancers
end
tests('dfw region') do
tests('dfw region').succeeds do
@service = Fog::Rackspace::LoadBalancers.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :dfw
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
@service.list_load_balancers
end
tests('ord region') do
tests('ord region').succeeds do
@service = Fog::Rackspace::LoadBalancers.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/) != nil }
@service.list_load_balancers
end
tests('custom endpoint') do
@service = Fog::Rackspace::LoadBalancers.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
@ -71,15 +75,22 @@ Shindo.tests('Fog::Rackspace::LoadBalancers', ['rackspace']) do
tests('default auth') do
pending if Fog.mocking?
tests('no params') do
tests('no params').succeeds do
@service = Fog::Rackspace::LoadBalancers.new
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
@service.list_load_balancers
end
tests('specify region') do
tests('specify old contstant style service endoint').succeeds do
@service = Fog::Rackspace::LoadBalancers.new :rackspace_lb_endpoint => Fog::Rackspace::LoadBalancers::ORD_ENDPOINT
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/ ) != nil }
@service.list_load_balancers
end
tests('specify region').succeeds do
@service = Fog::Rackspace::LoadBalancers.new :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/ ) != nil }
@service.list_load_balancers
end
tests('custom endpoint') do
@service = Fog::Rackspace::LoadBalancers.new :rackspace_load_balancers_url => 'https://my-custom-endpoint.com'

View file

@ -23,12 +23,13 @@ Shindo.tests('Rackspace | Storage', ['rackspace']) do
tests('authentication v1') do
pending if Fog.mocking?
@service = Fog::Storage::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Storage::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").nil? }
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
@service.head_containers
end
tests('custom endpoint') do
@service = Fog::Storage::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0',
@ -40,24 +41,27 @@ Shindo.tests('Rackspace | Storage', ['rackspace']) do
tests('authentation v2') do
pending if Fog.mocking?
@service = Fog::Storage::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
tests('variables populated') do
tests('variables populated').succeeds do
@service = Fog::Storage::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
@service.head_containers
end
tests('dfw region') do
tests('dfw region').succeeds do
@service = Fog::Storage::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :dfw
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw\d/) != nil }
@service.head_containers
end
tests('ord region') do
tests('ord region').succeeds do
@service = Fog::Storage::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord\d/) != nil }
@service.head_containers
end
tests('custom endpoint') do
tests('custom endpoint').succeeds do
@service = Fog::Storage::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
:rackspace_storage_url => 'https://my-custom-endpoint.com'
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
@ -68,15 +72,17 @@ Shindo.tests('Rackspace | Storage', ['rackspace']) do
tests('default auth') do
pending if Fog.mocking?
tests('no params') do
tests('no params').succeeds do
@service = Fog::Storage::Rackspace.new
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw\d/) != nil }
@service.head_containers
end
tests('specify region') do
tests('specify region').succeeds do
@service = Fog::Storage::Rackspace.new :rackspace_region => :ord
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord\d/ ) != nil }
@service.head_containers
end
tests('custom endpoint') do
@service = Fog::Storage::Rackspace.new :rackspace_storage_url => 'https://my-custom-endpoint.com'