Sha256: e1ced13bd5836b91f232195862852eec7a00919b1508788e0bf2e9d37f15a9ae

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)

describe OAuth2::Grant::DeviceCode do

  before :all do
    @host           = 'example.com'
    @client_id      = 's6BhdRkqt3'
    @client_secret  = 'SplxlOBeZQQYbYS6WxSbIA'
    @client = OAuth2::Client.new(@host, @client_id, @client_secret)
  end

  subject do
    OAuth2::Grant::DeviceCode.new(@client)
  end

  describe "#grant_type" do
    it "returns grant type" do
      expect(subject.grant_type).to eq 'http://oauth.net/grant_type/device/1.0'
    end
  end

  describe "#get_code" do
    it "gets user code" do
      subject.should_receive(:make_request).with(:post, "/oauth2/device/code", {:params=>{:client_id=>"s6BhdRkqt3"}})
      subject.get_code
    end
  end

  describe "#get_token" do
    it "gets access token" do
      subject.should_receive(:make_request).with(:post, "/oauth2/token", {:params=>{:code=>"G3Y6jU3a", :grant_type=>"http://oauth.net/grant_type/device/1.0"}, :authenticate=>:headers})
      subject.get_token('G3Y6jU3a')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oauth2-client-1.0.0 spec/oauth2/grant/device_spec.rb