lib/fog/rackspace/identity.rb in fog-maestrodev-1.19.0.20140212012611 vs lib/fog/rackspace/identity.rb in fog-maestrodev-1.20.0.20140305101305

- old
+ new

@@ -1,6 +1,6 @@ -require 'fog/rackspace' +require 'fog/rackspace/core' module Fog module Rackspace class Identity < Fog::Service @@ -32,22 +32,20 @@ request :get_user_by_name request :create_user request :update_user request :delete_user - class Mock < Fog::Rackspace::Service - attr_reader :service_catalog - - def request - Fog::Mock.not_implemented + module Common + attr_reader :service_catalog, :auth_token + + def authenticate(options={}) + data = self.create_token(@rackspace_username, @rackspace_api_key).body + @service_catalog = ServiceCatalog.from_response(self, data) + @auth_token = data['access']['token']['id'] end - end - class Real < Fog::Rackspace::Service - attr_reader :service_catalog, :auth_token - - def initialize(options={}) + def apply_options(options) @rackspace_username = options[:rackspace_username] @rackspace_api_key = options[:rackspace_api_key] @rackspace_region = options[:rackspace_region] @rackspace_auth_url = options[:rackspace_auth_url] || US_ENDPOINT @@ -56,18 +54,30 @@ @path = @uri.path @port = @uri.port @scheme = @uri.scheme @persistent = options[:persistent] || false @connection_options = options[:connection_options] || {} - @connection = Fog::Connection.new(@uri.to_s, @persistent, @connection_options) + end + end + class Mock < Fog::Rackspace::Service + include Common + + def initialize(options={}) + apply_options(options) + authenticate end + end + + class Real < Fog::Rackspace::Service + include Common - def authenticate(options={}) - data = self.create_token(@rackspace_username, @rackspace_api_key).body - @service_catalog = ServiceCatalog.from_response(self, data) - @auth_token = data['access']['token']['id'] + def initialize(options={}) + apply_options(options) + @connection = Fog::Connection.new(@uri.to_s, @persistent, @connection_options) + + authenticate end end end end end