Sha256: 30cafe8393654f8ed4f7d12c639f44d57be5b938605b11844b30c8c2593e8f27
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
require File.expand_path('../../../spec_helper', __FILE__) require 'oauth2-client/helper' describe OAuth2Client::Grant::Base do before :all do @client = OpenStruct.new( :host => 'example.com', :client_id => 's6BhdRkqt3', :client_secret => 'SplxlOBeZQQYbYS6WxSbIA', :authorize_path => '/oauth2/authorize', :token_path => '/oauth2/token', :device_path => '/oauth2/device', :connection => OpenStruct.new ) end subject do OAuth2Client::Grant::Base.new(@client) end describe "#make_request" do context "without authenticate option" do it "does not send authorization credentials" do @client.connection.should_receive(:send_request).with(:get, '/oauth2', {}) subject.make_request(:get, '/oauth2') end end context "with authenticate option" do context "option is headers" do it "authorization credentials in headers" do opts = { :headers => {'Authorization' => OAuth2Client::UrlHelper::http_basic_encode(@client.client_id, @client.client_secret)}, :params => {:client_id => @client.client_id} } @client.connection.should_receive(:send_request).with(:get, '/oauth2', opts) subject.make_request(:get, '/oauth2', :authenticate => :headers, :params => {:client_id => @client.client_id}) end end context "option is body" do it "authorization credentials in body" do opts = { :params => { :code => 'abc123', :client_id => @client.client_id, :client_secret => @client.client_secret }, } @client.connection.should_receive(:send_request).with(:get, '/oauth2', opts) subject.make_request(:get, '/oauth2', :params => {:code => 'abc123'}, :authenticate => :body) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
oauth2-client-2.0.0 | spec/oauth2-client/grant/base_spec.rb |