Sha256: 206a209c30098a4ff3a7196dc3566fb25c486fd43f952053d980fe09ec1efdea

Contents?: true

Size: 926 Bytes

Versions: 6

Compression:

Stored size: 926 Bytes

Contents

require 'spec_helper'

describe Rack::OAuth2::AccessToken::Authenticator do
  let(:resource_endpoint) { 'https://server.example.com/resources/fake' }
  let(:request) { Faraday::Request.new(:get, URI.parse(resource_endpoint)) }
  let(:authenticator) { Rack::OAuth2::AccessToken::Authenticator.new(token) }

  shared_examples_for :authenticator do
    it 'should let the token authenticate the request' do
      expect(token).to receive(:authenticate).with(request)
      authenticator.authenticate(request)
    end
  end

  context 'when Legacy token is given' do
    let(:token) do
      Rack::OAuth2::AccessToken::Legacy.new(
        access_token: 'access_token'
      )
    end
    it_behaves_like :authenticator
  end

  context 'when Bearer token is given' do
    let(:token) do
      Rack::OAuth2::AccessToken::Bearer.new(
        access_token: 'access_token'
      )
    end
    it_behaves_like :authenticator
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rack-oauth2-2.1.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-2.0.1 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-2.0.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-2.0.0.rc3 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-2.0.0.rc2 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-2.0.0.rc1 spec/rack/oauth2/access_token/authenticator_spec.rb