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

[rackspace|queues] updated Fog::Rackspace::Queues to generate UUID for client id if it is not provided with one.

This commit is contained in:
Kyle Rames 2013-10-10 10:25:35 -05:00
parent c0707cb41d
commit aae2a4f7d9
11 changed files with 32 additions and 15 deletions

View file

@ -1,4 +1,5 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rackspace'))
require 'uuidtools'
module Fog
module Rackspace
@ -10,11 +11,12 @@ module Fog
class BadRequest < Fog::Rackspace::Errors::BadRequest; end
class MethodNotAllowed < Fog::Rackspace::Errors::BadRequest; end
requires :rackspace_api_key, :rackspace_username, :rackspace_queues_client_id
requires :rackspace_api_key, :rackspace_username
recognizes :rackspace_auth_url
recognizes :rackspace_auth_token
recognizes :rackspace_region
recognizes :rackspace_queues_url
recognizes :rackspace_queues_client_id
model_path 'fog/rackspace/models/queues'
@ -60,7 +62,7 @@ module Fog
def initialize(options = {})
@rackspace_api_key = options[:rackspace_api_key]
@rackspace_username = options[:rackspace_username]
@rackspace_queues_client_id = options[:rackspace_queues_client_id]
@rackspace_queues_client_id = options[:rackspace_queues_client_id] || UUIDTools::UUID.random_create.to_s
@rackspace_auth_url = options[:rackspace_auth_url]
@rackspace_must_reauthenticate = false
@connection_options = options[:connection_options] || {}

View file

@ -2,7 +2,7 @@ Shindo.tests('Fog::Rackspace::Queues | claim', ['rackspace']) do
pending if Fog.mocking?
service = Fog::Rackspace::Queues.new(:rackspace_queues_client_id => 'test_client')
service = Fog::Rackspace::Queues.new
queue = service.queues.create({
:name => "fog_queue_#{Time.now.to_i.to_s}",
})

View file

@ -2,7 +2,7 @@ Shindo.tests('Fog::Rackspace::Queues | claims', ['rackspace']) do
pending if Fog.mocking?
service = Fog::Rackspace::Queues.new(:rackspace_queues_client_id => 'test_client')
service = Fog::Rackspace::Queues.new
queue = service.queues.create({
:name => "fog_queue_#{Time.now.to_i.to_s}",
})

View file

@ -2,7 +2,7 @@ Shindo.tests('Fog::Rackspace::Queues | message', ['rackspace']) do
pending if Fog.mocking?
service = Fog::Rackspace::Queues.new(:rackspace_queues_client_id => 'test_client')
service = Fog::Rackspace::Queues.new
queue = service.queues.create({
:name => "fog_instance_#{Time.now.to_i.to_s}",
})

View file

@ -2,7 +2,7 @@ Shindo.tests('Fog::Rackspace::Queues | messages', ['rackspace']) do
pending if Fog.mocking?
service = Fog::Rackspace::Queues.new(:rackspace_queues_client_id => 'test_client')
service = Fog::Rackspace::Queues.new
queue = service.queues.create({
:name => "fog_queue_#{Time.now.to_i.to_s}",
})

View file

@ -2,7 +2,7 @@ Shindo.tests('Fog::Rackspace::Queues | queue', ['rackspace']) do
pending if Fog.mocking?
service = Fog::Rackspace::Queues.new(:rackspace_queues_client_id => 'test_client')
service = Fog::Rackspace::Queues.new
options = {
:name => "fog_instance_#{Time.now.to_i.to_s}",
}

View file

@ -2,7 +2,7 @@ Shindo.tests('Fog::Rackspace::Queues | queues', ['rackspace']) do
pending if Fog.mocking?
service = Fog::Rackspace::Queues.new(:rackspace_queues_client_id => 'test_client')
service = Fog::Rackspace::Queues.new
options = {
:name => "fog_instance_#{Time.now.to_i.to_s}",
}

View file

@ -9,7 +9,7 @@ Shindo.tests('Fog::Rackspace::Queues', ['rackspace']) do
end
tests('#authentication_method') do
@service = Fog::Rackspace::Queues.new(:rackspace_queues_client_id => 'test_client')
@service = Fog::Rackspace::Queues.new
assert_method nil, :authenticate_v2
@ -97,4 +97,20 @@ Shindo.tests('Fog::Rackspace::Queues', ['rackspace']) do
data = @service.queues
returns(true) { data.is_a? Array }
end
tests('client_id') do
pending if Fog.mocking?
tests('should generate uuid if a client id is not provided').succeeds do
service = Fog::Rackspace::Queues.new
service.client_id =~ /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
end
tests('should use specified uuid').succeeds do
my_uuid = UUIDTools::UUID.random_create.to_s
service = Fog::Rackspace::Queues.new :rackspace_queues_client_id => my_uuid
service.client_id == my_uuid
end
end
end

View file

@ -2,10 +2,10 @@
pending if Fog.mocking?
service = Fog::Rackspace::Queues.new(:rackspace_queues_client_id => 'test_client')
service = Fog::Rackspace::Queues.new
queue_name = 'fog' + Time.now.to_i.to_s
client_id = 'fog-client-' + Time.now.to_i.to_s
client_id = service.client_id
claim_id = nil
service.create_queue(queue_name)

View file

@ -2,10 +2,10 @@ Shindo.tests('Fog::Rackspace::Queues | messages_tests', ['rackspace']) do
pending if Fog.mocking?
service = Fog::Rackspace::Queues.new(:rackspace_queues_client_id => 'test_client')
service = Fog::Rackspace::Queues.new
queue_name = 'fog' + Time.now.to_i.to_s
client_id = 'fog-client-' + Time.now.to_i.to_s
client_id = service.client_id
message_id = nil
service.create_queue(queue_name)

View file

@ -2,7 +2,7 @@ Shindo.tests('Fog::Rackspace::Queues | queue_tests', ['rackspace']) do
pending if Fog.mocking?
service = Fog::Rackspace::Queues.new(:rackspace_queues_client_id => 'test_client')
service = Fog::Rackspace::Queues.new
tests('success') do
@ -14,7 +14,6 @@ Shindo.tests('Fog::Rackspace::Queues | queue_tests', ['rackspace']) do
tests("#list_queues").formats(LIST_QUEUES_FORMAT) do
response = service.list_queues
puts response.inspect
response.body
end