2013-02-20 09:14:34 -05:00
|
|
|
Shindo.tests('Fog::Compute::RackspaceV2', ['rackspace']) do
|
|
|
|
|
|
|
|
def assert_method(url, method)
|
|
|
|
@service.instance_variable_set "@rackspace_auth_url", url
|
|
|
|
returns(method) { @service.send :authentication_method }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#authentication_method') do
|
2013-03-15 12:55:40 -04:00
|
|
|
@service = Fog::Compute::RackspaceV2.new
|
2013-02-26 10:52:53 -05:00
|
|
|
|
2013-02-20 09:14:34 -05:00
|
|
|
assert_method nil, :authenticate_v2
|
2013-02-26 10:52:53 -05:00
|
|
|
|
2013-02-26 11:05:23 -05:00
|
|
|
assert_method 'auth.api.rackspacecloud.com', :authenticate_v1 # chef's default auth endpoint
|
|
|
|
|
2013-02-26 10:52:53 -05:00
|
|
|
assert_method 'https://identity.api.rackspacecloud.com', :authenticate_v1
|
2013-02-20 09:14:34 -05:00
|
|
|
assert_method 'https://identity.api.rackspacecloud.com/v1', :authenticate_v1
|
|
|
|
assert_method 'https://identity.api.rackspacecloud.com/v1.1', :authenticate_v1
|
|
|
|
assert_method 'https://identity.api.rackspacecloud.com/v2.0', :authenticate_v2
|
|
|
|
|
2013-02-26 10:52:53 -05:00
|
|
|
assert_method 'https://lon.identity.api.rackspacecloud.com', :authenticate_v1
|
2013-02-20 09:14:34 -05:00
|
|
|
assert_method 'https://lon.identity.api.rackspacecloud.com/v1', :authenticate_v1
|
|
|
|
assert_method 'https://lon.identity.api.rackspacecloud.com/v1.1', :authenticate_v1
|
|
|
|
assert_method 'https://lon.identity.api.rackspacecloud.com/v2.0', :authenticate_v2
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
2013-03-01 15:48:26 -05:00
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
2013-02-20 16:48:19 -05:00
|
|
|
returns(false, "path populated") { @service.instance_variable_get("@uri").path.nil? }
|
2013-03-15 10:11:39 -04:00
|
|
|
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
|
2013-02-20 09:14:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('custom endpoint') do
|
|
|
|
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0',
|
2013-02-20 16:48:19 -05:00
|
|
|
:rackspace_compute_url => 'https://my-custom-endpoint.com'
|
2013-03-01 15:48:26 -05:00
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
2013-02-20 16:48:19 -05:00
|
|
|
returns(true, "uses custom endpoint") { (@service.instance_variable_get("@uri").host =~ /my-custom-endpoint\.com/) != nil }
|
2013-02-20 09:14:34 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
2013-03-01 15:48:26 -05:00
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
2013-02-20 16:48:19 -05:00
|
|
|
returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
|
2013-02-20 09:14:34 -05:00
|
|
|
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
|
|
|
|
end
|
|
|
|
tests('dfw region') do
|
|
|
|
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :dfw
|
2013-03-01 15:48:26 -05:00
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
2013-02-20 16:48:19 -05:00
|
|
|
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
|
2013-02-20 09:14:34 -05:00
|
|
|
end
|
|
|
|
tests('ord region') do
|
|
|
|
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :ord
|
2013-03-01 15:48:26 -05:00
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
2013-02-20 16:48:19 -05:00
|
|
|
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/) != nil }
|
|
|
|
end
|
|
|
|
tests('custom endpoint') do
|
|
|
|
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
|
|
|
|
:rackspace_compute_url => 'https://my-custom-endpoint.com'
|
2013-03-01 15:48:26 -05:00
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
2013-02-20 16:48:19 -05:00
|
|
|
returns(true, "uses custom endpoint") { (@service.instance_variable_get("@uri").host =~ /my-custom-endpoint\.com/) != nil }
|
2013-02-20 09:14:34 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-20 16:48:19 -05:00
|
|
|
tests('default auth') do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
|
|
|
|
tests('no params') do
|
|
|
|
@service = Fog::Compute::RackspaceV2.new
|
2013-03-01 15:48:26 -05:00
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
2013-02-20 16:48:19 -05:00
|
|
|
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
|
|
|
|
end
|
2013-03-15 10:11:39 -04:00
|
|
|
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
|
2013-02-20 16:48:19 -05:00
|
|
|
tests('specify region') do
|
|
|
|
@service = Fog::Compute::RackspaceV2.new :rackspace_region => :ord
|
2013-03-01 15:48:26 -05:00
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
2013-02-20 16:48:19 -05:00
|
|
|
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/ ) != nil }
|
|
|
|
end
|
|
|
|
tests('custom endpoint') do
|
|
|
|
@service = Fog::Compute::RackspaceV2.new :rackspace_compute_url => 'https://my-custom-endpoint.com'
|
2013-03-01 15:48:26 -05:00
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
2013-02-20 16:48:19 -05:00
|
|
|
returns(true, "uses custom endpoint") { (@service.instance_variable_get("@uri").host =~ /my-custom-endpoint\.com/) != nil }
|
|
|
|
end
|
|
|
|
end
|
2013-02-20 09:14:34 -05:00
|
|
|
|
|
|
|
end
|