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

[rackspace|queueing] Cleaned up tests and authentication logic

This commit is contained in:
Brian Hartsock 2013-10-07 17:54:23 -04:00
parent 7800c5904d
commit aeb9de7982
4 changed files with 12 additions and 28 deletions

View file

@ -13,7 +13,6 @@ module Fog
requires :rackspace_api_key, :rackspace_username, :rackspace_queues_client_id
recognizes :rackspace_auth_url
recognizes :rackspace_auth_token
recognizes :rackspace_endpoint
recognizes :rackspace_region
recognizes :rackspace_queues_url
@ -65,7 +64,7 @@ module Fog
@rackspace_auth_url = options[:rackspace_auth_url]
@rackspace_must_reauthenticate = false
@connection_options = options[:connection_options] || {}
@rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_queues_url] || options[:rackspace_endpoint])
@rackspace_region = options[:rackspace_region] || :ord
unless v2_authentication?
raise Fog::Errors::NotImplemented.new("V2 authentication required for Queues")
@ -73,8 +72,6 @@ module Fog
authenticate
deprecation_warnings(options)
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
@ -113,17 +110,6 @@ module Fog
def client_id=(client_id)
@rackspace_queues_client_id = client_id
end
private
def deprecation_warnings(options)
Fog::Logger.deprecation("The :rackspace_endpoint option is deprecated. Please use :rackspace_queues_url for custom endpoints") if options[:rackspace_endpoint]
# if [DFW_ENDPOINT, ORD_ENDPOINT, LON_ENDPOINT].include?(@rackspace_endpoint) && v2_authentication?
# regions = @identity_service.service_catalog.display_service_regions(service_name)
# Fog::Logger.deprecation("Please specify region using :rackspace_region rather than :rackspace_endpoint. Valid region for :rackspace_region are #{regions}.")
# end
end
end
end
end

View file

@ -25,6 +25,8 @@ Shindo.tests('Fog::Rackspace::Queues | message', ['rackspace']) do
message = queue.messages.create(options.merge({:claim_id => '10'}))
tests('#destroy => fails if claim is not valid').raises(Fog::Rackspace::Queues::ServiceError) do
#API team should be fixing this so that it errors in this scenario
pending
message.destroy
end
ensure

View file

@ -46,6 +46,9 @@ Shindo.tests('Fog::Rackspace::Queues', ['rackspace']) do
@service.queues
end
tests('dfw region').succeeds do
#We consistently use DFW as our default but queues doesn't have a DFW default region yet.
# We can enable this test once they have a DFW region (which they will)
pending
@service = Fog::Rackspace::Queues.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 }
@ -57,18 +60,15 @@ Shindo.tests('Fog::Rackspace::Queues', ['rackspace']) do
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/) != nil }
@service.queues
end
tests('custom endpoint') do
@service = Fog::Rackspace::Queues.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0',
:rackspace_queues_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?
tests('no params').succeeds do
#We consistently use DFW as our default but queues doesn't have a DFW default region yet.
# We can enable this test once they have a DFW region (which they will)
pending
@service = Fog::Rackspace::Queues.new
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
@ -80,11 +80,6 @@ Shindo.tests('Fog::Rackspace::Queues', ['rackspace']) do
returns(true) { (@service.instance_variable_get("@uri").host =~ /ord/ ) != nil }
@service.queues
end
tests('custom endpoint') do
@service = Fog::Rackspace::Queues.new :rackspace_queues_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('reauthentication') do
@ -93,7 +88,7 @@ Shindo.tests('Fog::Rackspace::Queues', ['rackspace']) do
@service = Fog::Rackspace::Queues.new
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
@service.instance_variable_set("@auth_token", "bad_token")
returns(200) { @service.list_queues.status }
returns(true, 'list queues call succeeds') { [200, 204].include?(@service.list_queues.status) }
end
@service = Fog::Rackspace::Queues.new

View file

@ -32,8 +32,9 @@ Shindo.tests('Fog::Rackspace::Queues | messages_tests', ['rackspace']) do
service.get_message(client_id, queue_name, message_id).body
end
#TODO - Report bad error code to queueing team
tests("#delete_message(#{queue_name}, #{message_id}, { :claim_id => '10' })").raises(Fog::Rackspace::Queues::ServiceError) do
#API team should be changing this
pending
service.delete_message(queue_name, message_id, { :claim_id => '10' })
end