Class: ActionController::TestRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/oauth/request_proxy/action_controller_request.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.use_oauth=(bool) ⇒ Object



78
79
80
# File 'lib/oauth/request_proxy/action_controller_request.rb', line 78

def self.use_oauth=(bool)
  @use_oauth = bool
end

.use_oauth?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/oauth/request_proxy/action_controller_request.rb', line 82

def self.use_oauth?
  @use_oauth
end

Instance Method Details

#apply_oauth!Object



95
96
97
98
99
100
101
102
# File 'lib/oauth/request_proxy/action_controller_request.rb', line 95

def apply_oauth!
  return unless ActionController::TestRequest.use_oauth? && @oauth_options

  @oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:request_uri => (respond_to?(:fullpath) ? fullpath : request_uri)))
  @oauth_helper.amend_user_agent_header(env)

  self.send("set_oauth_#{@oauth_options[:scheme]}")
end

#configure_oauth(consumer = nil, token = nil, options = {}) ⇒ Object



86
87
88
89
90
91
92
93
# File 'lib/oauth/request_proxy/action_controller_request.rb', line 86

def configure_oauth(consumer = nil, token = nil, options = {})
  @oauth_options = { :consumer  => consumer,
                     :token     => token,
                     :scheme    => 'header',
                     :signature_method => nil,
                     :nonce     => nil,
                     :timestamp => nil }.merge(options)
end

#set_oauth_headerObject



104
105
106
# File 'lib/oauth/request_proxy/action_controller_request.rb', line 104

def set_oauth_header
  env['Authorization'] = @oauth_helper.header
end

#set_oauth_parametersObject



108
109
110
111
# File 'lib/oauth/request_proxy/action_controller_request.rb', line 108

def set_oauth_parameters
  @query_parameters = @oauth_helper.parameters_with_oauth
  @query_parameters.merge!(:oauth_signature => @oauth_helper.signature)
end

#set_oauth_query_stringObject



113
114
# File 'lib/oauth/request_proxy/action_controller_request.rb', line 113

def set_oauth_query_string
end