Sha256: c2ec37af41e9d0bee14d604fc7c9a96ba380ebdb7c117c1e750c77d9006f751e

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

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

describe OAuth2::Grant::Implicit 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::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

4 entries across 4 versions & 1 rubygems

Version Path
oauth2-client-1.1.3 spec/oauth2/grant/implicit_spec.rb
oauth2-client-1.1.2 spec/oauth2/grant/implicit_spec.rb
oauth2-client-1.1.1 spec/oauth2/grant/implicit_spec.rb
oauth2-client-1.1.0 spec/oauth2/grant/implicit_spec.rb