Skip to content

Commit

Permalink
Merge pull request fog#1849 from rackspace/proxy
Browse files Browse the repository at this point in the history
[Rackspace] add proxy support for Auth 2.0
  • Loading branch information
Kyle Rames committed Jun 4, 2013
2 parents 9ad9471 + ee038e1 commit 5eebf7d
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 25 deletions.
3 changes: 2 additions & 1 deletion lib/fog/rackspace/block_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def authenticate
options = {
:rackspace_api_key => @rackspace_api_key,
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url
:rackspace_auth_url => @rackspace_auth_url,
:connection_options => @connection_options
}
super(options)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/rackspace/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ def authenticate
options = {
:rackspace_api_key => @rackspace_api_key,
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url
:rackspace_auth_url => @rackspace_auth_url,
:connection_options => @connection_options
}
super(options)
else
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/rackspace/compute_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ def authenticate
options = {
:rackspace_api_key => @rackspace_api_key,
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url
:rackspace_auth_url => @rackspace_auth_url,
:connection_options => @connection_options
}
super(options)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/rackspace/databases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def authenticate
options = {
:rackspace_api_key => @rackspace_api_key,
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url
:rackspace_auth_url => @rackspace_auth_url,
:connection_options => @connection_options
}

super(options)
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/rackspace/dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def authenticate
options = {
:rackspace_api_key => @rackspace_api_key,
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url
:rackspace_auth_url => @rackspace_auth_url,
:connection_options => @connection_options
}

super(options)
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/rackspace/load_balancers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def authenticate
options = {
:rackspace_api_key => @rackspace_api_key,
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url
:rackspace_auth_url => @rackspace_auth_url,
:connection_options => @connection_options
}
super(options)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/rackspace/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def authenticate_v2(identity_options)
hash = {
:rackspace_api_key => identity_options[:rackspace_api_key],
:rackspace_username => identity_options[:rackspace_username],
:rackspace_auth_url => identity_options[:rackspace_auth_url]
:rackspace_auth_url => identity_options[:rackspace_auth_url],
:connection_options => identity_options[:connection_options] || {}
}

@identity_service = Fog::Rackspace::Identity.new(hash)
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/rackspace/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def authenticate
options = {
:rackspace_api_key => @rackspace_api_key,
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url
:rackspace_auth_url => @rackspace_auth_url,
:connection_options => @connection_options
}
super(options)
else
Expand Down
9 changes: 6 additions & 3 deletions tests/rackspace/block_storage_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ def assert_method(url, method)
end
end

tests('current authentation') do
tests('current authentication') do
pending if Fog.mocking?

tests('variables populated').succeeds do
@service = Fog::Rackspace::BlockStorage.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
@service = Fog::Rackspace::BlockStorage.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :connection_options => {:ssl_verify_peer => true}
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }

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) }
@service.list_volumes
end
tests('dfw region').succeeds do
Expand Down
7 changes: 5 additions & 2 deletions tests/rackspace/cdn_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ def assert_method(url, method)
pending if Fog.mocking?

tests('variables populated').succeeds do
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
@service = Fog::CDN::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :connection_options => { :ssl_verify_peer => true }
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").path.nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
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) }

@service.get_containers
end
tests('dfw region').succeeds do
Expand Down
6 changes: 4 additions & 2 deletions tests/rackspace/compute_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ def assert_method(url, method)
pending if Fog.mocking?

tests('variables populated').succeeds do
@service = Fog::Compute::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
@service = Fog::Compute::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :connection_options => { :ssl_verify_peer => true }
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(true) { (@service.instance_variable_get("@uri").host == 'servers.api.rackspacecloud.com') != nil }

returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
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) }
@service.list_flavors
end

Expand Down
6 changes: 4 additions & 2 deletions tests/rackspace/compute_v2_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ def assert_method(url, method)
pending if Fog.mocking?

tests('variables populated').succeeds do
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
@service = Fog::Compute::RackspaceV2.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :connection_options => {:ssl_verify_peer => true}
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
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) }
@service.list_flavors
end
tests('dfw region').succeeds do
Expand Down
7 changes: 5 additions & 2 deletions tests/rackspace/databases_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ def assert_method(url, method)
pending if Fog.mocking?

tests('variables populated').succeeds do
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
@service = Fog::Rackspace::Databases.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :connection_options => { :ssl_verify_peer => true }
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }

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) }
@service.flavors
end
tests('dfw region').succeeds do
Expand Down
7 changes: 5 additions & 2 deletions tests/rackspace/dns_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ def assert_method(url, method)
pending if Fog.mocking?

tests('variables populated').succeeds do
@service = Fog::DNS::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
@service = Fog::DNS::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :connection_options => { :ssl_verify_peer => true }
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
returns(true, "contains tenant id") { (@service.instance_variable_get("@uri").path =~ /\/v1\.0\/\d+$/) != nil} #dns does not error if tenant id is missing
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }

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) }
@service.list_domains
end
tests('custom endpoint') do
Expand Down
6 changes: 4 additions & 2 deletions tests/rackspace/load_balancer_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ def assert_method(url, method)
pending if Fog.mocking?

tests('variables populated').succeeds do
@service = Fog::Rackspace::LoadBalancers.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
@service = Fog::Rackspace::LoadBalancers.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :connection_options => { :ssl_verify_peer => true }
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }
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) }
@service.list_load_balancers
end
tests('dfw region').succeeds do
Expand Down
9 changes: 9 additions & 0 deletions tests/rackspace/requests/identity/token_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
tests('#create_token').formats(ACCESS_FORMAT) do
service.create_token(username, api_key).body
end

tests('uses connection options').returns(true) do
identity_service = Fog::Rackspace::Identity.new(:connection_options => { :ssl_verify_peer => true })

connection = identity_service.instance_variable_get("@connection")
excon = connection.instance_variable_get("@excon")
data = excon.instance_variable_get("@data")
data.has_key?(:ssl_verify_peer)
end
end

tests('failure') do
Expand Down
7 changes: 5 additions & 2 deletions tests/rackspace/storage_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ def assert_method(url, method)
pending if Fog.mocking?

tests('variables populated').succeeds do
@service = Fog::Storage::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0'
@service = Fog::Storage::Rackspace.new :rackspace_auth_url => 'https://identity.api.rackspacecloud.com/v2.0', :connection_options => { :ssl_verify_peer => true }
returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
returns(false, "path populated") { @service.instance_variable_get("@uri").nil? }
returns(false, "identity service was used") { @service.instance_variable_get("@identity_service").nil? }

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) }
@service.head_containers
end
tests('dfw region').succeeds do
Expand Down

0 comments on commit 5eebf7d

Please sign in to comment.