Sha256: 7c5baba73dced283aafa46f35fa576e998e3496b538f8f8144503d5cfe7f9a95

Contents?: true

Size: 1.17 KB

Versions: 40

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe Rack::OAuth2::AccessToken::Authenticator do
  let(:resource_endpoint) { 'https://server.example.com/resources/fake' }
  let(:request) { HTTP::Message.new_request(: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.filter_request(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

  context 'when MAC token is given' do
    let(:token) do
      Rack::OAuth2::AccessToken::MAC.new(
        access_token: 'access_token',
        mac_key: 'secret',
        mac_algorithm: 'hmac-sha-256'
      )
    end
    it_behaves_like :authenticator
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
rack-oauth2-1.21.3 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.21.2 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.21.1 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.21.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.20.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.19.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.18.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.17.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.16.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.15.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.14.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.13.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.13.0.beta spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.12.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.11.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.10.1 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.10.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.9.3 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.9.2 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.9.1 spec/rack/oauth2/access_token/authenticator_spec.rb