Sha256: 79896d888458e6b001c5cac2f9d190fb50a3ee13ce73a21c6a0dfd7e45b0dacf

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

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

describe OAuth2Client::Grant::Implicit do

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

  subject do
    OAuth2Client::Grant::Implicit.new(@client)
  end

  describe "#response_type" do
    it "returns response type" do
      expect(subject.response_type).to eq 'token'
    end
  end

  describe "#token_url" do
    it "generates a token path using the given parameters" do
      path = subject.token_url(:scope => 'xyz', :state => 'abc xyz')
      query_values = Addressable::URI.parse(path).query_values
      expect(query_values).to eq({"scope"=>"xyz", "state"=>"abc xyz", "response_type"=>"token", "client_id"=>"s6BhdRkqt3"})
    end
  end

  describe "#get_token" do
    it "gets access token" do
      subject.should_receive(:make_request).with(:get, "/oauth2/token", {
        :params       => {:scope=>"xyz", :state=>"abc xyz", :response_type=>"token", :client_id=>"s6BhdRkqt3"},
        :authenticate => :headers
      })
      subject.get_token(:params => {:scope => 'xyz', :state => 'abc xyz'})
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oauth2-client-2.0.0 spec/oauth2-client/grant/implicit_spec.rb