I can make a request via rails console fine, so I know the app has been implemented correctly. When using the provided helper methods to sign the simple get request in the controller spec, the request does not appear to be signed correctly. Am I doing something wrong?
The successful console call:
coneybeare $ rails c test
Loading test environment (Rails 3.2.0)
rails test: main
>> consumer = OAuth::Consumer.new("one_key", "MyString", :site => [REDACTED])
# => #<OAuth::Consumer:0x007f9d01252268 @key="one_key", @secret="MyString", @options={:signature_method=>"HMAC-SHA1", :request_token_path=>"/oauth/request_token", :authorize_path=>"/oauth/authorize", :access_token_path=>"/oauth/access_token", :proxy=>nil, :scheme=>:header, :http_method=>:post, :oauth_version=>"1.0", :site=>[REDACTED]}>
ruby: main
>> req = consumer.create_signed_request(:get, "/api/v1/users.json", nil)
# => #<Net::HTTP::Get GET>
ruby: main
>> res = Net::HTTP.start([REDACTED]) {|http| http.request(req) }
# => #<Net::HTTPOK 200 OK readbody=true>
ruby: main
>> puts res.body
{"users":[{"id":206669143},{"id":358143215}]}
# => nil
The failed controller test:
it "responds as success with a valid oath signature" do
consumer = OAuth::Consumer.new("one_key", "MyString", :site => [REDACTED])
two_legged_sign_request_with_oauth(consumer)
get :index, {:api_version => 'v1', :format => :json}
response.should be_success
end
I can make a request via
rails console
fine, so I know the app has been implemented correctly. When using the provided helper methods to sign the simple get request in the controller spec, the request does not appear to be signed correctly. Am I doing something wrong?The successful console call:
The failed controller test:
My versions are:
Is this a bug? If not, can anybody point me in the right direction for testing controllers that are
oauthenticated
with a 2-legged approach?