2013-02-19 16:53:54 -05:00
|
|
|
Shindo.tests('Fog::CDN::Rackspace', ['rackspace']) do
|
|
|
|
|
|
|
|
def assert_method(url, method)
|
2013-02-19 17:05:17 -05:00
|
|
|
@service.instance_variable_set "@rackspace_auth_url", url
|
2013-02-19 16:53:54 -05:00
|
|
|
returns(method) { @service.send :authentication_method }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#authentication_method') do
|
|
|
|
@service = Fog::CDN::Rackspace.new
|
|
|
|
assert_method nil, :authenticate_v2
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-02-20 14:02:32 -05:00
|
|
|
tests('authentication v1') do
|
2013-02-19 16:53:54 -05:00
|
|
|
pending if Fog.mocking?
|
|
|
|
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
|
|
|
|
|
|
|
|
tests('variables populated') do
|
|
|
|
returns(false, "auth token populated") { @service.instance_variable_get("@auth_token").nil? }
|
2013-02-20 14:02:32 -05:00
|
|
|
returns(false, "path populated") { @service.instance_variable_get("@uri").path.nil? }
|
2013-02-19 16:53:54 -05:00
|
|
|
returns(true, "identity_service was not used") { @service.instance_variable_get("@identity_service").nil? }
|
|
|
|
end
|
2013-02-20 14:02:32 -05:00
|
|
|
tests('custom endpoint') do
|
|
|
|
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0',
|
|
|
|
:rackspace_cdn_url => 'https://my-custom-cdn-endpoint.com'
|
|
|
|
returns(true, "uses custom endpoint") { (@service.instance_variable_get("@uri").host =~ /my-custom-cdn-endpoint\.com/) != nil }
|
|
|
|
end
|
2013-02-19 16:53:54 -05:00
|
|
|
end
|
|
|
|
|
2013-02-20 14:02:32 -05:00
|
|
|
tests('authentation v2') do
|
2013-02-19 16:53:54 -05:00
|
|
|
pending if Fog.mocking?
|
|
|
|
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
|
|
|
|
|
|
|
|
tests('variables populated') do
|
|
|
|
returns(false, "auth token populated") { @service.instance_variable_get("@auth_token").nil? }
|
2013-02-20 14:02:32 -05:00
|
|
|
returns(false, "path populated") { @service.instance_variable_get("@uri").path.nil? }
|
2013-02-19 16:53:54 -05:00
|
|
|
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
|
|
|
|
end
|
|
|
|
tests('dfw region') do
|
|
|
|
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :dfw
|
2013-02-20 14:02:32 -05:00
|
|
|
returns(true) { (@service.instance_variable_get("@uri").host =~ /cdn1/) != nil }
|
2013-02-19 16:53:54 -05:00
|
|
|
end
|
|
|
|
tests('ord region') do
|
|
|
|
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :rackspace_region => :ord
|
2013-02-20 14:02:32 -05:00
|
|
|
returns(true) { (@service.instance_variable_get("@uri").host =~ /cdn2/) != nil }
|
|
|
|
end
|
|
|
|
tests('custom endpoint') do
|
|
|
|
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
|
|
|
|
:rackspace_cdn_url => 'https://my-custom-cdn-endpoint.com'
|
|
|
|
returns(true, "uses custom endpoint") { (@service.instance_variable_get("@uri").host =~ /my-custom-cdn-endpoint\.com/) != nil }
|
2013-02-19 16:53:54 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-20 14:02:32 -05:00
|
|
|
tests('default auth') do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
|
|
|
|
tests('no params') do
|
|
|
|
@service = Fog::CDN::Rackspace.new
|
|
|
|
returns(true, "uses DFW") { (@service.instance_variable_get("@uri").host =~ /cdn1/) != nil }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('specify region') do
|
|
|
|
@service = Fog::CDN::Rackspace.new :rackspace_region => :ord
|
|
|
|
returns(true) { (@service.instance_variable_get("@uri").host =~ /cdn2/) != nil }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('custom endpoint') do
|
|
|
|
@service = Fog::CDN::Rackspace.new :rackspace_cdn_url => 'https://my-custom-cdn-endpoint.com'
|
|
|
|
returns(true, "uses custom endpoint") { (@service.instance_variable_get("@uri").host =~ /my-custom-cdn-endpoint\.com/) != nil }
|
|
|
|
end
|
|
|
|
end
|
2013-02-19 16:53:54 -05:00
|
|
|
end
|