2012-06-22 12:37:20 -04:00
|
|
|
Shindo.tests('Fog::Rackspace::Databases', ['rackspace']) do |variable|
|
|
|
|
|
|
|
|
pending if Fog.mocking?
|
|
|
|
|
2013-03-13 17:01:32 -04:00
|
|
|
|
|
|
|
def assert_method(url, method)
|
|
|
|
@service.instance_variable_set "@rackspace_auth_url", url
|
|
|
|
returns(method) { @service.send :authentication_method }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#authentication_method') do
|
|
|
|
@service = Fog::Rackspace::Databases.new
|
|
|
|
|
|
|
|
assert_method nil, :authenticate_v2
|
|
|
|
|
|
|
|
assert_method 'https://identity.api.rackspacecloud.com', :authenticate_v1
|
|
|
|
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', :authenticate_v1
|
|
|
|
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('authentication v1') do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
|
|
|
|
tests('variables populated') do
|
2013-03-15 17:38:33 -04:00
|
|
|
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0'
|
2013-03-13 17:01:32 -04:00
|
|
|
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? }
|
2013-03-15 17:38:33 -04:00
|
|
|
@service.flavors
|
2013-03-13 17:01:32 -04:00
|
|
|
end
|
|
|
|
tests('custom endpoint') do
|
|
|
|
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v1.0',
|
|
|
|
:rackspace_database_url => 'https://my-custom-endpoint.com'
|
|
|
|
returns(false, "auth token populated") { @service.send(:auth_token).nil? }
|
|
|
|
returns(true, "uses custom endpoint") { (@service.instance_variable_get("@uri").host =~ /my-custom-endpoint\.com/) != nil }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('authentication v2') do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
|
2013-03-15 17:38:33 -04:00
|
|
|
tests('variables populated').succeeds do
|
2013-05-30 13:52:37 -04:00
|
|
|
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :connection_options => { :ssl_verify_peer => true }
|
2013-03-13 17:01:32 -04:00
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
|
|
|
returns(false, "path populated") { @service.instance_variable_get("@uri").nil? }
|
2013-05-30 13:52:37 -04:00
|
|
|
|
|
|
|
identity_service = @service.instance_variable_get("@identity_service")
|
|
|
|
returns(false, "identity service was used") { identity_service.nil? }
|
|
|
|
returns(true, "connection_options are passed") { identity_service.instance_variable_get("@connection_options").has_key?(:ssl_verify_peer) }
|
2013-03-15 17:38:33 -04:00
|
|
|
@service.flavors
|
2013-03-13 17:01:32 -04:00
|
|
|
end
|
2013-03-15 17:38:33 -04:00
|
|
|
tests('dfw region').succeeds do
|
2013-03-13 17:01:32 -04:00
|
|
|
@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? }
|
|
|
|
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
|
2013-03-15 17:38:33 -04:00
|
|
|
@service.flavors
|
2013-03-13 17:01:32 -04:00
|
|
|
end
|
2013-03-15 17:38:33 -04:00
|
|
|
tests('ord region').succeeds do
|
2013-03-13 17:01:32 -04:00
|
|
|
@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 }
|
2013-03-15 17:38:33 -04:00
|
|
|
@service.flavors
|
2013-03-13 17:01:32 -04:00
|
|
|
end
|
|
|
|
tests('custom endpoint') do
|
|
|
|
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
|
|
|
|
:rackspace_database_url => 'https://my-custom-endpoint.com'
|
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
|
|
|
returns(true, "uses custom endpoint") { (@service.instance_variable_get("@uri").host =~ /my-custom-endpoint\.com/) != nil }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('default auth') do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
|
2013-03-15 17:38:33 -04:00
|
|
|
tests('no params').succeeds do
|
2013-03-13 17:01:32 -04:00
|
|
|
@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 }
|
2013-03-15 17:38:33 -04:00
|
|
|
@service.flavors
|
|
|
|
end
|
|
|
|
tests('specify old contstant style service endoint').succeeds do
|
|
|
|
@service = Fog::Rackspace::Databases.new :rackspace_endpoint => Fog::Rackspace::Databases::ORD_ENDPOINT
|
2013-07-25 09:14:46 -04:00
|
|
|
returns(true) { (@service.instance_variable_get("@uri").to_s =~ /#{Fog::Rackspace::Databases::ORD_ENDPOINT}/ ) != nil }
|
2013-03-15 17:38:33 -04:00
|
|
|
@service.flavors
|
2013-03-13 17:01:32 -04:00
|
|
|
end
|
2013-03-15 17:38:33 -04:00
|
|
|
tests('specify region').succeeds do
|
2013-03-13 17:01:32 -04:00
|
|
|
@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 }
|
2013-03-15 17:38:33 -04:00
|
|
|
@service.flavors
|
2013-03-13 17:01:32 -04:00
|
|
|
end
|
|
|
|
tests('custom endpoint') do
|
|
|
|
@service = Fog::Rackspace::Databases.new :rackspace_database_url => 'https://my-custom-endpoint.com'
|
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
|
|
|
returns(true, "uses custom endpoint") { (@service.instance_variable_get("@uri").host =~ /my-custom-endpoint\.com/) != nil }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-21 16:11:17 -04:00
|
|
|
tests('reauthentication') do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
|
|
|
|
@service = Fog::Rackspace::Databases.new
|
|
|
|
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
|
|
|
|
@service.instance_variable_set("@auth_token", "bad_token")
|
|
|
|
returns(200) { @service.list_flavors.status }
|
|
|
|
end
|
|
|
|
|
2012-06-22 12:37:20 -04:00
|
|
|
@service = Fog::Rackspace::Databases.new
|
|
|
|
|
|
|
|
tests('#flavors').succeeds do
|
|
|
|
data = @service.flavors
|
|
|
|
returns(true) { data.is_a? Array }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#instances').succeeds do
|
|
|
|
data = @service.instances
|
|
|
|
returns(true) { data.is_a? Array }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#databases').succeeds do
|
|
|
|
data = @service.databases
|
|
|
|
returns(true) { data.is_a? Array }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#users').succeeds do
|
|
|
|
data = @service.users
|
|
|
|
returns(true) { data.is_a? Array }
|
|
|
|
end
|
2013-03-13 17:01:32 -04:00
|
|
|
|
2012-06-22 12:37:20 -04:00
|
|
|
end
|